|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.ibm.tspaces.examples.services.TService
TService is an abstract class that provides support for
T Spaces clients that provide some external service to other
T Spaces clients.
An example of how this might be used is as follows:
Assume that we want to have a Service that will wait for a Tuple to
arrive that looks like:
["ExternalMail","user@system.com","any long text string"]
This new Service will subclass TService and in the constructor
it will have something like:
super(TService.SENDMAIL,"ExternalMail",
"This will submit external mail");
// After any required setup, it should then invoke
super.enable();
It will then issue the following T Spaces commands so it can be woken up
when anyone sends it work to do.
Field stringField = Field.makeField("java.lang.String");
Tuple template = new Tuple("ExternalMail",stringField,stringField);
_TS.eventRegister( TupleSpace.WRITE, template, this);
To satisfy the eventRegister, the class must implement Callback and
provide a "call" method that will receive the callback.
The call method can use the provided putQ and getQ methods to
to pass the tuple to the run thread for processing. It should NOT
use the callback method to do long running tasks!!!!!!!!!!!!!
Before or after issing the eventRegister, it may want to "take" any
matching tuples that might have collected while it was not started.
TupleSpace, Serialized Form| Field Summary | |
static java.lang.String |
APPLICATION
|
static java.lang.String |
OTHER
|
static java.lang.String |
PRINT_FILE
|
static java.lang.String |
PRINT_TEXT
|
static java.lang.String |
READMAIL
|
static java.lang.String |
SENDMAIL
Possible values for _ServiceType |
| Constructor Summary | |
TService(java.lang.String type,
java.lang.String name,
java.lang.String description)
TService Constructor |
|
| Method Summary | |
boolean |
enable()
enable() will activate the service. |
boolean |
equals(java.lang.Object other)
Provide a proper equals(Object other) method for TService. |
java.lang.String |
getName()
getName will return the name of the Service. |
java.lang.Object |
getQ()
Method: getQ() will return the first object in the Queue. |
java.lang.String |
printQ()
Give Debug info on Queue |
void |
putQ(java.lang.Object obj)
Method: putQ(Object obj) will place specified object into the FIFO Queue |
java.lang.String |
toString()
Debug helper that displays the current object status |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
public static final java.lang.String SENDMAIL
public static final java.lang.String PRINT_TEXT
public static final java.lang.String PRINT_FILE
public static final java.lang.String READMAIL
public static final java.lang.String APPLICATION
public static final java.lang.String OTHER
| Constructor Detail |
public TService(java.lang.String type,
java.lang.String name,
java.lang.String description)
| Method Detail |
public java.lang.String getName()
public boolean enable()
public boolean equals(java.lang.Object other)
Object - other is the TService object to compare this topublic java.lang.String toString()
public java.lang.Object getQ()
If the queue is empty, it will block until a new object arrives.
public void putQ(java.lang.Object obj)
obj - An Object that is to be added to the queue.public java.lang.String printQ()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||