sds
Class DistributedObject

java.lang.Object
  extended by sds.DistributedObject
Direct Known Subclasses:
DistributedClientObject, DistributedServerObject

public abstract class DistributedObject
extends java.lang.Object

Defines generic distributed objects manipulated by SDS

Author:
ncottin

Constructor Summary
DistributedObject()
           Creates a non-initialized distributed object along with no associated manager and a default produced reference
 
Method Summary
static Reference createReference()
           
 java.util.Collection<Reference> deliver(Message msg, boolean block, java.util.Collection<Reference> recipients)
           Message delivery to recipients
 java.util.Collection<Reference> deliver(Message msg, boolean block, Reference... recipients)
           Message delivery to recipients
 sds.ResponseInfo getExpectedResponseInfo(java.lang.Long id)
           
 Reference getManager()
           Gets the reference of the manager which sent this distributed object to the local daemon
 Reference getReference()
           Gets the reference of this distributed object
 void run(int port)
           Executes this distributed object as a normal server (not a daemon).
abstract  void run(int port, boolean daemon)
           Executes this distributed object as a server.
abstract  boolean runsAsServer()
           Indicated whether this distributed object is a server (or an intermediary) or a client
 void setDefaultReference()
           
 void setManager(Reference manager)
           To be used by a daemon to set the manager associated with this distributed object
 void setReference(Reference reference)
           
abstract  void terminate()
           Called by the hosting daemon when asked (by a manager) to kill its running distributed objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedObject

public DistributedObject()

Creates a non-initialized distributed object along with no associated manager and a default produced reference

Method Detail

getExpectedResponseInfo

public final sds.ResponseInfo getExpectedResponseInfo(java.lang.Long id)

setManager

public final void setManager(Reference manager)

To be used by a daemon to set the manager associated with this distributed object

Parameters:
manager - the manager which called the local daemon to activate this distributed object. Setting null indicates that ths distributed object is not associated with any manager

getManager

public final Reference getManager()

Gets the reference of the manager which sent this distributed object to the local daemon

Returns:
the manager's reference or null if this object is not associated with a manager

setDefaultReference

public final void setDefaultReference()

createReference

public static final Reference createReference()

setReference

public final void setReference(Reference reference)

getReference

public final Reference getReference()

Gets the reference of this distributed object

Returns:
this distributed object's fully initialized reference

runsAsServer

public abstract boolean runsAsServer()

Indicated whether this distributed object is a server (or an intermediary) or a client

Returns:
true only if this distributed object is able to listen to incoming requests (i.e. this distributed object is server-oriented)

run

public abstract void run(int port,
                         boolean daemon)
                  throws SdsException

Executes this distributed object as a server. This operation must be non-blocking. A default reference is created if not initialized before (getReference() returns null)

Parameters:
port - the port to be used by this distributed object when running as a server
daemon - tells this server to run as a daemon or a normal server
Throws:
SdsException - raised if the port is already reserved or when this distributed object has no server ability

run

public final void run(int port)
               throws SdsException

Executes this distributed object as a normal server (not a daemon). This operation must be non-blocking. A default reference is created if not initialized before (getReference() returns null)

Parameters:
port - the port to be used by this distributed object when running as a server
Throws:
SdsException - raised if the port is already reserved or when this distributed object has no server ability
See Also:
run(int, boolean)

deliver

public final java.util.Collection<Reference> deliver(Message msg,
                                                     boolean block,
                                                     Reference... recipients)

Message delivery to recipients

Parameters:
msg - the message to deliver
block - true if this delivery operation waits for all messages to be sent and corresponding responses to be received
recipients - The list of recipients to receive the message
Returns:
the collection of non-delivered recipients. Always empty in case of non-blocking deliveries. Null when the message is null or when no recipient is specified (the provided list of recipients is either null or empty)

deliver

public final java.util.Collection<Reference> deliver(Message msg,
                                                     boolean block,
                                                     java.util.Collection<Reference> recipients)

Message delivery to recipients

Parameters:
msg - the message to deliver
block - true if this delivery operation waits for all messages to be sent and corresponding
recipients - the collection of recipients to receive the message
Returns:
the collection of non-delivered recipients. Always empty in case of non-blocking deliveries. Null when the message is null or the provided collection is null

terminate

public abstract void terminate()

Called by the hosting daemon when asked (by a manager) to kill its running distributed objects. Allows to perform tasks before an effective closing (along with this distributed object's unregistration from its local daemon)