james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1052216 - in /james/server/trunk: mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/ mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/
Date Thu, 23 Dec 2010 10:34:21 GMT
Author: norman
Date: Thu Dec 23 10:34:20 2010
New Revision: 1052216

URL: http://svn.apache.org/viewvc?rev=1052216&view=rev
Log:
Make sure we send the mail to the next processor on state change

Modified:
    james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessor.java
    james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessor.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java

Modified: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessor.java?rev=1052216&r1=1052215&r2=1052216&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessor.java
(original)
+++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelCompositeProcessor.java
Thu Dec 23 10:34:20 2010
@@ -29,19 +29,14 @@ import org.apache.james.mailetcontainer.
 import org.apache.james.mailetcontainer.api.MailetLoader;
 import org.apache.james.mailetcontainer.api.MatcherLoader;
 import org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor;
-import org.apache.james.mailetcontainer.lib.matchers.CompositeMatcher;
 import org.apache.mailet.Mail;
-import org.apache.mailet.Mailet;
 import org.apache.mailet.MailetContext;
-import org.apache.mailet.Matcher;
 
 /**
  * Build up the Camel Routes by parsing the mailetcontainer.xml configuration file. 
  * 
- * It also offer the {@link CompositeProcessor} implementation which allow to inject {@link
Mail} into the routes.
+ * It also offer the {@link AbstractStateCompositeProcessor} 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 CamelCompositeProcessor extends AbstractStateCompositeProcessor implements CamelContextAware{
@@ -104,15 +99,21 @@ public class CamelCompositeProcessor ext
      * @see org.apache.james.mailetcontainer.lib.AbstractCompositeMailProcessor#createMailProcessor(java.lang.String,
org.apache.commons.configuration.HierarchicalConfiguration)
      */
     protected MailProcessor createMailProcessor(String name, HierarchicalConfiguration config)
throws Exception{
-        CamelMailetProcessor container = new CamelMailetProcessor();
-        container.setLog(logger);
-        container.setCamelContext(camelContext);
-        container.setMailetContext(mailetContext);
-        container.setMailetLoader(mailetLoader);
-        container.setMatcherLoader(matcherLoader);
-        container.configure(config);
-        container.init();
-        return container;
+        CamelMailetProcessor processor = new CamelMailetProcessor();
+        try {
+            processor.setLog(logger);
+            processor.setCamelContext(camelContext);
+            processor.setMailetContext(mailetContext);
+            processor.setMailetLoader(mailetLoader);
+            processor.setMatcherLoader(matcherLoader);
+            processor.configure(config);
+            processor.init();
+            return processor;
+        } catch (Exception e) {
+            processor.destroy();
+            
+            throw e;
+        }
     }
  
 

Modified: james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessor.java?rev=1052216&r1=1052215&r2=1052216&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessor.java
(original)
+++ james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailetProcessor.java
Thu Dec 23 10:34:20 2010
@@ -140,6 +140,8 @@ public class CamelMailetProcessor extend
             Processor disposeProcessor = new DisposeProcessor();
             Processor removePropsProcessor = new RemovePropertiesProcessor();
             Processor completeProcessor = new CompleteProcessor();
+            Processor stateChangedProcessor = new StateChangedProcessor();
+            
             String state = getState();
             Log logger = getLogger();
 
@@ -171,7 +173,7 @@ public class CamelMailetProcessor extend
                     
                     .choice().when(new MailStateEquals(Mail.GHOST)).process(disposeProcessor).stop().otherwise().process(removePropsProcessor).end()
 
-                    .choice().when(new MailStateNotEquals(state)).process(completeProcessor).stop().end();
+                    .choice().when(new MailStateNotEquals(state)).process(stateChangedProcessor).process(completeProcessor).stop().end();
             }
                 
           
@@ -219,6 +221,16 @@ public class CamelMailetProcessor extend
             }
         }
         
+        private final class StateChangedProcessor implements Processor {
+
+            public void process(Exchange arg0) throws Exception {
+                Mail mail = arg0.getIn().getBody(Mail.class);
+                mailetContext.sendMail(mail);
+                
+            }
+            
+        }
+        
     }
 
 

Modified: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java?rev=1052216&r1=1052215&r2=1052216&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
(original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/AbstractStateMailetProcessor.java
Thu Dec 23 10:34:20 2010
@@ -57,7 +57,7 @@ import org.apache.mailet.base.MatcherInv
  */
 public abstract class AbstractStateMailetProcessor implements MailProcessor, Configurable,
LogEnabled{
 
-    private MailetContext mailetContext;
+    protected MailetContext mailetContext;
     private MatcherLoader matcherLoader;
     private List<MailetProcessorListener> listeners = Collections.synchronizedList(new
ArrayList<MailetProcessorListener>());
     private JMXStateMailetProcessorListener jmxListener;



---------------------------------------------------------------------
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