james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1028005 - in /james/server/trunk: container-spring/src/main/config/james/ mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/ mailetcontainer-library/ mailetcontainer-library/src/main/java/org/apache/james/mailetcon...
Date Wed, 27 Oct 2010 15:27:59 GMT
Author: norman
Date: Wed Oct 27 15:27:58 2010
New Revision: 1028005

URL: http://svn.apache.org/viewvc?rev=1028005&view=rev
Log:
Add support for CompositeMatcher implementations to allow complex Matcher combinations. This
implementation is based on the patch provided by Ralph B Holland, so many thanks! See JAMES-948

Added:
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/And.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/And.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/CompositeMatcher.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/CompositeMatcher.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/GenericCompositeMatcher.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/GenericCompositeMatcher.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Not.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Not.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Or.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Or.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Xor.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Xor.java
    james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/
    james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/AndTest.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AndTest.java
    james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/OrTest.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/OrTest.java
    james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/XorTest.java
      - copied, changed from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/XorTest.java
Removed:
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/And.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/CompositeMatcher.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/GenericCompositeMatcher.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Not.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Or.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Xor.java
    james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AndTest.java
    james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/OrTest.java
    james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/XorTest.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/mailetcontainer.xml
    james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
    james/server/trunk/mailetcontainer-library/pom.xml
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/MatcherManagement.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/ProcessorManagement.java

Modified: james/server/trunk/container-spring/src/main/config/james/mailetcontainer.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/mailetcontainer.xml?rev=1028005&r1=1028004&r2=1028005&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/mailetcontainer.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/mailetcontainer.xml Wed Oct
27 15:27:58 2010
@@ -36,6 +36,8 @@
         <matcherpackage>org.apache.james.transport.matchers</matcherpackage>
         <!-- Crytographic matchers -->
         <matcherpackage>org.apache.james.mailet.crypto.matchers</matcherpackage>
+        <!-- Composite matchers -->
+        <matcherpackage>org.apache.james.mailetcontainer.lib.matchers</matcherpackage>
       </matcherpackages>
       
       <!-- The root processor is a required processor - James routes all mail on the spool
-->

Modified: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java?rev=1028005&r1=1028004&r2=1028005&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
(original)
+++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
Wed Oct 27 15:27:58 2010
@@ -29,6 +29,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
+import javax.management.NotCompliantMBeanException;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -54,6 +55,7 @@ import org.apache.james.mailetcontainer.
 import org.apache.james.mailetcontainer.lib.MailetManagement;
 import org.apache.james.mailetcontainer.lib.MatcherManagement;
 import org.apache.james.mailetcontainer.lib.ProcessorDetail;
+import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
 import org.apache.mailet.Mail;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetConfig;
@@ -64,7 +66,10 @@ import org.apache.mailet.base.MatcherInv
 /**
  * Build up the Camel Routes by parsing the mailetcontainer.xml configuration file. 
  * 
- * It also offer the {@link MailProcessorList} implementation which allow to inject {@link
Mail} into the routes
+ * It also offer the {@link MailProcessorList} implementation which allow to inject {@link
Mail} into the routes.
+ *
+ * Beside the basic {@link Mailet} / {@link Matcher} support this implementation also supports
{@link CompositeMatcher} implementations.
+ * See JAMES-948 
  * 
  */
 public class CamelMailProcessorList implements Configurable, LogEnabled, MailProcessorList,
CamelContextAware, ProcessorManagementMBean {
@@ -76,6 +81,7 @@ public class CamelMailProcessorList impl
 
     private final Map<String,List<MailetManagement>> mailets = new HashMap<String,List<MailetManagement>>();
     private final Map<String,List<MatcherManagement>> matchers = new HashMap<String,List<MatcherManagement>>();
+    
     private final Map<String,MailProcessor> processors = new HashMap<String,MailProcessor>();
     private final UseLatestAggregationStrategy aggr = new UseLatestAggregationStrategy();
        
@@ -346,7 +352,13 @@ public class CamelMailProcessorList impl
                 // store the logger in properties
                 .setProperty(MatcherSplitter.LOGGER_PROPERTY, constant(logger));   
 
+                // load composite matchers if there are any
+                Map<String,MatcherManagement> compositeMatchers = new HashMap<String,
MatcherManagement>();
+                loadCompositeMatchers(processorName, compositeMatchers, processorConf.configurationsAt("matcher"));
+                
+                
                 final List<HierarchicalConfiguration> mailetConfs = processorConf.configurationsAt("mailet");
+                
                 // Loop through the mailet configuration, load
                 // all of the matcher and mailets, and add
                 // them to the processor.
@@ -366,9 +378,20 @@ public class CamelMailProcessorList impl
                             // 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);
+                            // try to load from compositeMatchers first
+                            matcher = compositeMatchers.get(matcherName);
+                            if (matcher == null) {
+                                // no composite Matcher found, try to load it via MatcherLoader
+                                matcher = matcherLoader.getMatcher(matcherName);
+                            }
                         } else if (invertedMatcherName != null) {
-                            matcher = new MatcherInverter(matcherLoader.getMatcher(invertedMatcherName));
+                            // try to load from compositeMatchers first
+                            matcher = compositeMatchers.get(matcherName);
+                            if (matcher == null) {
+                                // no composite Matcher found, try to load it via MatcherLoader
+                                matcher = matcherLoader.getMatcher(invertedMatcherName);
+                            }
+                            matcher = new MatcherInverter(matcher);
 
                         } else {
                             // default matcher is All
@@ -414,8 +437,21 @@ public class CamelMailProcessorList impl
                         throw new ConfigurationException("Unable to init mailet", ex);
                     }
                     if (mailet != null && matcher != null) {
-                        MailetManagement wrappedMailet = new MailetManagement(mailet);
-                        MatcherManagement wrappedMatcher = new MatcherManagement(matcher);
+                        MailetManagement wrappedMailet;
+                        if (mailet instanceof MailetManagement) {
+                            wrappedMailet = (MailetManagement) mailet;
+                        } else {
+                            wrappedMailet  = new MailetManagement(mailet);
+                        }
+                        
+                        MatcherManagement wrappedMatcher;
+                        if (matcher instanceof MatcherManagement) {
+                            wrappedMatcher = (MatcherManagement) matcher;
+                        } else {
+                            wrappedMatcher = new MatcherManagement(matcher);
+                        }
+                        
+                        
                         String onMatchException = null;
                         MailetConfig mailetConfig = wrappedMailet.getMailetConfig();
                     
@@ -430,6 +466,7 @@ public class CamelMailProcessorList impl
                             
                             // do splitting of the mail based on the stored matcher
                             .split().method(MatcherSplitter.class).aggregationStrategy(aggr).parallelProcessing()
+                            
                             .choice().when(new MatcherMatch()).process(mailetProccessor).end()
                             
                             .choice().when(new MailStateEquals(Mail.GHOST)).process(disposeProcessor).stop().otherwise().process(removePropsProcessor).end()
@@ -464,4 +501,65 @@ public class CamelMailProcessorList impl
                 
         }
     }
+    
+    /**
+     * Load  {@link CompositeMatcher} implementations and their child {@link Matcher}'s
+     * 
+     * CompositeMatcher were added by JAMES-948
+     * 
+     * @param processorName
+     * @param compMap
+     * @param compMatcherConfs
+     * @return compositeMatchers
+     * @throws ConfigurationException
+     * @throws MessagingException
+     * @throws NotCompliantMBeanException
+     */
+    @SuppressWarnings("unchecked")
+    private List<MatcherManagement> loadCompositeMatchers(String processorName, Map<String,MatcherManagement>
compMap, List<HierarchicalConfiguration> compMatcherConfs) throws ConfigurationException,
MessagingException, NotCompliantMBeanException {
+        List<MatcherManagement> matchers = new ArrayList<MatcherManagement>();
+
+        for (int j= 0 ; j < compMatcherConfs.size(); j++) {
+            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++) {
+                        compMatcher.add(childMatcher.get(i));
+                    }
+                }
+                matcher = new MatcherInverter(m);
+            }
+            if (matcher == null) throw new ConfigurationException("Unable to load matcher
instance");
+            MatcherManagement mgmtMatcher = new MatcherManagement(matcher);
+            matchers.add(mgmtMatcher);
+            if (compName != null) {
+                // check if there is already a composite Matcher with the name registered
in the processor
+                if (compMap.containsKey(compName)) throw new ConfigurationException("CompositeMatcher
with name " + compName + " is already defined in processor " + processorName);
+                compMap.put(compName, mgmtMatcher);
+            }
+        }
+        return matchers;
+    }
 }

Modified: james/server/trunk/mailetcontainer-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/pom.xml?rev=1028005&r1=1028004&r2=1028005&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/pom.xml (original)
+++ james/server/trunk/mailetcontainer-library/pom.xml Wed Oct 27 15:27:58 2010
@@ -81,5 +81,17 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-mailet-base</artifactId>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-standard-mailets</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/MatcherManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/MatcherManagement.java?rev=1028005&r1=1028004&r2=1028005&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/MatcherManagement.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/MatcherManagement.java
Wed Oct 27 15:27:58 2010
@@ -29,6 +29,11 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.MatcherConfig;
 
+/**
+ * JMX MBean which will collection statistics for the wrapped {@link Matcher}
+ * 
+ *
+ */
 public final class MatcherManagement extends StandardMBean implements MatcherManagementMBean,
Matcher{
     private Matcher matcher;
     private long slowestProcessing = -1;
@@ -41,8 +46,19 @@ public final class MatcherManagement ext
     public MatcherManagement(Matcher matcher) throws NotCompliantMBeanException {
         super(MatcherManagementMBean.class);
         this.matcher = matcher;
+
     }
 
+    /**
+     * Return the wrapped {@link Matcher}
+     * 
+     * @return wrappedMatcher
+     */
+    public Matcher getMatcher() {
+        return matcher;
+    }
+    
+    
     /*
      * (non-Javadoc)
      * @see org.apache.james.mailetcontainer.MatcherManagementMBean#getMatcherName()

Modified: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/ProcessorManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/ProcessorManagement.java?rev=1028005&r1=1028004&r2=1028005&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/ProcessorManagement.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/ProcessorManagement.java
Wed Oct 27 15:27:58 2010
@@ -20,6 +20,7 @@ package org.apache.james.mailetcontainer
 
 import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.annotation.PostConstruct;
@@ -37,6 +38,7 @@ import org.apache.james.mailetcontainer.
 import org.apache.james.mailetcontainer.api.MailProcessorList;
 import org.apache.james.mailetcontainer.api.MailetContainer;
 import org.apache.james.mailetcontainer.api.ProcessorManagementMBean;
+import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
 import org.apache.mailet.Mailet;
 import org.apache.mailet.Matcher;
 
@@ -73,6 +75,9 @@ public class ProcessorManagement extends
         unregisterMBeans();
     }
     
+    /**
+     * Unregister all JMX MBeans
+     */
     private void unregisterMBeans() {
         List<ObjectName> unregistered = new ArrayList<ObjectName>();
         for (int i = 0; i < mbeans.size(); i++) {
@@ -89,6 +94,11 @@ public class ProcessorManagement extends
     }
 
 
+    /**
+     * Register all JMX MBeans
+     * 
+     * @throws NotCompliantMBeanException
+     */
     private void registerMBeans() throws NotCompliantMBeanException {
        
         String baseObjectName = "org.apache.james:type=component,name=processor,";
@@ -96,12 +106,18 @@ public class ProcessorManagement extends
         String[] processorNames = getProcessorNames();
         for (int i = 0; i < processorNames.length; i++) {
             String processorName = processorNames[i];
-            createProcessorMBean(baseObjectName, processorName, mbeanserver);
-            continue;
+            registerProcessorMBean(baseObjectName, processorName);
         }
     }
 
-    private void createProcessorMBean(String baseObjectName, String processorName, MBeanServer
mBeanServer) throws NotCompliantMBeanException {
+    /**
+     * Register a JMX MBean for a {@link MailProcessor}
+     * 
+     * @param baseObjectName
+     * @param processorName
+     * @throws NotCompliantMBeanException
+     */
+    private void registerProcessorMBean(String baseObjectName, String processorName) throws
NotCompliantMBeanException {
         String processorMBeanName = baseObjectName + "processor=" + processorName;
         
         MailProcessor processor = mailProcessor.getProcessor(processorName);
@@ -114,54 +130,89 @@ public class ProcessorManagement extends
         } else {
             processorDetail = new ProcessorDetail(processorName, processor);
         }
-        registerMBean(mBeanServer, processorMBeanName, processorDetail);
+        registerMBean(processorMBeanName, processorDetail);
 
 
         // check if the processor holds Mailets and Matchers
         if (processor instanceof MailetContainer) {
             MailetContainer container = (MailetContainer) processor;
-            List<Mailet> mailets =  container.getMailets();
-         
-            for (int i = 0; i < mailets.size(); i++) {
-                MailetManagement mailetManagement;
-
-                Mailet mailet = mailets.get(i);
-                
-                // check if the mailet is an instance of MailetManagement. If not create
a wrapper around it. This will give us not all
-                // statistics but at least a few of them
-                if (mailet instanceof MailetManagement) {
-                    mailetManagement = (MailetManagement) mailet;
-                } else {
-                    mailetManagement = new MailetManagement(mailet);
-                }
-                String mailetMBeanName = processorMBeanName + ",subtype=mailet,index=" +
(i+1) + ",mailetname=" + mailetManagement.getMailetName();
-                registerMBean(mBeanServer, mailetMBeanName, mailetManagement);
-            }
-
-            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;
-                } else {
-                    matcherManagement = new MatcherManagement(matcher);
-                }
+            registerMailets(processorMBeanName, container.getMailets().iterator());
+            registerMatchers(processorMBeanName, container.getMatchers().iterator(), 0);
+           
+        }
+       
 
-                String matcherMBeanName = processorMBeanName + ",subtype=matcher,index="
+ (i+1) + ",matchername=" + matcherManagement.getMatcherName();
+    }
+    
+    /**
+     * Register the Mailets as JMX MBeans
+     * 
+     * @param parentMBeanName
+     * @param mailets
+     * @throws NotCompliantMBeanException
+     */
+    private void registerMailets(String parentMBeanName, Iterator<Mailet> mailets)
throws NotCompliantMBeanException {
+        int i = 0;
+        while(mailets.hasNext()) {
+            
+            MailetManagement mailetManagement;
 
-                registerMBean(mBeanServer, matcherMBeanName, matcherManagement);
+            Mailet mailet = mailets.next();
+            
+            // check if the mailet is an instance of MailetManagement. If not create a wrapper
around it. This will give us not all
+            // statistics but at least a few of them
+            if (mailet instanceof MailetManagement) {
+                mailetManagement = (MailetManagement) mailet;
+            } else {
+                mailetManagement = new MailetManagement(mailet);
             }
-           
+            String mailetMBeanName = parentMBeanName + ",subtype=mailet,index=" + (i++) +
",mailetname=" + mailetManagement.getMailetName();
+            registerMBean(mailetMBeanName, mailetManagement);
         }
-       
+        
+    }
+    
+
+    /**
+     * Register the {@link Matcher}'s as JMX MBeans
+     * 
+     * @param parentMBeanName
+     * @param matchers
+     * @param nestingLevel
+     * @throws NotCompliantMBeanException
+     */
+    @SuppressWarnings("unchecked")
+    private void registerMatchers(String parentMBeanName, Iterator<Matcher> matchers,
int nestingLevel) throws NotCompliantMBeanException {
+        // current level
+        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);
+            }
+        }
     }
 
-    private void registerMBean(MBeanServer mBeanServer, String mBeanName, Object object)
{
+    private void registerMBean(String mBeanName, Object object) {
         ObjectName objectName = null;
         try {
             objectName = new ObjectName(mBeanName);
@@ -171,7 +222,7 @@ public class ProcessorManagement extends
             return;
         }
         try {
-            mBeanServer.registerMBean(object, objectName);
+            mbeanserver.registerMBean(object, objectName);
             mbeans.add(objectName);
         } catch (javax.management.JMException e) {
             logger.error("Unable to register mbean", e);
@@ -196,5 +247,16 @@ public class ProcessorManagement extends
     public void setLog(Log logger) {
         this.logger = logger;
     }
+    
+
+    
+    private Matcher getWrappedMatcher(Matcher matcher) {
+        // call recursive to find the real Matcher
+        if (matcher instanceof MatcherManagement) {
+            return getWrappedMatcher(((MatcherManagement)matcher).getMatcher());
+        }
+        return matcher;
+        
+    }
 
 }

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/And.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/And.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/And.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/And.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/And.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/And.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/And.java
Wed Oct 27 15:27:58 2010
@@ -1,4 +1,4 @@
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 /****************************************************************
  * Licensed to the Apache Software Foundation (ASF) under one   *
@@ -22,6 +22,7 @@ package org.apache.james.transport.match
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.ArrayList;
+
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mail;
 import javax.mail.MessagingException;

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/CompositeMatcher.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/CompositeMatcher.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/CompositeMatcher.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/CompositeMatcher.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/CompositeMatcher.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/CompositeMatcher.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/CompositeMatcher.java
Wed Oct 27 15:27:58 2010
@@ -18,7 +18,7 @@
  ****************************************************************/
 
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 import java.util.Iterator;
 import org.apache.mailet.Matcher;

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/GenericCompositeMatcher.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/GenericCompositeMatcher.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/GenericCompositeMatcher.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/GenericCompositeMatcher.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/GenericCompositeMatcher.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/GenericCompositeMatcher.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/GenericCompositeMatcher.java
Wed Oct 27 15:27:58 2010
@@ -18,7 +18,7 @@
  ****************************************************************/
 
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 import java.util.Collection;
 import java.util.Iterator;

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Not.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Not.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Not.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Not.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Not.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Not.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Not.java
Wed Oct 27 15:27:58 2010
@@ -1,4 +1,4 @@
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 /****************************************************************
  * Licensed to the Apache Software Foundation (ASF) under one   *
@@ -22,6 +22,7 @@ package org.apache.james.transport.match
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+
 import org.apache.mailet.Matcher;
 import org.apache.mailet.Mail;
 

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Or.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Or.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Or.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Or.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Or.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Or.java (original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Or.java
Wed Oct 27 15:27:58 2010
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mail;
@@ -80,6 +80,7 @@ public class Or extends GenericComposite
                             for (Iterator i = result.iterator(); i.hasNext();) {
                                 recipient = (MailAddress) i.next();
                                 if (!finalResult.contains(recipient)) {
+                                    System.out.println(recipient);
                                     finalResult.add(recipient);
                                 }
                             }

Copied: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Xor.java
(from r1026947, james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Xor.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Xor.java?p2=james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Xor.java&p1=james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Xor.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/Xor.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/matchers/Xor.java
Wed Oct 27 15:27:58 2010
@@ -17,11 +17,12 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.ArrayList;
+
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Mail;
 import javax.mail.MessagingException;

Copied: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/AndTest.java
(from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AndTest.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/AndTest.java?p2=james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/AndTest.java&p1=james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AndTest.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/AndTest.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/AndTest.java
Wed Oct 27 15:27:58 2010
@@ -17,8 +17,12 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
+import org.apache.james.mailetcontainer.lib.matchers.And;
+import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
+import org.apache.james.transport.matchers.All;
+import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;

Copied: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/OrTest.java
(from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/OrTest.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/OrTest.java?p2=james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/OrTest.java&p1=james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/OrTest.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/OrTest.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/OrTest.java
Wed Oct 27 15:27:58 2010
@@ -17,8 +17,11 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
+import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
+import org.apache.james.mailetcontainer.lib.matchers.Or;
+import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;

Copied: james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/XorTest.java
(from r1026947, james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/XorTest.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/XorTest.java?p2=james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/XorTest.java&p1=james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/XorTest.java&r1=1026947&r2=1028005&rev=1028005&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/matchers/XorTest.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/lib/matchers/XorTest.java
Wed Oct 27 15:27:58 2010
@@ -17,8 +17,12 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.transport.matchers;
+package org.apache.james.mailetcontainer.lib.matchers;
 
+import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
+import org.apache.james.mailetcontainer.lib.matchers.Xor;
+import org.apache.james.transport.matchers.All;
+import org.apache.james.transport.matchers.RecipientIs;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.Matcher;
 import org.apache.mailet.base.test.FakeMail;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message