org.apache.mailet
Interface Mailet

All Known Subinterfaces:
ICommandListservManager
All Known Implementing Classes:
AbstractAddFooter, AbstractNotify, AbstractRedirect, AbstractVirtualUserTable, AddFooter, AddHabeasWarrantMark, AddHeader, AvalonListserv, AvalonListservManager, BayesianAnalysis, BayesianAnalysisFeeder, Bounce, ClamAVScan, CommandListservFooter, CommandListservManager, CommandListservProcessor, Counter, DSNBounce, DumpSystemErr, ExceptionThrowingMailet, Forward, FromRepository, GenericListserv, GenericListservManager, GenericMailet, Identity, JDBCAlias, JDBCListserv, JDBCVirtualUserTable, LocalDelivery, LogMessage, NotifyPostmaster, NotifySender, Null, PostmasterAlias, Redirect, RemoteDelivery, RemoveAllMailAttributes, RemoveMailAttribute, Resend, ServerTime, SetMailAttribute, SetMimeHeader, SMIMEAbstractSign, SMIMECheckSignature, SMIMEDecrypt, SMIMESign, ToMultiRepository, ToProcessor, ToRepository, UseHeaderRecipients, UsersRepositoryAliasingForwarding, WhiteListManager, XMLVirtualUserTable

public interface Mailet

Draft of a Mailet inteface. The service perform all needed work on the Mail object. Whatever remains at the end of the service is considered to need futher processing and will go to the next Mailet if there is one configured or will go to the error processor if not. Setting a Mail state (setState(String)) to Mail.GHOST or cleaning its recipient list has the same meaning that s no more processing is needed. Instead of creating new messages, the mailet can put a message with new recipients at the top of the mail queue, or insert them immediately after it's execution through the API are provided by the MailetContext interface.

This interface defines methods to initialize a mailet, to service messages, and to remove a mailet from the server. These are known as life-cycle methods and are called in the following sequence:

  1. The mailet is constructed, then initialized with the init method.
  2. Any messages for the service method are handled.
  3. The mailet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized.
In addition to the life-cycle methods, this interface provides the getMailetConfig method, which the mailet can use to get any startup information, and the getMailetInfo method, which allows the mailet to return basic information about itself, such as author, version, and copyright.

Version:
1.0.0, 24/04/1999

Method Summary
 void destroy()
          Called by the mailet container to indicate to a mailet that the mailet is being taken out of service.
 MailetConfig getMailetConfig()
          Returns a MailetConfig object, which contains initialization and startup parameters for this mailet.
 java.lang.String getMailetInfo()
          Returns information about the mailet, such as author, version, and copyright.
 void init(MailetConfig config)
          Called by the mailet container to indicate to a mailet that the mailet is being placed into service.
 void service(Mail mail)
          Called by the mailet container to allow the mailet to process to a message.
 

Method Detail

destroy

void destroy()
Called by the mailet container to indicate to a mailet that the mailet is being taken out of service. This method is only called once all threads within the mailet's service method have exited or after a timeout period has passed. After the mailet container calls this method, it will not call the service method again on this mailet.

This method gives the mailet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the mailet's current state in memory.


getMailetInfo

java.lang.String getMailetInfo()
Returns information about the mailet, such as author, version, and copyright.

The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.).

Returns:
a String containing servlet information

getMailetConfig

MailetConfig getMailetConfig()
Returns a MailetConfig object, which contains initialization and startup parameters for this mailet.

Implementations of this interface are responsible for storing the MailetConfig object so that this method can return it. The GenericMailet class, which implements this interface, already does this.

Returns:
the MailetConfig object that initializes this mailet

init

void init(MailetConfig config)
          throws javax.mail.MessagingException
Called by the mailet container to indicate to a mailet that the mailet is being placed into service.

The mailet container calls the init method exactly once after instantiating the mailet. The init method must complete successfully before the mailet can receive any requests.

Parameters:
config - - a MailetConfig object containing the mailet's configuration and initialization parameters
Throws:
javax.mail.MessagingException - - if an exception has occurred that interferes with the mailet's normal operation

service

void service(Mail mail)
             throws javax.mail.MessagingException
Called by the mailet container to allow the mailet to process to a message.

This method is only called after the mailet's init() method has completed successfully.

Mailets typically run inside multithreaded mailet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, as well as the mailet's class and instance variables. More information on multithreaded programming in Java is available in the Java tutorial on multi-threaded programming.

Parameters:
mail - - the Mail object that contains the message and routing information
Throws:
javax.mail.MessagingException - - if a message or address parsing exception occurs or an exception that interferes with the mailet's normal operation


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.