jegg
Class EggBase

java.lang.Object
  extended byjegg.EggBase
All Implemented Interfaces:
Egg
Direct Known Subclasses:
PortRegistry

public abstract class EggBase
extends java.lang.Object
implements Egg

A convenience base class for a concrete egg implementation. Rather than directly implement the jegg.Egg interface, an application egg can extend this base class.

This class handles the context configuration from the JEgg framework and makes the context available to the derived class via a getter method, and provides a default implementation of the init method that the framework calls to complete the initialization of the egg, prior to delivering the first application message to the egg.

For each message type that the derived class can handle, it should include a method of the following form:

      public void handle([message-type]);
 
where [message-type] is the concrete class name of the message type that method can handle. All handler methods should follow this naming convention - it's expected by the message dispatcher.


Constructor Summary
EggBase()
           
 
Method Summary
protected  EggContext getContext()
          Return this egg's current context.
protected  Port getPort()
          Return this egg's message port.
 void init()
          A default implementation, that does nothing, of the initialization method used by the framework to complete the initialization of the derived class egg.
 void setContext(EggContext c)
          Set the application context for this egg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jegg.Egg
handle
 

Constructor Detail

EggBase

public EggBase()
Method Detail

setContext

public final void setContext(EggContext c)
Description copied from interface: Egg
Set the application context for this egg. This method will be used by the JEgg framework to configure this egg with its application context. The application context provides the egg with access the JEgg framework for use in sending messages, retrieving the message port of the currently handled message, retrieving configuration properties, etc.

Specified by:
setContext in interface Egg
Parameters:
c - this eggs application context.

init

public void init()
          throws UnableToInitializeException
A default implementation, that does nothing, of the initialization method used by the framework to complete the initialization of the derived class egg.

Specified by:
init in interface Egg
Throws:
UnableToInitializeException - if this egg cannot complete its initialization.

getContext

protected final EggContext getContext()
Return this egg's current context.


getPort

protected Port getPort()
Return this egg's message port.

Returns:
this egg's message port.


Copyright © 2004 . All Rights Reserved.