pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.email
Class MailQueue

java.lang.Object
  extended by org.torweg.pulse.email.MailQueue
All Implemented Interfaces:
LifecycleResource

public final class MailQueue
extends java.lang.Object
implements LifecycleResource

is the MailQueue singleton of the pulse container.

The MailQueue is used to send mails from the pulse container. Mails will be delivered in specified intervals to an MTA. The configuration can be found in pulse.xml.

 ...
 <mail-queue interval="10000">
   <protocol>smtp</protocol>
   <server port="25">localhost</server>
   <user>mail-user</user>
   <password>pass</password>
   <temporary-directory>/tmp</temporary-directory>
 </mail-queue>
 ...
 

All values are optional and default to:

interval <em>10000</em>
protocol <em>smtp</em>
server <em>localhost</em>
port <em>25</em>
user no user, do not use authentication
password no password
temporary-directory <em>java.io.tmpdir</em>

Mails that are still in the queue during shutdowns are stored in the given temporary directory and reloaded on startup.

Version:
$Revision: 1697 $
Author:
Thomas Weber

Field Summary
static java.lang.String STORE_FILE_NAME
          the name of the file for storing unprocessed queue items.
 
Method Summary
 void add(Email email)
          adds an Email to the queue.
 void add(javax.mail.internet.MimeMessage mm)
          adds an MimeMessage to the queue.
protected  void finalize()
          tries to save the queue, if the MailQueue has not been stopped already.
protected  MailQueueConfiguration getConfiguration()
          returns the configuration for the SendingTask.
protected  java.util.concurrent.ConcurrentLinkedQueue<QueueItem> getCurrentQueue()
          getter used by the send task.
static MailQueue getInstance(MailQueueConfiguration conf)
          the MailQueue singleton.
 boolean isModified()
          always returns false.
protected  boolean isStopped()
          returns whether the MailQueue is stopped.
 void reconfigure(MailQueueConfiguration conf)
          reconfigures the MailQueue at runtime (used by Lifecycle$WatchDog).
 void restart()
          Deprecated. 
protected  void sendMessage(javax.mail.internet.MimeMessage message, javax.mail.Transport transport)
          used by the SendingTask to actually send a message.
 void shutdown()
          stops the MailQueue.
 void startup()
          starts the MailQueue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORE_FILE_NAME

public static final java.lang.String STORE_FILE_NAME
the name of the file for storing unprocessed queue items.

See Also:
Constant Field Values
Method Detail

getInstance

public static MailQueue getInstance(MailQueueConfiguration conf)
the MailQueue singleton.

Parameters:
conf - the configuration
Returns:
the MailQueue singleton

add

public void add(Email email)
adds an Email to the queue.

Parameters:
email - the e-mail to add

add

public void add(javax.mail.internet.MimeMessage mm)
adds an MimeMessage to the queue.

Parameters:
mm - the MIME message to add

getCurrentQueue

protected java.util.concurrent.ConcurrentLinkedQueue<QueueItem> getCurrentQueue()
getter used by the send task.

Returns:
the queue itself

getConfiguration

protected MailQueueConfiguration getConfiguration()
returns the configuration for the SendingTask.

Returns:
the configuration for the SendingTask.

isStopped

protected boolean isStopped()
returns whether the MailQueue is stopped.

Returns:
true, if the MailQueue is stopped

sendMessage

protected void sendMessage(javax.mail.internet.MimeMessage message,
                           javax.mail.Transport transport)
                    throws javax.mail.MessagingException
used by the SendingTask to actually send a message.

Parameters:
message - the message
transport - the transport
Throws:
javax.mail.MessagingException - on errors sending the message

isModified

public boolean isModified()
always returns false.

Specified by:
isModified in interface LifecycleResource
Returns:
false

restart

@Deprecated
public void restart()
             throws LifecycleException
Deprecated. 

This method is not supported.

Calls to this method will always cause a LifecycleException.

Specified by:
restart in interface LifecycleResource
Throws:
LifecycleException - always, since the method is not supported

shutdown

public void shutdown()
stops the MailQueue.

Specified by:
shutdown in interface LifecycleResource

startup

public void startup()
starts the MailQueue.

Specified by:
startup in interface LifecycleResource

reconfigure

public void reconfigure(MailQueueConfiguration conf)
reconfigures the MailQueue at runtime (used by Lifecycle$WatchDog).

Parameters:
conf - the new configuration

finalize

protected void finalize()
                 throws java.lang.Throwable
tries to save the queue, if the MailQueue has not been stopped already.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - on errors
See Also:
Object.finalize()