You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/03/05 07:51:23 UTC

svn commit: r919315 - in /james/server/trunk: spoolmanager/src/main/java/org/apache/james/ spring-deployment/src/main/config/james/

Author: norman
Date: Fri Mar  5 06:51:23 2010
New Revision: 919315

URL: http://svn.apache.org/viewvc?rev=919315&view=rev
Log:
* Some pending changes which allow developers to easily write their MailServer implementation which use other producers then ActiveMQ or JMS
* Rename James class to something more meaningful
* Add implementation for non ActiveMQ JMS

Added:
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/AbstractMailServer.java
      - copied, changed from r919305, james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/ActiveMQMailServer.java
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/JMSMailServer.java
Removed:
    james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java
Modified:
    james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml

Copied: james/server/trunk/spoolmanager/src/main/java/org/apache/james/AbstractMailServer.java (from r919305, james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/AbstractMailServer.java?p2=james/server/trunk/spoolmanager/src/main/java/org/apache/james/AbstractMailServer.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java&r1=919305&r2=919315&rev=919315&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/James.java (original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/AbstractMailServer.java Fri Mar  5 06:51:23 2010
@@ -76,7 +76,7 @@
 
  */
 @SuppressWarnings("unchecked")
-public class James
+public abstract class AbstractMailServer
     implements MailServer, LogEnabled, Configurable {
 
     /**
@@ -377,7 +377,7 @@
      */
     public void sendMail(Mail mail) throws MessagingException {
         try {
-            producerTemplate.sendBody("activemq:queue:processor."+ mail.getState(), ExchangePattern.InOnly, new InMemoryMail(mail));
+            producerTemplate.sendBody(getToUri(mail), ExchangePattern.InOnly, new InMemoryMail(mail));
             
         } catch (Exception e) {
             logger.error("Error storing message: " + e.getMessage(),e);
@@ -574,4 +574,13 @@
             return getDefaultDomain();
         }
     }
+    
+    /**
+     * Return the camel endpoint uri which should get used for the given mail
+     * 
+     * @param mail
+     * @return toUri
+     * 
+     */
+    protected abstract String getToUri(Mail mail);
 }

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/ActiveMQMailServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/ActiveMQMailServer.java?rev=919315&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/ActiveMQMailServer.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/ActiveMQMailServer.java Fri Mar  5 06:51:23 2010
@@ -0,0 +1,37 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james;
+
+
+import org.apache.mailet.Mail;
+
+/**
+ * MailServer implementation which use ActiveMQ to spool mails
+ * 
+ *
+ */
+public class ActiveMQMailServer extends AbstractMailServer{
+
+    @Override
+    protected String getToUri(Mail mail) {
+        return "activemq:queue:processor."+ mail.getState();
+    }
+}

Added: james/server/trunk/spoolmanager/src/main/java/org/apache/james/JMSMailServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/JMSMailServer.java?rev=919315&view=auto
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/JMSMailServer.java (added)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/JMSMailServer.java Fri Mar  5 06:51:23 2010
@@ -0,0 +1,39 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james;
+
+
+import org.apache.mailet.Mail;
+
+/**
+ * MailServer implementation which use JMS to spool mails#
+ * 
+ * If you use ActiveMQ for JMS you should use {@link ActiveMQMailServer}
+ * 
+ *
+ */
+public class JMSMailServer extends AbstractMailServer{
+
+    @Override
+    protected String getToUri(Mail mail) {
+        return "activemq:queue:processor."+ mail.getState();
+    }
+}

Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=919315&r1=919314&r2=919315&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Fri Mar  5 06:51:23 2010
@@ -82,6 +82,7 @@
 				<entry key="pop3ProtocolHandlerChain" value="pop3server"/>
 				<entry key="remoteProtocolHandlerChain" value="remotemanager"/>		
 				<entry key="spool" value="spoolmanager"/>
+				<entry key="mailserver" value="James"/>				
 	        </map>
 		</property>
 	</bean>
@@ -101,7 +102,8 @@
 				<entry key="smtpProtocolHandlerChain" value="smtpserver"/>
 				<entry key="pop3ProtocolHandlerChain" value="pop3server"/>
 				<entry key="remoteProtocolHandlerChain" value="remoteManager"/>
-				<entry key="spool" value="spoolmanager"/>				
+				<entry key="spool" value="spoolmanager"/>	
+				<entry key="mailserver" value="James"/>										
 			</map>
 		</property>
 	</bean>
@@ -122,8 +124,8 @@
         <camel:routeBuilder ref="processorRoute" /> 
     </camel:camelContext>
 
-     <!-- Build the camelroute from the spoolmanager.xml -->
-     <bean id="spoolmanager" name="processorRoute" class="org.apache.james.transport.camel.MailProcessorRouteBuilder"/>
+     <!-- Build the camelroute from the spoolmanager.xml using ActiveMQ as producer and consumer-->
+     <bean id="spoolmanager" name="processorRoute" class="org.apache.james.transport.camel.ActiveMQProcessorRouteBuilder"/>
  
  
 
@@ -154,7 +156,8 @@
         <property name="start" value="true" />
     </bean>
     
-	<bean id="James" class="org.apache.james.James"/>
+    <!-- mailserver implementation which use activemq for spooling the mail -->
+	<bean id="mailserver" name="James" class="org.apache.james.ActiveMQMailServer"/>
 	
 	<bean id="mailetcontext" class="org.apache.james.JamesMailetContext"/>
 



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