com.ibm.tspaces.examples.services
Class SendMail

java.lang.Object
  |
  +--com.ibm.tspaces.examples.services.TService
        |
        +--com.ibm.tspaces.examples.services.SendMail

public class SendMail
extends TService
implements Callback, java.lang.Runnable

SendMail accepts "SendMail" requests from TupleSpace and sends the specified message to the specified userid The SendMail service is started by issuing the java invocation and specifying the SMTP Host system as a parameter java com.ibm.tspaces.examples.services.SendMail mail.sys.com A client that wants to use the services needs to only do the following

 
      TupleSpace servers = new TupleSpace("Services",servicehost);	    
	     
	    servers.write("SendMail","jthomas@cruzio.com","Hello John");
        -or-
      servers.write("SendMail",String[] headers,"Hello John");
        where headers is an array of strings formated as RFC822 
        mail headers 
          {"To: a.big.com","Subject: about this"}
  

Author:
John Thomas
See Also:
TupleSpace, Serialized Form

Fields inherited from class com.ibm.tspaces.examples.services.TService
APPLICATION, OTHER, PRINT_FILE, PRINT_TEXT, READMAIL, SENDMAIL
 
Constructor Summary
SendMail(java.lang.String name, java.lang.String host, java.lang.String description)
          SendMail Constructor
 
Method Summary
 boolean call(java.lang.String eventName, java.lang.String tsName, int seqNum, SuperTuple tuple, boolean isException)
          Implementation for the Callback interface.
 void init()
          This will handle the initial processing It will do any backlog of requests by looking for unprocessed tuples It will set up RegisterEvent to process all future events
static void main(java.lang.String[] argv)
          Startup the SendMail Process
 void run()
          The run() method will wait for mail Tuple to be queue The Tuple has the format: [ String name, String to-email-addr, String message ] or [ String name, String[] mail-headers, String message ]
 void send(java.lang.String[] headers, java.lang.String msg)
          The send(String[] headers,msg) method will send the msg using the specified headers
 void send(java.lang.String toaddr, java.lang.String msg)
          The send(toaddr,msg) method will send the msg to toaddr
 
Methods inherited from class com.ibm.tspaces.examples.services.TService
enable, equals, getName, getQ, printQ, putQ, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SendMail

public SendMail(java.lang.String name,
                java.lang.String host,
                java.lang.String description)
SendMail Constructor
Method Detail

init

public void init()
This will handle the initial processing It will do any backlog of requests by looking for unprocessed tuples It will set up RegisterEvent to process all future events

call

public boolean call(java.lang.String eventName,
                    java.lang.String tsName,
                    int seqNum,
                    SuperTuple tuple,
                    boolean isException)
Implementation for the Callback interface. call an application back with a tuple it requested. In the case of an exceptional condition occurring on the server, isException will be true and the exception will be inside the tuple_, i.e., the tuple will contain one field that is a TupleSpaceServerException. This method is called by the callback thread and thus should do something really quick and return, that is it should not take up lots of time. Typically, it might just queue up the tuple and isException and wake up some other thread that will do the real processing, at least that is the intention.
Specified by:
call in interface Callback
Parameters:
eventName_ - the name of the event command that caused this call, that is the name of the client side command of the thread that registered this call, e.g., in the case of a read, this would be TupleSpace.READ, **not** TupleSpace.WRITE which is the corresponding command that caused the actaul event.
tsName_ - the name of the tuple space this command was executed on.
sequenceNumber_ - the sequenceNumber for this event/command
tuple_ - the returned tuple or a Tuple with an exception inside
isException_ - was the command processed normaly or was there an exception
Returns:
true if this is the last call this sequence # should be getting otherwise false

run

public void run()
The run() method will wait for mail Tuple to be queue The Tuple has the format: [ String name, String to-email-addr, String message ] or [ String name, String[] mail-headers, String message ]
Specified by:
run in interface java.lang.Runnable

send

public void send(java.lang.String toaddr,
                 java.lang.String msg)
The send(toaddr,msg) method will send the msg to toaddr

send

public void send(java.lang.String[] headers,
                 java.lang.String msg)
The send(String[] headers,msg) method will send the msg using the specified headers

main

public static void main(java.lang.String[] argv)
Startup the SendMail Process