FileDocCategorySizeDatePackage
LocalDelivery.javaAPI DocApache James 2.3.14647Fri Jan 12 12:56:28 GMT 2007org.apache.james.transport.mailets

LocalDelivery

public class LocalDelivery extends org.apache.mailet.GenericMailet
Receives a Mail from JamesSpoolManager and takes care of delivery of the message to local inboxes. Since James 2.3.0 this mailet is a composition of UserRepositoryAliasingForwarding and ToMultiRepository configurated to mimic the old "LocalDelivery" behaviour.

Fields Summary
private UsersRepositoryAliasingForwarding
aliasingMailet
Mailet that apply aliasing and forwarding
private ToMultiRepository
deliveryMailet
Mailet that actually store the message
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "Local Delivery Mailet";
    
public voidinit()

see
org.apache.mailet.GenericMailet#init()

        super.init();
        aliasingMailet = new UsersRepositoryAliasingForwarding();
        aliasingMailet.init(getMailetConfig());
        deliveryMailet = new ToMultiRepository();
        MailetConfig m = new MailetConfig() {

            /**
             * @see org.apache.mailet.MailetConfig#getInitParameter(java.lang.String)
             */
            public String getInitParameter(String name) {
                if ("addDeliveryHeader".equals(name)) {
                    return "Delivered-To";
                } else if ("resetReturnPath".equals(name)) {
                    return "true";
                } else {
                    return getMailetConfig().getInitParameter(name);
                }
            }

            /**
             * @see org.apache.mailet.MailetConfig#getInitParameterNames()
             */
            public Iterator getInitParameterNames() {
                IteratorChain c = new IteratorChain();
                Collection h = new ArrayList();
                h.add("addDeliveryHeader");
                h.add("resetReturnPath");
                c.addIterator(getMailetConfig().getInitParameterNames());
                c.addIterator(h.iterator());
                return c;
            }

            /**
             * @see org.apache.mailet.MailetConfig#getMailetContext()
             */
            public MailetContext getMailetContext() {
                return getMailetConfig().getMailetContext();
            }

            /**
             * @see org.apache.mailet.MailetConfig#getMailetName()
             */
            public String getMailetName() {
                return getMailetConfig().getMailetName();
            }

        };
        deliveryMailet.init(m);
    
public voidservice(org.apache.mailet.Mail mail)
Delivers a mail to a local mailbox.

param
mail the mail being processed
throws
MessagingException if an error occurs while storing the mail

        aliasingMailet.service(mail);
        if (mail.getState() != Mail.GHOST) {
            deliveryMailet.service(mail);
        }