Package org.apache.mailet

Examples of org.apache.mailet.Matcher


                    String mailetClassName = c.getString("[@class]");
                    String matcherName = c.getString("[@match]", null);
                    String invertedMatcherName = c.getString("[@notmatch]", null);
               
                    Mailet mailet = null;
                    Matcher matcher = null;
                    try {

                        if (matcherName != null && invertedMatcherName != null) {
                            // if no matcher is configured throw an Exception
                            throw new ConfigurationException("Please configure only match or nomatch per mailet");
View Full Code Here


            }

            List<Matcher> matchers =  container.getMatchers();
            for (int i = 0; i < matchers.size(); i++) {
                MatcherManagement matcherManagement;
                Matcher matcher = matchers.get(i);
               
                // check if the matcher is an instance of MatcherManagement. If not create a wrapper around it. This will give us not all
                // statistics but at least a few of them
                if (matcher instanceof MatcherManagement) {
                   matcherManagement = (MatcherManagement) matcher;
View Full Code Here

                    if (theClassLoader == null) {
                        theClassLoader = this.getClass().getClassLoader();
                    }

                    Matcher matcher = (Matcher) theClassLoader.loadClass(className).newInstance();
                    matcher.init(configImpl);
                    return matcher;
                } catch (ClassNotFoundException cnfe) {
                    //do this so we loop through all the packages
                }
            }
View Full Code Here

                {
                    Configuration c = mailetConfs[j];
                    String mailetClassName = c.getAttribute("class");
                    String matcherName = c.getAttribute("match");
                    Mailet mailet = null;
                    Matcher matcher = null;
                    try {
                        matcher = matchLoader.getMatcher(matcherName);
                        //The matcher itself should log that it's been inited.
                        if (getLogger().isInfoEnabled()) {
                            StringBuffer infoBuffer =
View Full Code Here

                try {
                    MatcherConfigImpl configImpl = new MatcherConfigImpl();
                    configImpl.setMatcherName(matchName);
                    configImpl.setCondition(condition);
                    configImpl.setMailetContext(context);
                    Matcher matcher = (Matcher) mailetClassLoader.loadClass(className).newInstance();
                    matcher.init(configImpl);
                    return matcher;
                } catch (ClassNotFoundException cnfe) {
                    //do this so we loop through all the packages
                }
            }
View Full Code Here

       
        Iterator<List<MatcherManagement>> mit = matchers.values().iterator();    
        while (mit.hasNext()) {
            List<MatcherManagement> mList = mit.next();
            for (int i = 0; i < mList.size(); i++) {
                Matcher m = mList.get(i);
                if (debugEnabled) {
                    logger.debug("Shutdown matcher " + m.getMatcherInfo());
                }
                m.destroy();
            }
          
        }     
    }
View Full Code Here

            HierarchicalConfiguration c = compMatcherConfs.get(j);
            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(matcherName);
                if (matcher instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) matcher;
                   
                    List<MatcherManagement> childMatcher = loadCompositeMatchers(processorName, compMap,c.configurationsAt("matcher"));
                    for (int i = 0 ; i < childMatcher.size(); i++) {
                        compMatcher.add(childMatcher.get(i));
                    }
                }
            } else if (invertedMatcherName != null) {
                Matcher m = matcherLoader.getMatcher(invertedMatcherName);
                if (m instanceof CompositeMatcher) {
                    CompositeMatcher compMatcher = (CompositeMatcher) m;
                   
                    List<MatcherManagement> childMatcher = loadCompositeMatchers(processorName, compMap,c.configurationsAt("matcher"));
                    for (int i = 0 ; i < childMatcher.size(); i++) {
View Full Code Here

                    String mailetClassName = c.getString("[@class]");
                    String matcherName = c.getString("[@match]", null);
                    String invertedMatcherName = c.getString("[@notmatch]", null);
               
                    Mailet mailet = null;
                    Matcher matcher = null;
                    try {

                        if (matcherName != null && invertedMatcherName != null) {
                            // if no matcher is configured throw an Exception
                            throw new ConfigurationException("Please configure only match or nomatch per mailet");
View Full Code Here

        int currentLevel = nestingLevel;
        int i = 0;

        while (matchers.hasNext()) {
            MatcherManagement matcherManagement;
            Matcher matcher = matchers.next();
           
            // check if the matcher is an instance of MatcherManagement. If not create a wrapper around it. This will give us not all
            // statistics but at least a few of them
            if (matcher instanceof MatcherManagement) {
               matcherManagement = (MatcherManagement) matcher;
            } else {
                matcherManagement = new MatcherManagement(matcher);
            }

            String matcherMBeanName = parentMBeanName + ",subtype" + currentLevel +"=matcher,index" + currentLevel+"=" + (i++) + ",matchername" + currentLevel+"=" + matcherManagement.getMatcherName();
            registerMBean(matcherMBeanName, matcherManagement);
           
            Matcher wrappedMatcher = getWrappedMatcher(matcherManagement);
           
            // Handle CompositeMatcher which were added by JAMES-948
            if (wrappedMatcher instanceof CompositeMatcher) {
                // we increment the nesting as we have one more child level and register the child matchers
                registerMatchers(matcherMBeanName, ((CompositeMatcher) wrappedMatcher).iterator(), ++nestingLevel);
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 = null;
        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

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.