org.jlf.log.smtpMechanism
Class SMTPQueueProcessor

java.lang.Object
  |
  +--org.jlf.log.QueueProcessor
        |
        +--org.jlf.log.smtpMechanism.SMTPQueueProcessor
All Implemented Interfaces:
java.lang.Runnable

public class SMTPQueueProcessor
extends QueueProcessor

The SNMPQueueProcessor class is a concrete class designed to offload the processing of emailing log entries.


Field Summary
protected  java.util.Hashtable logEntryQueues
          Holds a hashtable of LogEntryQueue objects with the key to the table being a concatenation of log name.loggingLevel and the value being the log entry queue to hold log entries of that type.
protected  javax.mail.Session session
          Cache the session
protected static SMTPQueueProcessor singleton
          Provides the class variable for the Singleton pattern, to keep track of the one and only instance of this class.
protected  javax.mail.Transport transport
          Cache the transport
protected static java.lang.String TRANSPORT_HOST_DEFAULT
           
protected static java.lang.String TRANSPORT_HOST_PROPERTY
           
protected static java.lang.String TRANSPORT_PASSWORD_DEFAULT
           
protected static java.lang.String TRANSPORT_PASSWORD_PROPERTY
           
protected static java.lang.String TRANSPORT_USER_DEFAULT
           
protected static java.lang.String TRANSPORT_USER_PROPERTY
           
 
Fields inherited from class org.jlf.log.QueueProcessor
NEVER_TIME_OUT_WAIT, processorQueue, processorThread, producerQueue, timeOutInMilliseconds
 
Constructor Summary
protected SMTPQueueProcessor()
          Default constructor, protected to implement the Singleton pattern, calls the superclass.
 
Method Summary
protected  void addLogEntry(LogEntry logEntry)
          Add entry to log entry queue to be later dumped.
static SMTPQueueProcessor getInstance()
          Returns the singleton instance of this class.
protected  LogEntryQueue getLogEntryQueue(LogEntry logEntry)
          Finds (or creates a new) log entry queue for the log entry.
protected  javax.mail.Session getSession()
          Lazy-initialized getter for the transport.
protected  javax.mail.Transport getTransport()
          Lazy-initialized getter for the transport.
protected  void processItem(java.lang.Object queueItem)
          Processes a constructed queue item.
protected  void processQueueItems()
          Iterates through the collection of processorQueue items to process them.
protected  void resetSession()
          Resets the lazy-initialized session object, to be called when the session fails.
protected  void resetTransport()
          Resets the lazy-initialized transport object, to be called when the transport fails.
protected  void sendLogEmail(Log log, int loggingLevel, java.lang.String logString)
          Helper method to send out an email for a particular log, logging level, and log string.
 
Methods inherited from class org.jlf.log.QueueProcessor
enqueue, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

protected static SMTPQueueProcessor singleton
Provides the class variable for the Singleton pattern, to keep track of the one and only instance of this class.


logEntryQueues

protected java.util.Hashtable logEntryQueues
Holds a hashtable of LogEntryQueue objects with the key to the table being a concatenation of log name.loggingLevel and the value being the log entry queue to hold log entries of that type.


TRANSPORT_HOST_PROPERTY

protected static final java.lang.String TRANSPORT_HOST_PROPERTY
See Also:
Constant Field Values

TRANSPORT_HOST_DEFAULT

protected static final java.lang.String TRANSPORT_HOST_DEFAULT
See Also:
Constant Field Values

TRANSPORT_USER_PROPERTY

protected static final java.lang.String TRANSPORT_USER_PROPERTY
See Also:
Constant Field Values

TRANSPORT_USER_DEFAULT

protected static final java.lang.String TRANSPORT_USER_DEFAULT
See Also:
Constant Field Values

TRANSPORT_PASSWORD_PROPERTY

protected static final java.lang.String TRANSPORT_PASSWORD_PROPERTY
See Also:
Constant Field Values

TRANSPORT_PASSWORD_DEFAULT

protected static final java.lang.String TRANSPORT_PASSWORD_DEFAULT
See Also:
Constant Field Values

session

protected javax.mail.Session session
Cache the session


transport

protected javax.mail.Transport transport
Cache the transport

Constructor Detail

SMTPQueueProcessor

protected SMTPQueueProcessor()
Default constructor, protected to implement the Singleton pattern, calls the superclass.

Method Detail

getInstance

public static SMTPQueueProcessor getInstance()
Returns the singleton instance of this class.


getLogEntryQueue

protected LogEntryQueue getLogEntryQueue(LogEntry logEntry)
Finds (or creates a new) log entry queue for the log entry.


addLogEntry

protected void addLogEntry(LogEntry logEntry)
Add entry to log entry queue to be later dumped.


getSession

protected javax.mail.Session getSession()
Lazy-initialized getter for the transport.


resetSession

protected void resetSession()
Resets the lazy-initialized session object, to be called when the session fails.


getTransport

protected javax.mail.Transport getTransport()
Lazy-initialized getter for the transport. TODO: Unfortunately, this currently doesn't work, can't figure out how to get a transport from a session, API doc doesn't tell how to do this. Must use Transport.send for now!


resetTransport

protected void resetTransport()
Resets the lazy-initialized transport object, to be called when the transport fails.


processQueueItems

protected void processQueueItems()
Iterates through the collection of processorQueue items to process them. Calls the superclass first to process any items on the queue, then sends email messages.

Overrides:
processQueueItems in class QueueProcessor

processItem

protected void processItem(java.lang.Object queueItem)
Processes a constructed queue item. This method separates the entry into the correct subqueue, based on log and logging level. The subqueue entries are processed via processQueueItems().

Specified by:
processItem in class QueueProcessor

sendLogEmail

protected void sendLogEmail(Log log,
                            int loggingLevel,
                            java.lang.String logString)
Helper method to send out an email for a particular log, logging level, and log string.