Class TService

Direct Known Subclasses:
Pager, PrintText, SendMail, TstServer

public abstract class TService
extends java.lang.Object
implements, Callback

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","","any long text string"] This new Service will subclass TService and in the constructor it will have something like:

                  "This will submit external mail");
      // After any required setup, it should then invoke

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.

John Thomas
See Also:
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
Possible values for _ServiceType


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)
TService Constructor
Method Detail


public java.lang.String getName()
getName will return the name of the Service.


public boolean enable()
enable() will activate the service. It will write a registration Tuple to the TupleSpace giving the name and description of the service.


public boolean equals(java.lang.Object other)
Provide a proper equals(Object other) method for TService. This will return true if all of the following conditions are true:
- (Object other) is an instance of TService
- The ServiceNames match i.e. this.getName.equals(other.getName()
equals in class java.lang.Object
Object - other is the TService object to compare this to


public java.lang.String toString()
Debug helper that displays the current object status
toString in class java.lang.Object


public java.lang.Object getQ()
Method: getQ() will return the first object in the Queue.

If the queue is empty, it will block until a new object arrives.

Object It will return the next Object in the Queue.


public void putQ(java.lang.Object obj)
Method: putQ(Object obj) will place specified object into the FIFO Queue
obj - An Object that is to be added to the queue.


public java.lang.String printQ()
Give Debug info on Queue