org.objectweb.proactive.core.body
Class AbstractBody

java.lang.Object
  |
  +--org.objectweb.proactive.core.body.AbstractUniversalBody
        |
        +--org.objectweb.proactive.core.body.AbstractBody
All Implemented Interfaces:
Body, Job, LocalBodyStrategy, MessageEventProducer, java.io.Serializable, UniversalBody
Direct Known Subclasses:
BodyImpl, HalfBody

public abstract class AbstractBody
extends AbstractUniversalBody
implements Body, java.io.Serializable

**For internal use only**

This class gives a common implementation of the Body interface. It provides all the non specific behavior allowing sub-class to write the detail implementation.

Each body is identify by an unique identifier.

All active bodies that get created in one JVM register themselves into a table that allows to tack them done. The registering and deregistering is done by the AbstractBody and the table is managed here as well using some static methods.

In order to let somebody customize the body of an active object without subclassing it, AbstractBody delegates lot of tasks to satellite objects that implements a given interface. Abstract protected methods instantiate those objects allowing subclasses to create them as they want (using customizable factories or instance).

Since:
ProActive 0.9
Version:
1.0, 2001/10/23
Author:
ProActive Team
See Also:
Body, UniqueID, Serialized Form

Field Summary
protected  InternalBodySecurity internalBodySecurity
           
protected  boolean isSecurityOn
           
protected  LocalBodyStrategy localBodyStrategy
           
protected static org.apache.log4j.Logger logger
           
protected  java.util.Hashtable openedSessions
           
protected  ProActiveGroupManager pgm
           
protected  ProActiveSecurityManager psm
           
protected  ThreadStore threadStore
           
 
Fields inherited from class org.objectweb.proactive.core.body.AbstractUniversalBody
bodyID, location, nodeURL, remoteBody, remoteBodyFactory
 
Constructor Summary
AbstractBody()
          Creates a new AbstractBody.
AbstractBody(java.lang.Object reifiedObject, java.lang.String nodeURL, MetaObjectFactory factory)
          Creates a new AbstractBody for an active object attached to a given node.
 
Method Summary
 void acceptCommunication()
          Signals the body to accept all incoming communications.
protected  void activityStarted()
          Signals that the activity of this body, managed by the active thread has just started.
protected  void activityStopped()
          Signals that the activity of this body, managed by the active thread has just stopped.
 void blockCommunication()
          blocks all incoming communications.
 UniversalBody checkNewLocation(UniqueID bodyID)
          Tries to find a local version of the body of id uniqueID.
 void disableAC()
          Disables automatic continuation mechanism for this body
 void enableAC()
          Enables automatic continuation mechanism for this body
 void enterInThreadStore()
          Allows the calling thread to enter in the ThreadStore of this body.
 void exitFromThreadStore()
          Allows the calling thread to exit from the ThreadStore of this body.
 java.security.cert.X509Certificate getCertificate()
           
 byte[] getCertificateEncoded()
           
 java.util.ArrayList getEntities()
           
 FuturePool getFuturePool()
          Returns the future pool of this body
 java.lang.String getName()
          Returns the name of this body that can be used for displaying information
 SecurityContext getPolicy(SecurityContext securityContext)
           
 Policy getPolicyFrom(java.security.cert.X509Certificate certificate)
           
 Communication getPolicyTo(java.lang.String type, java.lang.String from, java.lang.String to)
           
 ProActiveSecurityManager getProActiveSecurityManager()
           
 java.security.PublicKey getPublicKey()
           
 java.lang.Object getReifiedObject()
          Returns the reified object that body is for The reified object is the object that has been turned active.
 BlockingRequestQueue getRequestQueue()
          Returns the request queue associated to this body
 java.lang.Object getSPMDGroup()
          Returns the SPMD group of the active object
 java.lang.String getVNName()
           
 void initiateSession(int type, UniversalBody body)
           
protected abstract  void internalReceiveReply(Reply reply)
          Receives a reply in response to a former request.
protected abstract  void internalReceiveRequest(Request request)
          Receives a request for later processing.
 boolean isActive()
          Returns whether the body is active or not.
 boolean isAlive()
          Returns whether the body is alive or not.
 ConfidentialityTicket negociateKeyReceiverSide(ConfidentialityTicket confidentialityTicket, long sessionID)
           
 byte[][] publicKeyExchange(long sessionID, UniversalBody distantBody, byte[] my_pub, byte[] my_cert, byte[] sig_code)
           
 byte[] randomValue(long sessionID, byte[] cl_rand)
           
 void receiveReply(Reply reply)
          Receives a reply in response to a former request.
 void receiveRequest(Request request)
          Receives a request for later processing.
 void renegociateSessionIfNeeded(long sID)
           
 byte[][] secretKeyExchange(long sessionID, byte[] tmp, byte[] tmp1, byte[] tmp2, byte[] tmp3, byte[] tmp4)
           
 void sendRequest(MethodCall methodCall, Future future, UniversalBody destinationBody)
          Sends the request request with the future future to the local body body.
 void serve(Request request)
          Serves the request.
protected  void setLocalBodyImpl(LocalBodyStrategy localBody)
           
 void setSPMDGroup(java.lang.Object o)
          Set the SPMD group for the active object
protected  void startDefaultProActiveSecurityManager()
           
 long startNewSession(Communication policy)
           
 void terminate()
          Terminate the body.
 void terminateSession(long sessionID)
           
 void test()
           
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.objectweb.proactive.core.body.AbstractUniversalBody
getID, getNodeURL, getRemoteAdapter, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.objectweb.proactive.core.body.UniversalBody
getID, getNodeURL, getRemoteAdapter, setImmediateService, updateLocation
 
Methods inherited from interface org.objectweb.proactive.core.body.message.MessageEventProducer
addMessageEventListener, removeMessageEventListener
 
Methods inherited from interface org.objectweb.proactive.Job
getJobID
 

Field Detail

threadStore

protected ThreadStore threadStore

localBodyStrategy

protected LocalBodyStrategy localBodyStrategy

psm

protected ProActiveSecurityManager psm

isSecurityOn

protected boolean isSecurityOn

internalBodySecurity

protected transient InternalBodySecurity internalBodySecurity

openedSessions

protected java.util.Hashtable openedSessions

logger

protected static org.apache.log4j.Logger logger

pgm

protected ProActiveGroupManager pgm
Constructor Detail

AbstractBody

public AbstractBody()
Creates a new AbstractBody. Used for serialization.


AbstractBody

public AbstractBody(java.lang.Object reifiedObject,
                    java.lang.String nodeURL,
                    MetaObjectFactory factory)
Creates a new AbstractBody for an active object attached to a given node.

Parameters:
reifiedObject - the active object that body is for
nodeURL - the URL of the node that body is attached to
factory - the factory able to construct new factories for each type of meta objects needed by this body
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object

receiveRequest

public void receiveRequest(Request request)
                    throws java.io.IOException,
                           RenegotiateSessionException
Description copied from interface: UniversalBody
Receives a request for later processing. The call to this method is non blocking unless the body cannot temporary receive the request.

Specified by:
receiveRequest in interface UniversalBody
Parameters:
request - the request to process
Throws:
java.io.IOException - if the request cannot be accepted
RenegotiateSessionException

receiveReply

public void receiveReply(Reply reply)
                  throws java.io.IOException
Description copied from interface: UniversalBody
Receives a reply in response to a former request.

Specified by:
receiveReply in interface UniversalBody
Throws:
java.io.IOException - if the reply cannot be accepted

enableAC

public void enableAC()
Description copied from interface: UniversalBody
Enables automatic continuation mechanism for this body

Specified by:
enableAC in interface UniversalBody

disableAC

public void disableAC()
Description copied from interface: UniversalBody
Disables automatic continuation mechanism for this body

Specified by:
disableAC in interface UniversalBody

renegociateSessionIfNeeded

public void renegociateSessionIfNeeded(long sID)
                                throws java.io.IOException,
                                       RenegotiateSessionException,
                                       SecurityNotAvailableException
java.io.IOException
RenegotiateSessionException
SecurityNotAvailableException

getVNName

public java.lang.String getVNName()
                           throws java.io.IOException,
                                  SecurityNotAvailableException
Specified by:
getVNName in interface UniversalBody
Returns:
name of the virtual node where the object has been created
java.io.IOException
SecurityNotAvailableException

initiateSession

public void initiateSession(int type,
                            UniversalBody body)
                     throws java.io.IOException,
                            CommunicationForbiddenException,
                            AuthenticationException,
                            RenegotiateSessionException,
                            SecurityNotAvailableException
Specified by:
initiateSession in interface UniversalBody
java.io.IOException
CommunicationForbiddenException
AuthenticationException
RenegotiateSessionException
SecurityNotAvailableException

terminateSession

public void terminateSession(long sessionID)
                      throws java.io.IOException,
                             SecurityNotAvailableException
Specified by:
terminateSession in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

getCertificate

public java.security.cert.X509Certificate getCertificate()
                                                  throws java.io.IOException,
                                                         SecurityNotAvailableException
Specified by:
getCertificate in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

getProActiveSecurityManager

public ProActiveSecurityManager getProActiveSecurityManager()
                                                     throws java.io.IOException,
                                                            SecurityNotAvailableException
Specified by:
getProActiveSecurityManager in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

getPolicyFrom

public Policy getPolicyFrom(java.security.cert.X509Certificate certificate)
                     throws java.io.IOException,
                            SecurityNotAvailableException
Specified by:
getPolicyFrom in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

startNewSession

public long startNewSession(Communication policy)
                     throws java.io.IOException,
                            RenegotiateSessionException,
                            SecurityNotAvailableException
Specified by:
startNewSession in interface UniversalBody
java.io.IOException
RenegotiateSessionException
SecurityNotAvailableException

negociateKeyReceiverSide

public ConfidentialityTicket negociateKeyReceiverSide(ConfidentialityTicket confidentialityTicket,
                                                      long sessionID)
                                               throws java.io.IOException,
                                                      KeyExchangeException,
                                                      SecurityNotAvailableException
Specified by:
negociateKeyReceiverSide in interface UniversalBody
java.io.IOException
KeyExchangeException
SecurityNotAvailableException

getPublicKey

public java.security.PublicKey getPublicKey()
                                     throws java.io.IOException,
                                            SecurityNotAvailableException
Specified by:
getPublicKey in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

randomValue

public byte[] randomValue(long sessionID,
                          byte[] cl_rand)
                   throws java.io.IOException,
                          SecurityNotAvailableException,
                          java.lang.Exception
Specified by:
randomValue in interface UniversalBody
java.io.IOException
SecurityNotAvailableException
java.lang.Exception

publicKeyExchange

public byte[][] publicKeyExchange(long sessionID,
                                  UniversalBody distantBody,
                                  byte[] my_pub,
                                  byte[] my_cert,
                                  byte[] sig_code)
                           throws java.io.IOException,
                                  SecurityNotAvailableException,
                                  java.lang.Exception
Specified by:
publicKeyExchange in interface UniversalBody
java.io.IOException
SecurityNotAvailableException
java.lang.Exception

secretKeyExchange

public byte[][] secretKeyExchange(long sessionID,
                                  byte[] tmp,
                                  byte[] tmp1,
                                  byte[] tmp2,
                                  byte[] tmp3,
                                  byte[] tmp4)
                           throws java.io.IOException,
                                  java.lang.Exception,
                                  SecurityNotAvailableException
Specified by:
secretKeyExchange in interface UniversalBody
java.io.IOException
java.lang.Exception
SecurityNotAvailableException

getPolicyTo

public Communication getPolicyTo(java.lang.String type,
                                 java.lang.String from,
                                 java.lang.String to)
                          throws SecurityNotAvailableException,
                                 java.io.IOException
Specified by:
getPolicyTo in interface UniversalBody
SecurityNotAvailableException
java.io.IOException

getPolicy

public SecurityContext getPolicy(SecurityContext securityContext)
                          throws java.io.IOException,
                                 SecurityNotAvailableException
Specified by:
getPolicy in interface UniversalBody
java.io.IOException
SecurityNotAvailableException

getCertificateEncoded

public byte[] getCertificateEncoded()
                             throws java.io.IOException,
                                    SecurityNotAvailableException
Specified by:
getCertificateEncoded in interface UniversalBody
Returns:
object's X509Certificate as byte array
java.io.IOException
SecurityNotAvailableException

startDefaultProActiveSecurityManager

protected void startDefaultProActiveSecurityManager()

getEntities

public java.util.ArrayList getEntities()
                                throws SecurityNotAvailableException,
                                       java.io.IOException
Specified by:
getEntities in interface UniversalBody
SecurityNotAvailableException
java.io.IOException

terminate

public void terminate()
Description copied from interface: Body
Terminate the body. After this call the body is no more alive and no more active although the active thread is not interrupted. The body is unuseable after this call.

Specified by:
terminate in interface Body

blockCommunication

public void blockCommunication()
Description copied from interface: Body
blocks all incoming communications. After this call, the body cannot receive any request or reply.

Specified by:
blockCommunication in interface Body

acceptCommunication

public void acceptCommunication()
Description copied from interface: Body
Signals the body to accept all incoming communications. This call undo a previous call to blockCommunication.

Specified by:
acceptCommunication in interface Body

enterInThreadStore

public void enterInThreadStore()
Description copied from interface: Body
Allows the calling thread to enter in the ThreadStore of this body.

Specified by:
enterInThreadStore in interface Body

exitFromThreadStore

public void exitFromThreadStore()
Description copied from interface: Body
Allows the calling thread to exit from the ThreadStore of this body.

Specified by:
exitFromThreadStore in interface Body

isAlive

public boolean isAlive()
Description copied from interface: Body
Returns whether the body is alive or not. The body is alive as long as it is processing request and reply

Specified by:
isAlive in interface Body
Returns:
whether the body is alive or not.

isActive

public boolean isActive()
Description copied from interface: Body
Returns whether the body is active or not. The body is active as long as it has an associated thread running to serve the requests by calling methods on the active object.

Specified by:
isActive in interface Body
Returns:
whether the body is active or not.

checkNewLocation

public UniversalBody checkNewLocation(UniqueID bodyID)
Description copied from interface: Body
Tries to find a local version of the body of id uniqueID. If a local version is found it is returned. If not, tries to find the body of id uniqueID in the known body of this body. If a body is found it is returned, else null is returned.

Specified by:
checkNewLocation in interface Body
Parameters:
bodyID - the id of the body to lookup
Returns:
the last known version of the body of id uniqueID or null if not known

getFuturePool

public FuturePool getFuturePool()
Description copied from interface: LocalBodyStrategy
Returns the future pool of this body

Specified by:
getFuturePool in interface LocalBodyStrategy
Returns:
the future pool of this body

getRequestQueue

public BlockingRequestQueue getRequestQueue()
Description copied from interface: LocalBodyStrategy
Returns the request queue associated to this body

Specified by:
getRequestQueue in interface LocalBodyStrategy
Returns:
the request queue associated to this body

getReifiedObject

public java.lang.Object getReifiedObject()
Description copied from interface: LocalBodyStrategy
Returns the reified object that body is for The reified object is the object that has been turned active.

Specified by:
getReifiedObject in interface LocalBodyStrategy
Returns:
the reified object that body is for

getName

public java.lang.String getName()
Description copied from interface: LocalBodyStrategy
Returns the name of this body that can be used for displaying information

Specified by:
getName in interface LocalBodyStrategy
Returns:
the name of this body

serve

public void serve(Request request)
Serves the request. The request should be removed from the request queue before serving, which is correctly done by all methods of the Service class. However, this condition is not ensured for custom calls on serve.

Specified by:
serve in interface LocalBodyStrategy
Parameters:
request - the request to serve

sendRequest

public void sendRequest(MethodCall methodCall,
                        Future future,
                        UniversalBody destinationBody)
                 throws java.io.IOException,
                        RenegotiateSessionException
Description copied from interface: LocalBodyStrategy
Sends the request request with the future future to the local body body.

Specified by:
sendRequest in interface LocalBodyStrategy
Parameters:
methodCall - the methodCall to send
future - the future associated to the request
destinationBody - the body the request is sent to
Throws:
java.io.IOException - if the request cannot be sent to the destination body
RenegotiateSessionException

internalReceiveRequest

protected abstract void internalReceiveRequest(Request request)
                                        throws java.io.IOException,
                                               RenegotiateSessionException
Receives a request for later processing. The call to this method is non blocking unless the body cannot temporary receive the request.

Parameters:
request - the request to process
Throws:
java.io.IOException - if the request cannot be accepted
RenegotiateSessionException

internalReceiveReply

protected abstract void internalReceiveReply(Reply reply)
                                      throws java.io.IOException
Receives a reply in response to a former request.

Parameters:
reply - the reply received
Throws:
java.io.IOException - if the reply cannot be accepted

setLocalBodyImpl

protected void setLocalBodyImpl(LocalBodyStrategy localBody)

activityStopped

protected void activityStopped()
Signals that the activity of this body, managed by the active thread has just stopped.


activityStarted

protected void activityStarted()
Signals that the activity of this body, managed by the active thread has just started.


setSPMDGroup

public void setSPMDGroup(java.lang.Object o)
Set the SPMD group for the active object

Parameters:
o - - the new SPMD group

getSPMDGroup

public java.lang.Object getSPMDGroup()
Returns the SPMD group of the active object

Returns:
the SPMD group of the active object

test

public void test()


Copyright © April 2004 INRIA All Rights Reserved.