org.elkoserver.server.workshop
Class WorkerObject

java.lang.Object
  extended by org.elkoserver.server.workshop.WorkerObject
All Implemented Interfaces:
DispatchTarget, Encodable, Referenceable
Direct Known Subclasses:
BankWorker

public abstract class WorkerObject
extends Object
implements DispatchTarget, Encodable, Referenceable

Base class for all worker objects.


Constructor Summary
WorkerObject(String serviceName)
          Constructor.
 
Method Summary
 void activate()
          Overridable hook for subclasses to be notified about activation.
 JSONLiteral encode(EncodeControl control)
          Produce a JSONLiteral representing the encoded state of this object, suitable for transmission over a messaging medium or for writing to persistent storage.
 String ref()
          Obtain this object's reference string.
protected  Workshop workshop()
          Obtain the workshop for this server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkerObject

public WorkerObject(String serviceName)
Constructor.

Parameters:
serviceName - Service name to register with broker, or null for none.
Method Detail

activate

public void activate()
Overridable hook for subclasses to be notified about activation.


workshop

protected Workshop workshop()
Obtain the workshop for this server.

Returns:
the Workshop object for this server.

encode

public JSONLiteral encode(EncodeControl control)
Produce a JSONLiteral representing the encoded state of this object, suitable for transmission over a messaging medium or for writing to persistent storage. The default implementation makes this object not actually encodable, but subclasses can override.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSONLiteral representing the encoded state of this object.

ref

public String ref()
Obtain this object's reference string.

Specified by:
ref in interface Referenceable
Returns:
a string that can be used to refer to this object in JSON messages, either as the message target or as a parameter value.