sds.service
Class Daemon

java.lang.Object
  extended by sds.DistributedObject
      extended by sds.DistributedServerObject
          extended by sds.service.Daemon

public final class Daemon
extends DistributedServerObject

Server-oriented distributed object to be started on each distant host which participates to the distributed system. It receives distributed objects sent by a Manager and manages their life cycle (from load and activation to destruction)

Author:
ncottin
See Also:
DistributedObject

Field Summary
static long DEFAULT_FIRST_ID
          Default identifier (= 0) for loaded distributed objects
static int NO_MAX_PORT
          Indicates that this daemon can load and run server-oriented distributed objects without taking care of available ports numbers
 
Constructor Summary
Daemon(boolean requiresSignature, int minPort, int maxPort, long firstId)
           
 
Method Summary
 void execute()
           Defines this server's default behaviour (i.e. while not receiving messages from other distributed objects)
 int getMaxPort()
           
 int getMinPort()
           
 boolean hasMaxPort()
           
 void processError(SdsException e)
           Automatically called when DistributedServerObject.receive(Message) returns false or when an SdsException while processing an incoming request
 boolean receive(Message msg)
           Defines the server behavior when a message is received
 void terminateServer()
           Automatically called by DistributedServerObject.terminate()
 
Methods inherited from class sds.DistributedServerObject
isSignatureRequired, run, runsAsServer, terminate
 
Methods inherited from class sds.DistributedObject
createReference, deliver, deliver, getExpectedResponseInfo, getManager, getReference, run, setDefaultReference, setManager, setReference
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FIRST_ID

public static final long DEFAULT_FIRST_ID
Default identifier (= 0) for loaded distributed objects

See Also:
Constant Field Values

NO_MAX_PORT

public static final int NO_MAX_PORT
Indicates that this daemon can load and run server-oriented distributed objects without taking care of available ports numbers

See Also:
Constant Field Values
Constructor Detail

Daemon

public Daemon(boolean requiresSignature,
              int minPort,
              int maxPort,
              long firstId)
Method Detail

getMinPort

public int getMinPort()

getMaxPort

public int getMaxPort()

hasMaxPort

public boolean hasMaxPort()

execute

public void execute()
Description copied from class: DistributedServerObject

Defines this server's default behaviour (i.e. while not receiving messages from other distributed objects)

Specified by:
execute in class DistributedServerObject

processError

public void processError(SdsException e)
Description copied from class: DistributedServerObject

Automatically called when DistributedServerObject.receive(Message) returns false or when an SdsException while processing an incoming request

Specified by:
processError in class DistributedServerObject

receive

public boolean receive(Message msg)
                throws SdsException
Description copied from class: DistributedServerObject

Defines the server behavior when a message is received

Specified by:
receive in class DistributedServerObject
Parameters:
msg - received message. Must not be null (no checking is necessary when implementing this operation)
Returns:
true if request message content is successfully handled
Throws:
SdsException - an error occurred when retrieving information from the message (or cast)

terminateServer

public void terminateServer()
Description copied from class: DistributedServerObject

Automatically called by DistributedServerObject.terminate()

Specified by:
terminateServer in class DistributedServerObject