Author: norman
Date: Mon Jun 27 10:42:20 2011
New Revision: 1140094
URL: http://svn.apache.org/viewvc?rev=1140094&view=rev
Log:
Move API from mailetcontainer-library to mailetcontainer-api. See JAMES-1282
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailProcessorManagementMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailSpoolerMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailetManagementMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java
james/server/trunk/mailetcontainer-api/src/test/
james/server/trunk/mailetcontainer-api/src/test/java/
james/server/trunk/mailetcontainer-api/src/test/java/org/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
Removed:
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java
james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/api/jmx/
james/server/trunk/mailetcontainer-library/src/test/java/org/apache/james/mailetcontainer/api/mock/
Modified:
james/server/trunk/mailetcontainer-api/ (props changed)
james/server/trunk/mailetcontainer-api/.classpath
james/server/trunk/mailetcontainer-api/pom.xml
james/server/trunk/mailetcontainer-camel/pom.xml
james/server/trunk/mailetcontainer-library/pom.xml
james/server/trunk/pom.xml
Propchange: james/server/trunk/mailetcontainer-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 27 10:42:20 2011
@@ -0,0 +1 @@
+target
Modified: james/server/trunk/mailetcontainer-api/.classpath
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/.classpath?rev=1140094&r1=1140093&r2=1140094&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-api/.classpath (original)
+++ james/server/trunk/mailetcontainer-api/.classpath Mon Jun 27 10:42:20 2011
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: james/server/trunk/mailetcontainer-api/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/pom.xml?rev=1140094&r1=1140093&r2=1140094&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-api/pom.xml (original)
+++ james/server/trunk/mailetcontainer-api/pom.xml Mon Jun 27 10:42:20 2011
@@ -67,11 +67,9 @@ Parent pom build failure prevents inheri
<groupId>org.apache.james</groupId>
<artifactId>apache-mailet</artifactId>
</dependency>
-
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
+ <groupId>${javax.mail.groupId}</groupId>
+ <artifactId>${javax.mail.artifactId}</artifactId>
</dependency>
</dependencies>
</project>
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailProcessor.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.mailetcontainer.api;
+
+import org.apache.mailet.Mail;
+
+/**
+ * The <code>service</code> perform all needed work on the Mail object.
Whatever
+ * remains at the end of the service is considered to need futher processing
and
+ * will go to the next Mailet if there is one configured or will go to the
error
+ * processor if not. Setting a Mail state (setState(String)) to Mail.GHOST or
+ * cleaning its recipient list has the same meaning that s no more processing
is
+ * needed.
+ */
+public interface MailProcessor {
+ /**
+ * <p>
+ * Called by the mailet container to allow the mailet to process to a
+ * message.
+ * </p>
+ * <p>
+ * This method is only called after the mailet's init() method has
completed
+ * successfully.
+ * </p>
+ * <p>
+ * Mailets typically run inside multithreaded mailet containers that can
+ * handle multiple requests concurrently. Developers must be aware to
+ * synchronize access to any shared resources such as files, network
+ * connections, as well as the mailet's class and instance variables. More
+ * information on multithreaded programming in Java is available in <a
href=
+ *
"http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">the
+ * Java tutorial on multi-threaded programming</a>.
+ * </p>
+ *
+ * @param mail
+ * - the Mail object that contains the message and routing
+ * information
+ * @throws javax.mail.MessagingException
+ * - if a message or address parsing exception occurs or an
+ * exception that interferes with the mailet's normal operation
+ */
+ void service(Mail mail) throws javax.mail.MessagingException;
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MailetLoader.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.mailetcontainer.api;
+
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+import javax.mail.MessagingException;
+
+/**
+ * Implementations of this interface are responsible to create {@link Mailet}
+ * instances
+ */
+public interface MailetLoader {
+
+ /**
+ * Get a new {@link Mailet} instance for the given {@link MailetConfig}.
The
+ * returned {@link Mailet} needs to be fully initialized, so the returned
+ * instance is "read-to-use"
+ *
+ * @param config
+ * @throws MessagingException
+ * if an error occurs
+ */
+ Mailet getMailet(MailetConfig config) throws MessagingException;
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/MatcherLoader.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.mailetcontainer.api;
+
+import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
+
+import javax.mail.MessagingException;
+
+/**
+ * Implementations of this interface are responsible for loading {@link
Matcher}
+ * instances
+ */
+public interface MatcherLoader {
+
+ /**
+ * Get a new {@link Matcher} for the given {@link MatcherConfig}. The
+ * returned {@link Matcher} needs to be fully initialized, so the returned
+ * instance is "read-to-use"
+ *
+ * @param config
+ * @throws MessagingException
+ * if an error occurs
+ */
+ Matcher getMatcher(MatcherConfig config) throws MessagingException;
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailProcessorManagementMBean.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailProcessorManagementMBean.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailProcessorManagementMBean.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailProcessorManagementMBean.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,70 @@
+/****************************************************************
+ * 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.mailetcontainer.api.jmx;
+
+/**
+ * MBean for Mail processing components
+ */
+public interface MailProcessorManagementMBean {
+
+ /**
+ * Return the count of handled mail
+ *
+ * @return handledCount
+ */
+ long getHandledMailCount();
+
+ /**
+ * Return the time in ms of the fastest processing
+ *
+ * @return fastest
+ */
+ long getFastestProcessing();
+
+ /**
+ * Return the time in ms of the slowest processing
+ *
+ * @return slowest
+ */
+ long getSlowestProcessing();
+
+ /**
+ * Return the count of how many time the processing was done without and
+ * error
+ *
+ * @return successCount
+ */
+ long getSuccessCount();
+
+ /**
+ * Return the count of how many times an error was detected while
processing
+ *
+ * @return errorCount
+ */
+ long getErrorCount();
+
+ /**
+ * Return the time in ms of the last processing
+ *
+ * @return last
+ */
+ long getLastProcessing();
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailSpoolerMBean.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailSpoolerMBean.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailSpoolerMBean.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailSpoolerMBean.java
Mon Jun 27 10:42:20 2011
@@ -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.mailetcontainer.api.jmx;
+
+/**
+ * JMX MBean for MailSpooler
+ */
+public interface MailSpoolerMBean {
+
+ /**
+ * Return the number of threads used for spooling
+ *
+ * @return threadCount
+ */
+ int getThreadCount();
+
+ /**
+ *
+ * @return
+ */
+ int getCurrentSpoolCount();
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailetManagementMBean.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailetManagementMBean.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailetManagementMBean.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MailetManagementMBean.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.mailetcontainer.api.jmx;
+
+/**
+ * management interface for one Mailet instance
+ */
+public interface MailetManagementMBean extends MailProcessorManagementMBean {
+
+ /**
+ * Return the name of the mailet
+ *
+ * @return mailet
+ */
+ String getMailetName();
+
+ /**
+ * Return the parameters which are configured for the mailet
+ *
+ * @return params
+ */
+ String[] getMailetParameters();
+}
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/api/jmx/MatcherManagementMBean.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.mailetcontainer.api.jmx;
+
+/**
+ * management interface for one Matcher instance
+ */
+public interface MatcherManagementMBean extends MailProcessorManagementMBean {
+
+ /**
+ * Return the name of the Matcher
+ *
+ * @return name
+ */
+ String getMatcherName();
+
+ /**
+ * Return the matcher condition
+ *
+ * @return condition
+ */
+ String getMatcherCondition();
+
+ /**
+ * Return the count of how many times the Matcher matched
+ *
+ * @return matched
+ */
+ long getMatchedCount();
+
+ /**
+ * Return the count of how many times the Matcher not matches
+ *
+ * @return notmatched
+ */
+ long getNotMatchedCount();
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMailet.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+public class ExceptionThrowingMailet implements Mailet {
+
+ private MailetConfig config;
+
+ public void destroy() {
+
+ }
+
+ public MailetConfig getMailetConfig() {
+ return config;
+ }
+
+ public String getMailetInfo() {
+ return getClass().getName();
+ }
+
+ public void init(MailetConfig config) throws MessagingException {
+ this.config = config;
+ }
+
+ public void service(Mail arg0) throws MessagingException {
+ throw new MessagingException();
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/ExceptionThrowingMatcher.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import java.util.Collection;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
+
+public class ExceptionThrowingMatcher implements Matcher {
+
+ private MatcherConfig config;
+
+ public void destroy() {
+ }
+
+ public MatcherConfig getMatcherConfig() {
+ return config;
+ }
+
+ public String getMatcherInfo() {
+ return getClass().getName();
+ }
+
+ public void init(MatcherConfig config) throws MessagingException {
+ this.config = config;
+ }
+
+ public Collection match(Mail arg0) throws MessagingException {
+ throw new MessagingException();
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailProcessor.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import javax.mail.MessagingException;
+
+import org.apache.james.mailetcontainer.api.MailProcessor;
+import org.apache.mailet.Mail;
+
+public class MockMailProcessor implements MailProcessor {
+
+ private boolean shouldThrow = false;
+ private String newState = null;
+
+ public MockMailProcessor(boolean shouldThrow) {
+ this.shouldThrow = shouldThrow;
+ }
+
+ public MockMailProcessor(String newState) {
+ this.newState = newState;
+ }
+
+ public void service(Mail mail) throws MessagingException {
+ if (shouldThrow) {
+ throw new MessagingException();
+ } else {
+ mail.setState(newState);
+ }
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailet.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+public class MockMailet implements Mailet {
+
+ private MailetConfig config;
+
+ public void destroy() {
+ }
+
+ public MailetConfig getMailetConfig() {
+ return config;
+ }
+
+ public String getMailetInfo() {
+ return "";
+ }
+
+ public void init(MailetConfig config) throws MessagingException {
+ this.config = config;
+ }
+
+ public void service(Mail mail) throws MessagingException {
+ String state = config.getInitParameter("state");
+ mail.setState(state);
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetContext.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,163 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.mailet.HostAddress;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.MailetContext;
+
+public class MockMailetContext implements MailetContext {
+
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+ private List<Mail> mails = new ArrayList<Mail>();
+
+ public void bounce(Mail arg0, String arg1) throws MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+
+ }
+
+ public void bounce(Mail arg0, String arg1, MailAddress arg2) throws
MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+
+ }
+
+ public Object getAttribute(String arg0) {
+ return attributes.get(arg0);
+ }
+
+ public Iterator getAttributeNames() {
+ return attributes.keySet().iterator();
+ }
+
+ /**
+ * Return an {@link Collection} which holds "mx.localhost" if the given
host
+ * was "localhost". Otherwise and empty {@link Collection} is returned
+ */
+ public Collection getMailServers(String host) {
+ List<String> servers = new ArrayList<String>();
+ if ("localhost".equalsIgnoreCase(host)) {
+ servers.add("mx.localhost");
+ }
+ return servers;
+ }
+
+ public int getMajorVersion() {
+ return 0;
+ }
+
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ public MailAddress getPostmaster() {
+ try {
+ return new MailAddress("postmaster@localhost");
+ } catch (AddressException e) {
+ // will never happen
+ return null;
+ }
+ }
+
+ public Iterator getSMTPHostAddresses(String arg0) {
+ return new ArrayList<HostAddress>().iterator();
+ }
+
+ public String getServerInfo() {
+ return "Mock Server";
+ }
+
+ /**
+ * @see #isLocalUser(String)
+ */
+ public boolean isLocalEmail(MailAddress arg0) {
+ return isLocalUser(arg0.toString());
+ }
+
+ /**
+ * Return true if "localhost" was given
+ */
+ public boolean isLocalServer(String server) {
+ return "localhost".equalsIgnoreCase(server);
+ }
+
+ /**
+ * Return true if "localuser@localhost" was given
+ */
+ public boolean isLocalUser(String user) {
+ return "localuser@localhost".equalsIgnoreCase(user);
+ }
+
+ public void log(String msg) {
+ System.out.println(msg);
+ }
+
+ public void log(String arg0, Throwable arg1) {
+ System.out.println(arg0);
+ arg1.printStackTrace();
+
+ }
+
+ public void removeAttribute(String arg0) {
+ attributes.remove(arg0);
+ }
+
+ public void sendMail(MimeMessage arg0) throws MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+
+ }
+
+ public void sendMail(Mail mail) throws MessagingException {
+ mails.add(mail);
+ }
+
+ public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2)
throws MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+
+ }
+
+ public void sendMail(MailAddress arg0, Collection arg1, MimeMessage arg2,
String arg3) throws MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+
+ }
+
+ public void setAttribute(String arg0, Object arg1) {
+ attributes.put(arg0, arg1);
+ }
+
+ public void storeMail(MailAddress arg0, MailAddress arg1, MimeMessage
arg2) throws MessagingException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public List<Mail> getSentMails() {
+ return mails;
+ }
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMailetLoader.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,42 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import javax.mail.MessagingException;
+
+import org.apache.james.mailetcontainer.api.MailetLoader;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+public class MockMailetLoader implements MailetLoader {
+
+ @SuppressWarnings("unchecked")
+ public Mailet getMailet(MailetConfig config) throws MessagingException {
+ try {
+ Class<Mailet> clazz = (Class<Mailet>)
Thread.currentThread().getContextClassLoader().loadClass(config.getMailetName());
+ Mailet m = clazz.newInstance();
+ m.init(config);
+ return m;
+ } catch (Exception e) {
+ throw new MessagingException("Unable to load mailet " +
config.getMailetName());
+ }
+
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcher.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,72 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
+
+public class MockMatcher implements Matcher {
+
+ private int matchCount = 0;
+
+ private MatcherConfig config;
+
+ public void destroy() {
+
+ }
+
+ public MatcherConfig getMatcherConfig() {
+ return config;
+ }
+
+ public String getMatcherInfo() {
+ return getClass().getName();
+ }
+
+ public void init(MatcherConfig config) throws MessagingException {
+ this.config = config;
+ matchCount = Integer.parseInt(config.getCondition());
+ }
+
+ public Collection match(Mail mail) throws MessagingException {
+ List<MailAddress> match = new ArrayList<MailAddress>();
+
+ Iterator<MailAddress> rcpts = mail.getRecipients().iterator();
+ while (rcpts.hasNext() && match.size() < matchCount) {
+ MailAddress addr = rcpts.next();
+ match.add(addr);
+
+ }
+ if (match.isEmpty()) {
+ return null;
+ }
+ return match;
+ }
+
+}
Added:
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java?rev=1140094&view=auto
==============================================================================
---
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
(added)
+++
james/server/trunk/mailetcontainer-api/src/test/java/org/apache/james/mailetcontainer/api/mock/MockMatcherLoader.java
Mon Jun 27 10:42:20 2011
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.mailetcontainer.api.mock;
+
+import javax.mail.MessagingException;
+
+import org.apache.james.mailetcontainer.api.MatcherLoader;
+import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
+
+public class MockMatcherLoader implements MatcherLoader {
+
+ @SuppressWarnings("unchecked")
+ public Matcher getMatcher(MatcherConfig config) throws MessagingException {
+
+ try {
+ Class<Matcher> clazz = (Class<Matcher>)
Thread.currentThread().getContextClassLoader().loadClass(config.getMatcherName());
+ Matcher m = clazz.newInstance();
+ m.init(config);
+ return m;
+ } catch (Exception e) {
+ throw new MessagingException("Unable to load matcher " +
config.getMatcherName());
+ }
+
+ }
+
+}
Modified: james/server/trunk/mailetcontainer-camel/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/pom.xml?rev=1140094&r1=1140093&r2=1140094&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/pom.xml (original)
+++ james/server/trunk/mailetcontainer-camel/pom.xml Mon Jun 27 10:42:20 2011
@@ -91,6 +91,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-mailetcontainer-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: james/server/trunk/mailetcontainer-library/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/pom.xml?rev=1140094&r1=1140093&r2=1140094&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/pom.xml (original)
+++ james/server/trunk/mailetcontainer-library/pom.xml Mon Jun 27 10:42:20 2011
@@ -68,6 +68,10 @@ Parent pom build failure prevents inheri
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-mailetcontainer-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-queue-api</artifactId>
</dependency>
<dependency>
@@ -112,5 +116,11 @@ Parent pom build failure prevents inheri
<artifactId>apache-standard-mailets</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-mailetcontainer-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: james/server/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=1140094&r1=1140093&r2=1140094&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Mon Jun 27 10:42:20 2011
@@ -625,6 +625,13 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-mailetcontainer-api</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-mailetcontainer-library</artifactId>
<version>${project.version}</version>
</dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]