SK.gnome.dwarf.mail.smtp
Interface MailQueue

All Known Implementing Classes:
FileMailQueue

public interface MailQueue

Provides interface for a mail queue.

This interface models a mail queue which stores mail messages waiting for processing and delivery to local mailboxes or remote hosts.


Method Summary
 SMTPMessage dequeueMessage(Node node)
          Dequeues a message for the given node.
 void enqueueMessage(SMTPMessage message, Node node, long time)
          Enqueues the message for the given node and time.
 SMTPMessage getMessageInstance()
          Returns a new SMTPMessage instance.
 void listMessages(boolean details, java.io.PrintWriter out)
          Lists all messages in the queue.
 java.util.Iterator listNodes()
          Lists all active nodes.
 

Method Detail

getMessageInstance

public SMTPMessage getMessageInstance()
                               throws MailException
Returns a new SMTPMessage instance.

Returns:
the new message instance
Throws:
MailException - if an error occured

listMessages

public void listMessages(boolean details,
                         java.io.PrintWriter out)
                  throws MailException
Lists all messages in the queue.

A short or detailed information is printed out about each message waiting in the queue.

Parameters:
details - true to print message details, false otherwise
out - the output stream
Throws:
MailException - if an error occured

enqueueMessage

public void enqueueMessage(SMTPMessage message,
                           Node node,
                           long time)
                    throws MailException
Enqueues the message for the given node and time.

The message as well as its recipient collection are stored to the mail queue and may be returned later via the dequeueMessage(Node) method, if the recipients are targeted for the given node and other conditions are met, too. In other words, the message is scheduled to be processed for the given node at the specified time.

Parameters:
message - the message
node - the node to enqueue the message for
time - the time for next processing or delivery attempt
Throws:
MailException - if an error occured

dequeueMessage

public SMTPMessage dequeueMessage(Node node)
                           throws MailException
Dequeues a message for the given node.

Only those messages may be returned which had been enqueued for the given node and time less or equal the current system time, unless the node's Node.getForceDelivery() returns true. Furthemore, messages which had been already processed for the same Node object previously must not be returned. A returned message's SMTPMessage.getRecipients() method may return only those recipients which are targeted for the given node. After dequeueing the recipients are removed from the queue processing and may be included in it again only by calling enqueueMessage(SMTPMessage, Node, long) on the same message object.

Parameters:
node - the node to dequeue a message for
Returns:
the message or null if no message waits for the processing
Throws:
MailException - if an error occured

listNodes

public java.util.Iterator listNodes()
Lists all active nodes.

A node is active only if it contains any messages for processing. The returned iteration contains java.lang.String objects with the node names.

Returns:
the iteration of active nodes


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.