View Javadoc
1 /* 2 * Copyright (C) The Apache Software Foundation. All rights reserved. 3 * 4 * This software is published under the terms of the Apache Software License 5 * version 1.1, a copy of which has been included with this distribution in 6 * the LICENSE file. 7 */ 8 package org.apache.mailet; 9 10 /*** 11 * Draft of a Mailet inteface. The <code>service</code> perform all needed work 12 * on the Mail object. Whatever remains at the end of the service is considered 13 * to need futher processing and will go to the next Mailet if there is one 14 * configured or will go to the error processor if not. 15 * Setting a Mail state (setState(String)) to Mail.GHOST or cleaning its recipient 16 * list has the same meaning that s no more processing is needed. 17 * Instead of creating new messages, the mailet can put a message with new recipients 18 * at the top of the mail queue, or insert them immediately after it's execution 19 * through the API are provided by the MailetContext interface. 20 * <p> 21 * This interface defines methods to initialize a mailet, to service messages, and to 22 * remove a mailet from the server. These are known as life-cycle methods and are called 23 * in the following sequence: 24 * <ol> 25 * <li>The mailet is constructed, then initialized with the init method. </li> 26 * <li>Any messages for the service method are handled.</li> 27 * <li>The mailet is taken out of service, then destroyed with the destroy method, 28 * then garbage collected and finalized.</li> 29 * </ol> 30 * In addition to the life-cycle methods, this interface provides the getMailletConfig 31 * method, which the mailet can use to get any startup information, and the 32 * getMailetInfo method, which allows the mailet to return basic information about itself, 33 * such as author, version, and copyright. 34 * 35 * @version 1.0.0, 24/04/1999 36 * @author Federico Barbieri <scoobie@pop.systemy.it> 37 * @author Stefano Mazzocchi <stefano@apache.org> 38 * @author Pierpaolo Fumagalli <pier@apache.org> 39 * @author Serge Knystautas <sergek@lokitech.com> 40 */ 41 public interface Mailet { 42 43 /*** 44 * Called by the mailet container to indicate to a mailet that the 45 * mailet is being taken out of service. This method is only called once 46 * all threads within the mailet's service method have exited or after a 47 * timeout period has passed. After the mailet container calls this method, 48 * it will not call the service method again on this mailet. 49 * <p> 50 * This method gives the mailet an opportunity to clean up any resources that 51 * are being held (for example, memory, file handles, threads) and make sure 52 * that any persistent state is synchronized with the mailet's current state in memory. 53 */ 54 void destroy(); 55 56 /*** 57 * Returns information about the mailet, such as author, version, and 58 * copyright. 59 * <p> 60 * The string that this method returns should be plain text and not markup 61 * of any kind (such as HTML, XML, etc.). 62 * 63 * @return a String containing servlet information 64 */ 65 String getMailetInfo(); 66 67 /*** 68 * Returns a MailetConfig object, which contains initialization and 69 * startup parameters for this mailet. 70 * <p> 71 * Implementations of this interface are responsible for storing the MailetConfig 72 * object so that this method can return it. The GenericMailet class, which implements 73 * this interface, already does this. 74 * 75 * @return the MailletConfig object that initializes this mailet 76 */ 77 MailetConfig getMailetConfig(); 78 79 /*** 80 * Called by the mailet container to indicate to a mailet that the 81 * mailet is being placed into service. 82 * <p> 83 * The mailet container calls the init method exactly once after 84 * instantiating the mailet. The init method must complete successfully 85 * before the mailet can receive any requests. 86 * 87 * @param config - a MailetConfig object containing the mailet's configuration 88 * and initialization parameters 89 * @throws MessagingException - if an exception has occurred that interferes with 90 * the mailet's normal operation 91 */ 92 void init(MailetConfig config) throws javax.mail.MessagingException; 93 94 /*** 95 * Called by the mailet container to allow the mailet to process to 96 * a message message. 97 * <p> 98 * This method is only called after the mailet's init() method has completed 99 * successfully. 100 * <p> 101 * Mailets typically run inside multithreaded mailet containers that can handle 102 * multiple requests concurrently. Developers must be aware to synchronize access 103 * to any shared resources such as files, network connections, and as well as the 104 * mailet's class and instance variables. More information on multithreaded 105 * programming in Java is available in <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">the 106 * Java tutorial on multi-threaded programming</a>. 107 * 108 * @param mail - the Mail object that contains the message and routing information 109 * @throws javax.mail.MessagingException - if an message or address parsing exception occurs or 110 * an exception that interferes with the mailet's normal operation 111 */ 112 void service(Mail mail) throws javax.mail.MessagingException; 113 }

This page was automatically generated by Maven