org.objectweb.proactive.core.body
Class BodyAdapterImpl

java.lang.Object
  extended byorg.objectweb.proactive.core.body.BodyAdapter
      extended byorg.objectweb.proactive.core.body.BodyAdapterImpl
All Implemented Interfaces:
java.lang.Cloneable, Job, NFEProducer, SecurityEntity, java.io.Serializable, UniversalBody
Direct Known Subclasses:
HttpBodyAdapter, IbisBodyAdapter, JiniBodyAdapter, RmiBodyAdapter

public abstract class BodyAdapterImpl
extends BodyAdapter
implements java.lang.Cloneable, java.io.Serializable

An adapter for a RemoteBody. The Adpater is the generic entry point for remote calls to a RemoteBody using different protocols such as RMI, RMISSH, IBIS, HTTP, JINI. This also allows to cache informations, and so to avoid crossing the network when calling some methods.

Since:
ProActive 2.2
Author:
ProActiveTeam
See Also:
smartProxy Pattern., Serialized Form

Field Summary
protected  RemoteBody proxiedRemoteBody
          The encapsulated RmiRemoteBody
 
Fields inherited from class org.objectweb.proactive.core.body.BodyAdapter
bodyID, jobID
 
Fields inherited from interface org.objectweb.proactive.core.body.UniversalBody
bodyLogger
 
Constructor Summary
BodyAdapterImpl()
           
 
Method Summary
 void addNFEListener(NFEListener listener)
           
 void changeProxiedBody(Body newBody)
          Change the body referenced by this adapter.
protected  void construct(RemoteBody remoteBody)
           
 void createShortcut(Shortcut shortcut)
          similar to the UniversalBody.updateLocation(org.objectweb.proactive.core.UniqueID, UniversalBody) method, it allows direct communication to the target of a functional call, accross membranes of composite components.
 void disableAC()
          Disables automatic continuation mechanism for this body
 void enableAC()
          Enables automatic continuation mechanism for this body
 boolean equals(java.lang.Object o)
           
 int fireNFE(NonFunctionalException e)
           
 java.security.cert.X509Certificate getCertificate()
          entity certificate
 byte[] getCertificateEncoded()
          Entity's X509Certificate as byte array
 java.util.ArrayList getEntities()
          Retrieves all the entity's ID which contain this entity plus this entity ID.
 UniqueID getID()
          Returns the UniqueID of this body This identifier is unique accross all JVMs
 java.lang.String getJobID()
           
 java.lang.String getNodeURL()
          Returns the url of the node this body is associated to The url of the node can change if the active object migrates
 SecurityContext getPolicy(SecurityContext securityContext)
          Ask the entity to fill the securityContext parameters with its own policy according to the communication details contained in the given securityContext
 java.security.PublicKey getPublicKey()
          entity public key
 BodyAdapter getRemoteAdapter()
          Returns the remote friendly version of this body
 int hashCode()
           
abstract  UniversalBody lookup(java.lang.String url)
          Looks-up an active object previously registered in a registry.
 byte[][] publicKeyExchange(long sessionID, byte[] myPublicKey, byte[] myCertificate, byte[] signature)
          exchange entity certificate and/or public key if certificate are not available
 byte[] randomValue(long sessionID, byte[] clientRandomValue)
          Exchange random value between client and server entity
protected  java.lang.Object readResolve()
           
 java.lang.Object receiveFTMessage(FTMessage ev)
          For sending a non fonctional message to the FTManager linked to this object.
 int receiveReply(Reply r)
          Receives a reply in response to a former request.
 int receiveRequest(Request request)
          Receives a request for later processing.
abstract  void register(java.lang.String url)
          Registers an active object into protocol-specific registry.
 void removeImmediateService(java.lang.String methodName, java.lang.Class[] parametersTypes)
          Removes an immediate service for this body An immediate service is a method that will bw excecuted by the calling thread.
 void removeNFEListener(NFEListener listener)
           
 byte[][] secretKeyExchange(long sessionID, byte[] encodedAESKey, byte[] encodedIVParameters, byte[] encodedClientMacKey, byte[] encodedLockData, byte[] parametersSignature)
          this method sends encoded secret parameters to the target entity
 void setImmediateService(java.lang.String methodName)
          For setting an immediate service for this body.
 void setImmediateService(java.lang.String methodName, java.lang.Class[] parametersTypes)
          Adds an immediate service for this body An immediate service is a method that will bw excecuted by the calling thread.
 long startNewSession(Communication policy)
          start an unvalidated empty session
 void terminate()
          Terminate the body.
 void terminateSession(long sessionID)
          terminate a given session
abstract  void unregister(java.lang.String url)
          Unregisters an active object previously registered into a registry.
 void updateLocation(UniqueID id, UniversalBody body)
          Signals to this body that the body identified by id is now to a new remote location.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

proxiedRemoteBody

protected RemoteBody proxiedRemoteBody
The encapsulated RmiRemoteBody

Constructor Detail

BodyAdapterImpl

public BodyAdapterImpl()
Method Detail

changeProxiedBody

public void changeProxiedBody(Body newBody)
                       throws java.io.IOException
Change the body referenced by this adapter.

Specified by:
changeProxiedBody in class BodyAdapter
Parameters:
newBody - the body referenced after the call
Throws:
java.io.IOException - if a pb occurs during this method call

lookup

public abstract UniversalBody lookup(java.lang.String url)
                              throws java.io.IOException
Looks-up an active object previously registered in a registry. In fact it is the remote version of the body of an active object that can be registered into the Registry under a given URL.

Specified by:
lookup in class BodyAdapter
Parameters:
url - the url the remote Body is registered to
Returns:
a UniversalBody
Throws:
java.io.IOException - if the remote body cannot be found under the given url or if the object found is not of type RemoteBody

register

public abstract void register(java.lang.String url)
                       throws java.io.IOException
Registers an active object into protocol-specific registry. In fact it is the remote version of the body of the active object that is registered into the Registry under the given URL.

Specified by:
register in class BodyAdapter
Parameters:
url - the url under which the remote body is registered.
Throws:
java.io.IOException - if the remote body cannot be registered

unregister

public abstract void unregister(java.lang.String url)
                         throws java.io.IOException
Unregisters an active object previously registered into a registry.

Specified by:
unregister in class BodyAdapter
Parameters:
url - the url under which the active object is registered.
Throws:
java.io.IOException - if the remote object cannot be removed from the registry

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

construct

protected void construct(RemoteBody remoteBody)
                  throws ProActiveException
Throws:
ProActiveException

getJobID

public java.lang.String getJobID()
Specified by:
getJobID in interface Job
Returns:
the jobID associated with this object
See Also:
Job.getJobID()

receiveRequest

public int 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
Returns:
value for fault-tolerance protocol
Throws:
java.io.IOException - if the request cannot be accepted
RenegotiateSessionException
See Also:
UniversalBody.receiveRequest(org.objectweb.proactive.core.body.request.Request)

receiveReply

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

Specified by:
receiveReply in interface UniversalBody
Parameters:
r - the reply received
Returns:
value for fault-tolerance procotol
Throws:
java.io.IOException - if the reply cannot be accepted
See Also:
UniversalBody.receiveReply(org.objectweb.proactive.core.body.reply.Reply)

getNodeURL

public java.lang.String getNodeURL()
Description copied from interface: UniversalBody
Returns the url of the node this body is associated to The url of the node can change if the active object migrates

Specified by:
getNodeURL in interface UniversalBody
Returns:
the url of the node this body is associated to
See Also:
UniversalBody.getNodeURL()

getID

public UniqueID getID()
Description copied from interface: UniversalBody
Returns the UniqueID of this body This identifier is unique accross all JVMs

Specified by:
getID in interface UniversalBody
Returns:
the UniqueID of this body
See Also:
UniversalBody.getID()

updateLocation

public void updateLocation(UniqueID id,
                           UniversalBody body)
                    throws java.io.IOException
Description copied from interface: UniversalBody
Signals to this body that the body identified by id is now to a new remote location. The body given in parameter is a new stub pointing to this new location. This call is a way for a body to signal to his peer that it has migrated to a new location

Specified by:
updateLocation in interface UniversalBody
Parameters:
id - the id of the body
body - the stub to the new location
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.updateLocation(org.objectweb.proactive.core.UniqueID, org.objectweb.proactive.core.body.UniversalBody)

createShortcut

public void createShortcut(Shortcut shortcut)
                    throws java.io.IOException
Description copied from interface: UniversalBody
similar to the UniversalBody.updateLocation(org.objectweb.proactive.core.UniqueID, UniversalBody) method, it allows direct communication to the target of a functional call, accross membranes of composite components.

Specified by:
createShortcut in interface UniversalBody
Parameters:
shortcut - the shortcut to create
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.createShortcut(org.objectweb.proactive.core.component.request.Shortcut)

getRemoteAdapter

public BodyAdapter getRemoteAdapter()
Description copied from interface: UniversalBody
Returns the remote friendly version of this body

Specified by:
getRemoteAdapter in interface UniversalBody
Returns:
the remote friendly version of this body
See Also:
UniversalBody.getRemoteAdapter()

terminate

public void terminate()
               throws java.io.IOException
Description copied from interface: UniversalBody
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 UniversalBody
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.terminate()

enableAC

public void enableAC()
              throws java.io.IOException
Description copied from interface: UniversalBody
Enables automatic continuation mechanism for this body

Specified by:
enableAC in interface UniversalBody
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.enableAC()

disableAC

public void disableAC()
               throws java.io.IOException
Description copied from interface: UniversalBody
Disables automatic continuation mechanism for this body

Specified by:
disableAC in interface UniversalBody
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.disableAC()

setImmediateService

public void setImmediateService(java.lang.String methodName)
                         throws java.io.IOException
Description copied from interface: UniversalBody
For setting an immediate service for this body. An immediate service is a method that will bw excecuted by the calling thread.

Specified by:
setImmediateService in interface UniversalBody
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.setImmediateService(java.lang.String)

setImmediateService

public void setImmediateService(java.lang.String methodName,
                                java.lang.Class[] parametersTypes)
                         throws java.io.IOException
Description copied from interface: UniversalBody
Adds an immediate service for this body An immediate service is a method that will bw excecuted by the calling thread.

Specified by:
setImmediateService in interface UniversalBody
Parameters:
methodName - the name of the method
parametersTypes - the types of the parameters of the method
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.setImmediateService(java.lang.String, java.lang.Class[])

removeImmediateService

public void removeImmediateService(java.lang.String methodName,
                                   java.lang.Class[] parametersTypes)
                            throws java.io.IOException
Description copied from interface: UniversalBody
Removes an immediate service for this body An immediate service is a method that will bw excecuted by the calling thread.

Specified by:
removeImmediateService in interface UniversalBody
Parameters:
methodName - the name of the method
parametersTypes - the types of the parameters of the method
Throws:
java.io.IOException - if a pb occurs during this method call
See Also:
UniversalBody.removeImmediateService(java.lang.String, java.lang.Class[])

getCertificate

public java.security.cert.X509Certificate getCertificate()
                                                  throws SecurityNotAvailableException,
                                                         java.io.IOException
entity certificate

Specified by:
getCertificate in interface SecurityEntity
Returns:
returns entity certificate
Throws:
SecurityNotAvailableException - if security is not available
java.io.IOException - if communication fails

startNewSession

public long startNewSession(Communication policy)
                     throws SecurityNotAvailableException,
                            RenegotiateSessionException,
                            java.io.IOException
start an unvalidated empty session

Specified by:
startNewSession in interface SecurityEntity
Parameters:
policy - policy associated to the session
Returns:
session ID
Throws:
SecurityNotAvailableException - if security is not available
RenegotiateSessionException - if the session immediatly expires
java.io.IOException

getPublicKey

public java.security.PublicKey getPublicKey()
                                     throws SecurityNotAvailableException,
                                            java.io.IOException
entity public key

Specified by:
getPublicKey in interface SecurityEntity
Returns:
returns entity public key
Throws:
SecurityNotAvailableException
java.io.IOException

randomValue

public byte[] randomValue(long sessionID,
                          byte[] clientRandomValue)
                   throws SecurityNotAvailableException,
                          RenegotiateSessionException,
                          java.io.IOException
Exchange random value between client and server entity

Specified by:
randomValue in interface SecurityEntity
Parameters:
sessionID - the session ID
clientRandomValue - client random value
Returns:
server random value
Throws:
SecurityNotAvailableException - if the security is not available
RenegotiateSessionException - if the session has expired
java.io.IOException

publicKeyExchange

public byte[][] publicKeyExchange(long sessionID,
                                  byte[] myPublicKey,
                                  byte[] myCertificate,
                                  byte[] signature)
                           throws SecurityNotAvailableException,
                                  RenegotiateSessionException,
                                  KeyExchangeException,
                                  java.io.IOException
exchange entity certificate and/or public key if certificate are not available

Specified by:
publicKeyExchange in interface SecurityEntity
Parameters:
sessionID - the session ID
myPublicKey - encoded public key
myCertificate - encoded certificate
signature - encoded signature of previous paramaters
Returns:
an array containing : - server certificate and/or server public key - encoded signature of these parameters
Throws:
SecurityNotAvailableException - if the security is not available
RenegotiateSessionException - if the session has expired
KeyExchangeException - if a key data/length/algorithm is not supported
java.io.IOException

secretKeyExchange

public byte[][] secretKeyExchange(long sessionID,
                                  byte[] encodedAESKey,
                                  byte[] encodedIVParameters,
                                  byte[] encodedClientMacKey,
                                  byte[] encodedLockData,
                                  byte[] parametersSignature)
                           throws SecurityNotAvailableException,
                                  RenegotiateSessionException,
                                  java.io.IOException
this method sends encoded secret parameters to the target entity

Specified by:
secretKeyExchange in interface SecurityEntity
Parameters:
sessionID - session ID
encodedAESKey - the AES key use to exchange secret message
encodedIVParameters - Initilization parameters for the AES key
encodedClientMacKey - MAC key for checking signature of future messages
encodedLockData - random value to prevent message replays by an external attacker
parametersSignature - encoded signature of the previous parameters
Returns:
an array containing : - encoded server AES key - encoded IV parameters - encoded server MAC key - encoded lock data to prevent message replays - encoded signature of previous parameters
Throws:
SecurityNotAvailableException - if this entity does not support security
RenegotiateSessionException - if the session has expired or has been cancelled during this exchange
java.io.IOException - if communication fails

getPolicy

public SecurityContext getPolicy(SecurityContext securityContext)
                          throws SecurityNotAvailableException,
                                 java.io.IOException
Ask the entity to fill the securityContext parameters with its own policy according to the communication details contained in the given securityContext

Specified by:
getPolicy in interface SecurityEntity
Parameters:
securityContext - communication details allowing the entity to look for a matching policy
Returns:
securityContext filled with this entity's policy
Throws:
SecurityNotAvailableException - thrown the entity doest not support the security
java.io.IOException

getCertificateEncoded

public byte[] getCertificateEncoded()
                             throws SecurityNotAvailableException,
                                    java.io.IOException
Entity's X509Certificate as byte array

Specified by:
getCertificateEncoded in interface SecurityEntity
Returns:
entity's X509Certificate as byte array
Throws:
SecurityNotAvailableException
java.io.IOException

getEntities

public java.util.ArrayList getEntities()
                                throws SecurityNotAvailableException,
                                       java.io.IOException
Retrieves all the entity's ID which contain this entity plus this entity ID.

Specified by:
getEntities in interface SecurityEntity
Returns:
returns all the entity's ID which contain this entity plus this entity ID.
Throws:
SecurityNotAvailableException - if the target entity does not support security
java.io.IOException

terminateSession

public void terminateSession(long sessionID)
                      throws SecurityNotAvailableException,
                             java.io.IOException
terminate a given session

Specified by:
terminateSession in interface SecurityEntity
Parameters:
sessionID -
Throws:
SecurityNotAvailableException - id security is not available
java.io.IOException

receiveFTMessage

public java.lang.Object receiveFTMessage(FTMessage ev)
                                  throws java.io.IOException
Description copied from interface: UniversalBody
For sending a non fonctional message to the FTManager linked to this object.

Specified by:
receiveFTMessage in interface UniversalBody
Parameters:
ev - the message to send
Returns:
depends on the message meaning
Throws:
java.io.IOException - if a pb occurs during this method call

addNFEListener

public void addNFEListener(NFEListener listener)
Specified by:
addNFEListener in interface NFEProducer

removeNFEListener

public void removeNFEListener(NFEListener listener)
Specified by:
removeNFEListener in interface NFEProducer

fireNFE

public int fireNFE(NonFunctionalException e)
Specified by:
fireNFE in interface NFEProducer

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException


Copyright 2001-2005 INRIA All Rights Reserved.