Package org.apache.mailet

Examples of org.apache.mailet.Mailet


    public void testFullQualifiedUsingFakeConfig() throws ConfigurationException, MessagingException {
        m_conf.add("none.existing.package"); // has to be here so the Loader won't choke
        setUpLoader();

        Mailet mailet = m_jamesMailetLoader.getMailet("org.apache.james.transport.mailets.Null", null);
        assetIsNullMailet(mailet);
    }
View Full Code Here


    public void testStandardMailets() throws ConfigurationException, MessagingException {
        m_conf.addStandardPackages();
        setUpLoader();

        // use standard package
        Mailet mailetNull1 = m_jamesMailetLoader.getMailet("Null", null);
        assetIsNullMailet(mailetNull1);

        // use full qualified package in parallel
        Mailet mailetNull2 = m_jamesMailetLoader.getMailet("org.apache.james.transport.mailets.Null", null);
        assetIsNullMailet(mailetNull2);

    }
View Full Code Here

    private void checkTestMailet(String mailetName) throws MessagingException {
        // use standard package
        DefaultConfiguration configuration = new DefaultConfiguration("mailetLoaderTest");
        configuration.addChild(Util.getValuedConfiguration("testMailetKey", "testMailetValue"));

        Mailet mailet = m_jamesMailetLoader.getMailet(mailetName, configuration);
        assertTrue("MailetLoaderTestMailet mailet is expected class", mailet instanceof MailetLoaderTestMailet);
        MailetLoaderTestMailet mailetLoaderTestMailet = ((MailetLoaderTestMailet) mailet);
        assertTrue("init was called by loader", mailetLoaderTestMailet.assertInitCalled());
        MailetConfig mailetConfig = mailetLoaderTestMailet.getMailetConfig();
        assertEquals("init was called w/ right config", "testMailetValue", mailetConfig.getInitParameter("testMailetKey"));
View Full Code Here

    }

    private String processAddFooter(String asciisource, String footer)
            throws MessagingException, IOException {
        Mailet mailet = new AddFooter();

        MockMailetConfig mci = new MockMailetConfig("Test",new MockMailContext());
        mci.setProperty("text",footer);

        mailet.init(mci);

        Mail mail = new MailImpl(new MimeMessage(Session
                .getDefaultInstance(new Properties()),
                new ByteArrayInputStream(asciisource.getBytes())));

        mailet.service(mail);

        ByteArrayOutputStream rawMessage = new ByteArrayOutputStream();
        mail.getMessage().writeTo(
                rawMessage,
                new String[] { "Bcc", "Content-Length", "Message-ID" });
View Full Code Here

        recipientIs.init(new DummyMatcherConfig("rec1@domain.com"));
       
        Matcher all = new All();
        all.init(new DummyMatcherConfig(""));
       
        Mailet changeBody = new MyMailet();
        Mailet changeBody2 = new MyMailet();

        changeBody.init(mockMailetConfig);
        changeBody2.init(mockMailetConfig);
       
        Mailet dumpSystemErr = new DumpSystemErr();
        changeBody.init(mockMailetConfig);
       
        checkerMailet = new CheckerMailet();
        t.add(recipientIs,changeBody);
        t.add(all,changeBody);
View Full Code Here

        recipientIs.init(new DummyMatcherConfig("rec1@domain.com"));
       
        Matcher all = new All();
        all.init(new DummyMatcherConfig(""));
       
        Mailet dumpSystemErr = new DumpSystemErr();
       
        checkerMailet = new CheckerMailet();
        t.add(recipientIs,dumpSystemErr);
        t.add(all,dumpSystemErr);
        t.add(all,checkerMailet);
View Full Code Here

                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
                }
            }
View Full Code Here

     */
    public void dispose() {
        Iterator it = mailets.iterator();
        boolean debugEnabled = getLogger().isDebugEnabled();
        while (it.hasNext()) {
            Mailet mailet = (Mailet)it.next();
            if (debugEnabled) {
                getLogger().debug("Shutdown mailet " + mailet.getMailetInfo());
            }
            mailet.destroy();
        }
    }
View Full Code Here

           
                public String getMatcherInfo() {
                    return TERMINATING_MATCHER_NAME;
                }
            };
        Mailet terminatingMailet =
            new GenericMailet() {
                public void service(Mail mail) {
                    if (!(Mail.ERROR.equals(mail.getState()))) {
                        // Don't complain if we fall off the end of the
                        // error processor.  That is currently the
View Full Code Here

                unprocessed[i + 1].add(notMail);
                //We have to set the reduce possible recipients on the old message
                mail.setRecipients(recipients);
            }
            // We have messages that need to process... time to run the mailet.
            Mailet mailet = (Mailet) mailets.get(i);
            if (getLogger().isDebugEnabled()) {
                logMessageBuffer =
                    new StringBuffer(128)
                            .append("Servicing ")
                            .append(mail.getName())
                            .append(" by ")
                            .append(mailet.getMailetInfo());
                getLogger().debug(logMessageBuffer.toString());
            }
            try {
                mailet.service(mail);
                // Make sure all the recipients are still MailAddress objects
                verifyMailAddresses(mail.getRecipients());
            } catch (MessagingException me) {
                MailetConfig mailetConfig = mailet.getMailetConfig();
                String onMailetException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMailetException");
                if (onMailetException == null) {
                    onMailetException = Mail.ERROR;
                } else {
                    onMailetException = onMailetException.trim().toLowerCase(Locale.US);
                }
                if (onMailetException.compareTo("ignore") == 0) {
                    // ignore the exception and continue
                    // this option should not be used if the mail object can be changed by the mailet
                    verifyMailAddresses(mail.getRecipients());
                } else {
                    handleException(me, mail, mailet.getMailetConfig().getMailetName(), onMailetException);
                }
            }

            // See if the state was changed by the mailet
            if (!mail.getState().equals(originalState)) {
View Full Code Here

TOP

Related Classes of org.apache.mailet.Mailet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.