FileDocCategorySizeDatePackage
JamesMailetLoader.javaAPI DocApache James 2.3.13687Fri Jan 12 12:56:26 GMT 2007org.apache.james.transport

JamesMailetLoader

public class JamesMailetLoader extends Loader implements org.apache.james.services.MailetLoader
Loads Mailets for use inside James.

Fields Summary
Constructors Summary
Methods Summary
public voidconfigure(org.apache.avalon.framework.configuration.Configuration conf)

see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)

        getPackages(conf,MAILET_PACKAGE);
    
public org.apache.mailet.MailetgetMailet(java.lang.String mailetName, org.apache.avalon.framework.configuration.Configuration configuration)

see
org.apache.james.services.MailetLoader#getMailet(java.lang.String, org.apache.avalon.framework.configuration.Configuration)

        try {
            for (int i = 0; i < packages.size(); i++) {
                String className = (String) packages.elementAt(i) + mailetName;
                try {
                    MailetConfigImpl configImpl = new MailetConfigImpl();
                    configImpl.setMailetName(mailetName);
                    configImpl.setConfiguration(configuration);
                    configImpl.setMailetContext(mailetContext);
                    Mailet mailet = (Mailet) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
                    mailet.init(configImpl);
                    return mailet;
                } catch (ClassNotFoundException cnfe) {
                    //do this so we loop through all the packages
                }
            }
            StringBuffer exceptionBuffer =
                new StringBuffer(128)
                    .append("Requested mailet not found: ")
                    .append(mailetName)
                    .append(".  looked in ")
                    .append(packages.toString());
            throw new ClassNotFoundException(exceptionBuffer.toString());
        } catch (MessagingException me) {
            throw me;
        } catch (Exception e) {
            StringBuffer exceptionBuffer =
                new StringBuffer(128).append("Could not load mailet (").append(mailetName).append(
                    ")");
            throw new MailetException(exceptionBuffer.toString(), e);
        }