|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ostore.apps.test.TapestryHowto
A simple example of how to write your own DD client and message types. The example is as follows. We bring up two machines, a sender and a receiver. The sender sends a Ping message to the receiver, which the receiver acknoledges with a Pong. This happens a number of times, and then the test exits. It's simple, but it covers most of the things you need to know to do more complicated things. Please just read the source, it's well commented.
First off, this class is going to be a SEDA/Sandstorm stage, so it
has to inherit from EventHandlerIF
.
Nested Class Summary | |
---|---|
static class |
TapestryHowto.Ping
One of two DD messages used in this test. |
static class |
TapestryHowto.Pong
This class is identical in all by type from the Ping class above, so I'm not going to comment it further. |
Constructor Summary | |
---|---|
TapestryHowto()
|
Method Summary | |
---|---|
void |
destroy()
Sandstorm calls this function when it unloads your stage, which to my knowledge, it never does. |
void |
handleEvent(QueueElementIF item)
This is the function that will be called when a stage dispatches a message that we've subscribed to. |
void |
handleEvents(QueueElementIF[] items)
If Sandstorm has more than one event waiting for this stage, it will call this function instead of handleEvent. |
void |
init(ConfigDataIF config)
Initializes the stage once Sandstorm is up and running. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TapestryHowto()
Method Detail |
public void init(ConfigDataIF config) throws Exception
You'll notice that most stages won't have constructors. The reason is that all initialization can take place here, where you have the information from your stage's config file to help you. I'll detail the important things you want to do in this function below.
init
in interface EventHandlerIF
Exception
public void handleEvent(QueueElementIF item) throws EventHandlerException
handleEvent
in interface EventHandlerIF
EventHandlerException
public void handleEvents(QueueElementIF[] items) throws EventHandlerException
handleEvents
in interface EventHandlerIF
EventHandlerException
public void destroy() throws Exception
destroy
in interface EventHandlerIF
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |