Package org.apache.mailet

Examples of org.apache.mailet.Matcher


        String matchName = config.getMatcherName();

        try {

            final Matcher matcher = load(matchName);

            // init the matcher
            matcher.init(config);
            return matcher;

        } catch (MessagingException me) {
            throw me;
        } catch (Exception e) {
View Full Code Here


            jmxListener.dispose();
        }

        for (MatcherMailetPair pair : pairs) {
            Mailet mailet = pair.getMailet();
            Matcher matcher = pair.getMatcher();
            if (logger.isDebugEnabled()) {
                logger.debug("Shutdown matcher " + matcher.getMatcherInfo());
            }
            matcher.destroy();

            if (logger.isDebugEnabled()) {
                logger.debug("Shutdown mailet " + mailet.getMailetInfo());
            }
            mailet.destroy();
View Full Code Here

        for (HierarchicalConfiguration c : compMatcherConfs) {
            String compName = c.getString("[@name]", null);
            String matcherName = c.getString("[@match]", null);
            String invertedMatcherName = c.getString("[@notmatch]", null);

            Matcher matcher = null;
            if (matcherName != null && invertedMatcherName != null) {
                // if no matcher is configured throw an Exception
                throw new ConfigurationException("Please configure only match or nomatch per mailet");
            } else if (matcherName != null) {
                matcher = matcherLoader.getMatcher(createMatcherConfig(matcherName));
                if (matcher instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) matcher;

                    List<Matcher> childMatcher = loadCompositeMatchers(state, compMap, c.configurationsAt("matcher"));
                    for (Matcher aChildMatcher : childMatcher) {
                        compMatcher.add(aChildMatcher);
                    }
                }
            } else if (invertedMatcherName != null) {
                Matcher m = matcherLoader.getMatcher(createMatcherConfig(invertedMatcherName));
                if (m instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) m;

                    List<Matcher> childMatcher = loadCompositeMatchers(state, compMap, c.configurationsAt("matcher"));
                    for (Matcher aChildMatcher : childMatcher) {
View Full Code Here

            String mailetClassName = c.getString("[@class]");
            String matcherName = c.getString("[@match]", null);
            String invertedMatcherName = c.getString("[@notmatch]", null);

            Mailet mailet;
            Matcher matcher;

            try {

                if (matcherName != null && invertedMatcherName != null) {
                    // if no matcher is configured throw an Exception
View Full Code Here

        FakeMatcherConfig mci = new FakeMatcherConfig(matcherName, context);
        matcher.init(mci);
    }

    void setupChild(String matcherName) throws MessagingException {
        Matcher child;
        if (matcherName.equals("All")) {
            child = new All();
        }
        else {
            child = new RecipientIs();
        }
        FakeMatcherConfig sub = new FakeMatcherConfig(matcherName, context);
        child.init(sub);
        matcher.add(child);
    }
View Full Code Here

     * @return Collection of Recipient from the Or composition results of the
     *         child matchers.
     */
    public Collection match(Mail mail) throws MessagingException {
        Collection finalResult = null;
        Matcher matcher;
        boolean first = true;

        // the size of the complete set of recipients
        int size = mail.getRecipients().size();

        // Loop through until the finalResult is full or all the child matchers
        // have been executed
        for (Iterator matcherIter = iterator(); matcherIter.hasNext();) {
            matcher = (Matcher) matcherIter.next();
            // log("Matching with "
            // + matcher
            // .getMatcherConfig()
            // .getMatcherName()
            // );
            Collection result = matcher.match(mail);
            if (first) {
                if (result == null) {
                    result = new ArrayList(0);
                }
                finalResult = result;
View Full Code Here

     * @return Collectiom of Recipient from the Negated composition of the child
     *         Matcher(s).
     */
    public Collection match(Mail mail) throws MessagingException {
        Collection finalResult = mail.getRecipients();
        Matcher matcher;
        for (Iterator matcherIter = iterator(); matcherIter.hasNext();) {
            matcher = (Matcher) (matcherIter.next());
            // log("Matching with " +
            // matcher.getMatcherConfig().getMatcherName());
            Collection result = matcher.match(mail);
            if (result == finalResult) {
                // Not is an empty list
                finalResult = null;
            } else if (result != null) {
                finalResult = new ArrayList(finalResult);
View Full Code Here

     * @return Collection of Recipients from the Xor composition of the child
     *         matchers.
     */
    public Collection match(Mail mail) throws MessagingException {
        Collection finalResult = null;
        Matcher matcher;
        boolean first = true;
        for (Iterator matcherIter = iterator(); matcherIter.hasNext();) {
            matcher = (Matcher) (matcherIter.next());
            Collection result = matcher.match(mail);
            if (result == null) {
                result = new ArrayList(0);
            }
            // log("Matching with " +
            // matcher.getMatcherConfig().getMatcherName() +
View Full Code Here

    public Matcher getMatcher(MatcherConfig config) throws MessagingException {

        try {
            Class<Matcher> clazz = (Class<Matcher>) Thread.currentThread().getContextClassLoader().loadClass(config.
                    getMatcherName());
            Matcher m = clazz.newInstance();
            m.init(config);
            return m;
        } catch (Exception e) {
            throw new MessagingException("Unable to load matcher " + config.getMatcherName());
        }
View Full Code Here

     * @return Collection of Recipient from the And composition results of the
     *         child Matchers.
     */
    public Collection match(Mail mail) throws MessagingException {
        Collection finalResult = null;
        Matcher matcher;
        boolean first = true;
        for (Iterator matcherIter = iterator(); matcherIter.hasNext();) {
            matcher = (Matcher) (matcherIter.next());
            Collection result = matcher.match(mail);

            if (result == null) {
                // short-circuit
                // log("Matching with " +
                // matcher.getMatcherConfig().getMatcherName() +
View Full Code Here

TOP

Related Classes of org.apache.mailet.Matcher

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.