com.cometway.net
Class Emailer

java.lang.Object
  extended by java.lang.Thread
      extended by com.cometway.net.Emailer
All Implemented Interfaces:
java.lang.Runnable

public class Emailer
extends java.lang.Thread

This subclass of Thread sends Email using the ESMTPSender class. This Thread will sleep until the send(IMessage) method is called, which causes the Thread to wake up. Upon wakeup, the Thread checks the queue for IMessages to send and sends them. Messages that return an error when attempting to deliver the message will be dropped from the queue. If the SMTP host which this Thread uses to relay the message is down, all the messages are added back into the Queue. The mesage queue has a max size of 500 messages.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Emailer(java.lang.String smtphost, int waitTime)
          Setup with default SMTP server, instantiates a new messages Vector and starts thread.
 
Method Summary
static void main(java.lang.String[] args)
           
 void print(java.lang.String s)
          Print method.
 void run()
          infinite loop, every 5 seconds it checks vector for IMessages.
 void send(IMessage m)
          Puts IMessage into the Vector of messages to be sent.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Emailer

public Emailer(java.lang.String smtphost,
               int waitTime)
Setup with default SMTP server, instantiates a new messages Vector and starts thread. The Emailer uses SocketManager Sockets.

Parameters:
smtphost - This is the SMTP server all email will be sent from.
waitTime - This is the time in seconds that the Emailer will sleep between connections to the mail server
Method Detail

send

public void send(IMessage m)
Puts IMessage into the Vector of messages to be sent.

Parameters:
m - the IMessages to be sent. Assumed IMessage includes from, to and subject fields.

run

public void run()
infinite loop, every 5 seconds it checks vector for IMessages. If found, sends them

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

print

public void print(java.lang.String s)
Print method.


main

public static void main(java.lang.String[] args)