Author: norman
Date: Fri Mar 5 06:26:51 2010
New Revision: 919309
URL: http://svn.apache.org/viewvc?rev=919309&view=rev
Log:
* Some pending changes which allow developers to easily write their own
ProcessorRouteBuilder which use other consumer and producers for mails.
* Add implementation for non ActiveMQ JMS
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/AbstractProcessorRouteBuilder.java
- copied, changed from r919305,
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQProcessorRouteBuilder.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQRecipientList.java
- copied, changed from r919305,
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSProcessorRouteBuilder.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSRecipientList.java
Removed:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java
Copied:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/AbstractProcessorRouteBuilder.java
(from r919305,
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java)
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/AbstractProcessorRouteBuilder.java?p2=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/AbstractProcessorRouteBuilder.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java&r1=919305&r2=919309&rev=919309&view=diff
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailProcessorRouteBuilder.java
(original)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/AbstractProcessorRouteBuilder.java
Fri Mar 5 06:26:51 2010
@@ -55,7 +55,7 @@
*
* TODO: - Limit Threads
*/
-public class MailProcessorRouteBuilder extends RouteBuilder implements
SpoolManager, Configurable, LogEnabled {
+public abstract class AbstractProcessorRouteBuilder extends RouteBuilder
implements SpoolManager, Configurable, LogEnabled {
private MatcherLoader matcherLoader;
private HierarchicalConfiguration config;
@@ -100,7 +100,7 @@
matchers.put(processorName, new ArrayList<Matcher>());
// Check which route we need to go
- ChoiceDefinition processorDef =
fromF("activemq:queue:processor.%s?maxConcurrentConsumers=50", processorName)
+ ChoiceDefinition processorDef = fromF(getFromUri(processorName))
// exchange mode is inOnly
.inOnly()
@@ -218,7 +218,7 @@
// check if the state of the mail is the same as
the
// current processor. If not just route it to the
right endpoint via recipientList and stop processing.
- .when(new
MailStateNotEquals(processorName)).recipientList().method(MailRouter.class).stop()
+ .when(new
MailStateNotEquals(processorName)).recipientList().method(getRecipientList()).stop()
// end first choice
.end()
@@ -252,7 +252,7 @@
.end()
// route it to the right processor
- .recipientList().method(MailRouter.class);
+ .recipientList().method(getRecipientList());
}
}
@@ -395,5 +395,19 @@
return TERMINATING_MAILET_NAME;
}
}
+
+ /**
+ * Return the uri for the processor to use for consuming mails
+ *
+ * @param processor
+ * @return consumerUri
+ */
+ protected abstract String getFromUri(String processor);
+ /**
+ * Return the class which get used for dynamic lookup the ToUris for the
mails (producers)
+ *
+ * @return recipientListClass
+ */
+ protected abstract Class<?> getRecipientList();
}
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQProcessorRouteBuilder.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQProcessorRouteBuilder.java?rev=919309&view=auto
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQProcessorRouteBuilder.java
(added)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQProcessorRouteBuilder.java
Fri Mar 5 06:26:51 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.transport.camel;
+
+
+/**
+ * ActiveMQ based ProcessorRouteBuilder which use a JMS to consume and produce
mails
+ *
+ */
+public class ActiveMQProcessorRouteBuilder extends
AbstractProcessorRouteBuilder {
+
+ @Override
+ protected String getFromUri(String processorName) {
+ return "activemq:queue:processor." +
processorName+"?maxConcurrentConsumers=50";
+ }
+
+ @Override
+ protected Class<?> getRecipientList() {
+ return ActiveMQRecipientList.class;
+ }
+
+}
Copied:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQRecipientList.java
(from r919305,
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java)
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQRecipientList.java?p2=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQRecipientList.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java&r1=919305&r2=919309&rev=919309&view=diff
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/MailRouter.java
(original)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/ActiveMQRecipientList.java
Fri Mar 5 06:26:51 2010
@@ -22,12 +22,12 @@
import org.apache.mailet.Mail;
/**
- * Route the mail to the right JMS queue depending on the state of the Mail.
+ * RecipientList implementation which route the mail to a ActiveMQ Queue with
the name of
+ * processor.$mailstate
*
- *
- *
+ * $mailstate is the what get returned by Mail.getState()
*/
-public class MailRouter {
+public class ActiveMQRecipientList {
/**
* Route Mail to the right JMS queue based on the state of the mail
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSProcessorRouteBuilder.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSProcessorRouteBuilder.java?rev=919309&view=auto
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSProcessorRouteBuilder.java
(added)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSProcessorRouteBuilder.java
Fri Mar 5 06:26:51 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.transport.camel;
+
+/**
+ * JMS based ProcessorRouteBuilder which use a JMS to consume and produce mails
+ *
+ * If you want to use ActiveMQ as JMS implementation you should use {...@link
ActiveMQProcessorRouteBuilder}
+ */
+public class JMSProcessorRouteBuilder extends AbstractProcessorRouteBuilder{
+
+
+ @Override
+ protected String getFromUri(String processorName) {
+ return "jms:queue:processor." +
processorName+"?maxConcurrentConsumers=50";
+ }
+
+ @Override
+ protected Class<?> getRecipientList() {
+ return JMSRecipientList.class;
+ }
+
+}
Added:
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSRecipientList.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSRecipientList.java?rev=919309&view=auto
==============================================================================
---
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSRecipientList.java
(added)
+++
james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/camel/JMSRecipientList.java
Fri Mar 5 06:26:51 2010
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.transport.camel;
+
+import org.apache.camel.Body;
+import org.apache.mailet.Mail;
+
+/**
+ * RecipientList implementation which route the mail to a JMS Queue with the
name of
+ * processor.$mailstate
+ *
+ * $mailstate is the what get returned by Mail.getState()
+ *
+ * If you want to use ActiveMQ as JMS implementation you should use {...@link
ActiveMQRecipientList}
+ *
+ *
+ */
+public class JMSRecipientList {
+
+ /**
+ * Route Mail to the right JMS queue based on the state of the mail
+ *
+ * @param mail
+ * @return camel endpoint uri
+ */
+ public String to(@Body Mail mail) {
+ String queueName = "jms:queue:processor."+ mail.getState();
+ return queueName;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]