|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jegg.impl.EggShell
Base class for implementing an egg. Concrete classes that extend this class will be plugged into the JEgg framework and be able to send and receive arbitrary messages. The Egg base class also provides convenience methods for the following:
respond
)publishPort
)requestPort
)send
)
bindToPort
)createTimer
)#createMessage(Object)
)
The default constructor will assign this egg to the default thread. Use the
constructor that takes a Dispatcher
in order to
assign the egg to a specific thread.
The derived class should implement handlers for the message types that it expects
to receive. A message handler is implemented by overloading the handle
method with a version that accepts the expected message type. When the derived
class is loaded, the handle
methods are reflected and cached in
a lookup table to improve the message delivery performance.
The message dispatcher assigned to the egg will only deliver one message at a time to the Egg subclass. If an egg is expected to take a long time to process some messages, then it should be assigned its own dispatcher (see above).
Messages are dispatched to an egg according to their priority, in the order they were sent. So, a more recent message with a high priority can be delivered to the egg before a message that was sent earlier but with a lower priority.
Constructor Summary | |
EggShell(java.lang.Object id,
Egg h)
Construct an egg that dispatches messages to a user-supplied message handler using a specific message dispatcher. |
|
EggShell(java.lang.Object id,
Egg h,
Dispatcher d)
|
Method Summary | |
void |
assignTo(Dispatcher d)
|
java.lang.Class[] |
getInterface()
Return the message types that this egg will handle. |
Port |
getPort()
Return the port used to deliver messages to this egg. |
protected void |
send(java.lang.Object msg)
Broadcast a message to all eggs that have bound to this egg's port (see bindToPort ). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EggShell(java.lang.Object id, Egg h)
id
- a unique object that can be used to identify this egg. The
name should be unique among the eggs instantiated in the JVM.h
- a user-supplied message handler.
java.lang.IllegalArgumentException
- if any argument is null.public EggShell(java.lang.Object id, Egg h, Dispatcher d)
Method Detail |
public void assignTo(Dispatcher d)
public final java.lang.Class[] getInterface()
public final Port getPort()
protected final void send(java.lang.Object msg)
bindToPort
).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |