|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.mailet.GenericMailet
public abstract class GenericMailet
GenericMailet makes writing mailets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the MailetConfig interface. GenericMailet also implements the log method, declared in the MailetContext interface.
To write a generic mailet, you need only override the abstract service method.
Constructor Summary | |
---|---|
GenericMailet()
|
Method Summary | |
---|---|
void |
destroy()
Called by the mailer container to indicate to a mailet that the mailet is being taken out of service. |
java.lang.String |
getInitParameter(java.lang.String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist. |
java.lang.String |
getInitParameter(java.lang.String name,
java.lang.String defValue)
Returns a String containing the value of the named initialization parameter, or defValue if the parameter does not exist. |
java.util.Iterator |
getInitParameterNames()
Returns the names of the mailet's initialization parameters as an Iterator of String objects, or an empty Iterator if the mailet has no initialization parameters. |
MailetConfig |
getMailetConfig()
Returns this Mailet's MailetConfig object. |
MailetContext |
getMailetContext()
Returns a reference to the MailetContext in which this mailet is running. |
java.lang.String |
getMailetInfo()
Returns information about the mailet, such as author, version, and copyright. |
java.lang.String |
getMailetName()
Returns the name of this mailet instance. |
void |
init()
A convenience method which can be overridden so that there's no need to call super.init(config). |
void |
init(MailetConfig newConfig)
Called by the mailet container to indicate to a mailet that the mailet is being placed into service. |
void |
log(java.lang.String message)
Writes the specified message to a mailet log file, prepended by the mailet's name. |
void |
log(java.lang.String message,
java.lang.Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception to the mailet log file, prepended by the mailet's name. |
abstract void |
service(Mail mail)
Called by the mailet container to allow the mailet to process a message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericMailet()
Method Detail |
---|
public void destroy()
destroy
in interface Mailet
public java.lang.String getInitParameter(java.lang.String name)
This method is supplied for convenience. It gets the value of the named parameter from the mailet's MailetConfig object.
getInitParameter
in interface MailetConfig
name
- - a String specifying the name of the initialization parameter
public java.lang.String getInitParameter(java.lang.String name, java.lang.String defValue)
This method is supplied for convenience. It gets the value of the named parameter from the mailet's MailetConfig object.
name
- - a String specifying the name of the initialization parameterdefValue
- - a String specifying the default value when the parameter
is not present
public java.util.Iterator getInitParameterNames()
This method is supplied for convenience. It gets the parameter names from the mailet's MailetConfig object.
getInitParameterNames
in interface MailetConfig
public MailetConfig getMailetConfig()
getMailetConfig
in interface Mailet
public MailetContext getMailetContext()
getMailetContext
in interface MailetConfig
public java.lang.String getMailetInfo()
getMailetInfo
in interface Mailet
public java.lang.String getMailetName()
getMailetName
in interface MailetConfig
public void init(MailetConfig newConfig) throws javax.mail.MessagingException
Called by the mailet container to indicate to a mailet that the mailet is being placed into service.
This implementation stores the MailetConfig object it receives from the mailet container for later use. When overriding this form of the method, call super.init(config).
init
in interface Mailet
MailetConfig
- newconfig - the MailetConfig object that contains
configutation information for this mailet
javax.mail.MessagingException
- if an exception occurs that interrupts the mailet's normal operationpublic void init() throws javax.mail.MessagingException
A convenience method which can be overridden so that there's no need to call super.init(config).
Instead of overriding init(MailetConfig), simply override this method and it will be called by GenericMailet.init(MailetConfig config). The MailetConfig object can still be retrieved via getMailetConfig().
javax.mail.MessagingException
- if an exception occurs that interrupts the mailet's normal operationpublic void log(java.lang.String message)
message
- - a String specifying the message to be written to the log filepublic void log(java.lang.String message, java.lang.Throwable t)
message
- - a String that describes the error or exceptiont
- - the java.lang.Throwable to be loggedpublic abstract void service(Mail mail) throws javax.mail.MessagingException
Called by the mailet container to allow the mailet to process a message.
This method is declared abstract so subclasses must override it.
service
in interface Mailet
mail
- - the Mail object that contains the MimeMessage and
routing information
javax.mail.MessagingException
- - if an exception occurs that interferes with the mailet's normal operation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |