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/10/13 18:51:47 UTC
svn commit: r1022183 - in /james/server/trunk: core-library/
mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/
mailetcontainer-camel/
mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/
mailetcontainer-impl/src...
Author: norman
Date: Wed Oct 13 16:51:40 2010
New Revision: 1022183
URL: http://svn.apache.org/viewvc?rev=1022183&view=rev
Log:
Some work to expose processor/mailet/matcher stuff via JMX. Not complete yet (JAMES-1057)
Added:
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailProcessingMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailetManagementMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MatcherManagementMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorDetailMBean.java
james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorManagementMBean.java
james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MailetMBeanWrapper.java
james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherManagement.java
Removed:
james/server/trunk/management/src/main/java/org/apache/james/management/ProcessorManagementMBean.java
james/server/trunk/management/src/main/java/org/apache/james/management/ProcessorManagementService.java
james/server/trunk/management/src/main/java/org/apache/james/management/impl/ProcessorManagement.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/MailetManagement.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/MailetManagementMBean.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/MatcherManagement.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/MatcherManagementMBean.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/ProcessorDetail.java
james/server/trunk/management/src/main/java/org/apache/james/management/mbean/ProcessorDetailMBean.java
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListMailetsCmdHandler.java
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListMatchersCmdHandler.java
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ListProcessorsCmdHandler.java
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ShowMailetInfoCmdHandler.java
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/ShowMatcherInfoCmdHandler.java
Modified:
james/server/trunk/core-library/pom.xml
james/server/trunk/mailetcontainer-camel/pom.xml
james/server/trunk/mailetcontainer-camel/src/main/java/org/apache/james/mailetcontainer/camel/CamelMailProcessorList.java
james/server/trunk/management/pom.xml
james/server/trunk/netty-socket/pom.xml
james/server/trunk/queue-activemq/pom.xml
james/server/trunk/queue-jms/pom.xml
james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/CoreCmdHandlerLoader.java
james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
james/server/trunk/spring-common/pom.xml
james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
Modified: james/server/trunk/core-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/core-library/pom.xml (original)
+++ james/server/trunk/core-library/pom.xml Wed Oct 13 16:51:40 2010
@@ -34,14 +34,6 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-dnsservice-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-domain-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>james-server-common-util</artifactId>
</dependency>
@@ -84,11 +76,6 @@
<!-- Test dependencies -->
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-user-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>apache-mailet-base</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailProcessingMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailProcessingMBean.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailProcessingMBean.java (added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailProcessingMBean.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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;
+
+public interface MailProcessingMBean {
+
+ public long getHandledMailCount();
+
+ public long getFastestProcessing();
+
+ public long getSlowestProcessing();
+
+ public long getSuccessCount();
+
+ public long getErrorCount();
+
+}
Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailetManagementMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailetManagementMBean.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailetManagementMBean.java (added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MailetManagementMBean.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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;
+
+/**
+ * management interface for one Mailet instance
+ */
+public interface MailetManagementMBean extends MailProcessingMBean{
+
+ public String getMailetName();
+
+ public String[] getMailetParameters();
+}
Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MatcherManagementMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MatcherManagementMBean.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MatcherManagementMBean.java (added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/MatcherManagementMBean.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,28 @@
+/****************************************************************
+ * 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;
+
+/**
+ * management interface for one Matcher instance
+ */
+public interface MatcherManagementMBean {
+ String getMatcherName();
+ String getMatcherCondition();
+}
Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorDetailMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorDetailMBean.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorDetailMBean.java (added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorDetailMBean.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,31 @@
+/****************************************************************
+ * 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;
+
+
+/**
+ * MBean for one processor instance
+ */
+public interface ProcessorDetailMBean extends MailProcessingMBean{
+
+ public String getName();
+
+
+
+}
Added: james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorManagementMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorManagementMBean.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorManagementMBean.java (added)
+++ james/server/trunk/mailetcontainer-api/src/main/java/org/apache/james/mailetcontainer/ProcessorManagementMBean.java Wed Oct 13 16:51:40 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.mailetcontainer;
+
+/**
+ * Expose processor management functionality through JMX.
+ *
+ * @phoenix:mx-topic name="ProcessorAdministration"
+ */
+public interface ProcessorManagementMBean {
+
+ /**
+ * Retrieves all existing processors
+ *
+ * @phoenix:mx-operation
+ * @phoenix:mx-description Retrieves all existing processors
+ *
+ * @return names of all configured processors
+ */
+ String[] getProcessorNames();
+
+}
Modified: james/server/trunk/mailetcontainer-camel/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-camel/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-camel/pom.xml (original)
+++ james/server/trunk/mailetcontainer-camel/pom.xml Wed Oct 13 16:51:40 2010
@@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
+ <artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
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=1022183&r1=1022182&r2=1022183&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 13 16:51:40 2010
@@ -29,6 +29,9 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.mail.MessagingException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
@@ -49,28 +52,33 @@ import org.apache.james.mailetcontainer.
import org.apache.james.mailetcontainer.MailetConfigImpl;
import org.apache.james.mailetcontainer.MailetContainer;
import org.apache.james.mailetcontainer.MailetLoader;
+import org.apache.james.mailetcontainer.MailetMBeanWrapper;
import org.apache.james.mailetcontainer.MatcherLoader;
+import org.apache.james.mailetcontainer.MatcherManagement;
+import org.apache.james.mailetcontainer.ProcessorDetailMBean;
+import org.apache.james.mailetcontainer.ProcessorManagementMBean;
import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
import org.apache.mailet.Matcher;
+import org.apache.mailet.MatcherConfig;
import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.base.MatcherInverter;
/**
- * Build up the Camel Routes by parsing the spoolmanager.xml configuration file.
+ * 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
*
*/
-public class CamelMailProcessorList implements Configurable, LogEnabled, MailProcessorList, CamelContextAware {
+public class CamelMailProcessorList implements Configurable, LogEnabled, MailProcessorList, CamelContextAware, ProcessorManagementMBean {
private MatcherLoader matcherLoader;
private HierarchicalConfiguration config;
private MailetLoader mailetLoader;
private Log logger;
- private final Map<String,List<Mailet>> mailets = new HashMap<String,List<Mailet>>();
+ private final Map<String,List<MailetMBeanWrapper>> mailets = new HashMap<String,List<MailetMBeanWrapper>>();
private final Map<String,List<Matcher>> matchers = new HashMap<String,List<Matcher>>();
private final Map<String,MailProcessor> processors = new HashMap<String,MailProcessor>();
private final UseLatestAggregationStrategy aggr = new UseLatestAggregationStrategy();
@@ -87,14 +95,24 @@ public class CamelMailProcessorList impl
private ProducerTemplate producerTemplate;
private CamelContext camelContext;
+ private MBeanServer mbeanserver;
@PostConstruct
- public void init() throws Exception {
- getCamelContext().addRoutes(new SpoolRouteBuilder());
- producerTemplate = getCamelContext().createProducerTemplate();
- }
+ public void init() throws Exception {
+ getCamelContext().addRoutes(new SpoolRouteBuilder());
+ producerTemplate = getCamelContext().createProducerTemplate();
+
+ registerMBeans();
+
+ }
+
+ @Resource(name = "mbeanserver")
+ public void setMbeanServer(MBeanServer mbeanServer) {
+ this.mbeanserver = mbeanServer;
+ }
+
/**
* Destroy all mailets and matchers
@@ -103,11 +121,11 @@ public class CamelMailProcessorList impl
public void dispose() {
boolean debugEnabled = logger.isDebugEnabled();
- Iterator<List<Mailet>> it = mailets.values().iterator();
+ Iterator<List<MailetMBeanWrapper>> it = mailets.values().iterator();
while (it.hasNext()) {
- List<Mailet> mList = it.next();
+ List<MailetMBeanWrapper> mList = it.next();
for (int i = 0; i < mList.size(); i++) {
- Mailet m = mList.get(i);
+ Mailet m = mList.get(i).getMailet();
if (debugEnabled) {
logger.debug("Shutdown mailet " + m.getMailetInfo());
}
@@ -251,17 +269,20 @@ public class CamelMailProcessorList impl
private final class RemovePropertiesProcessor implements Processor {
- public void process(Exchange exchange) throws Exception {
- exchange.removeProperty(MatcherSplitter.ON_MATCH_EXCEPTION_PROPERTY);
- exchange.removeProperty(MatcherSplitter.MATCHER_PROPERTY);
- }
+ public void process(Exchange exchange) throws Exception {
+ exchange.removeProperty(MatcherSplitter.ON_MATCH_EXCEPTION_PROPERTY);
+ exchange.removeProperty(MatcherSplitter.MATCHER_PROPERTY);
+ }
}
- private final class ChildMailProcessor implements MailProcessor, MailetContainer {
-
+ private final class ChildMailProcessor implements MailProcessor, MailetContainer, ProcessorDetailMBean {
private String processorName;
-
+ private long slowestProcessing = -1;
+ private long fastestProcessing = -1;
+ private long successCount = 0;
+ private long errorCount = 0;
+
public ChildMailProcessor(String processorName) {
this.processorName = processorName;
}
@@ -272,9 +293,21 @@ public class CamelMailProcessorList impl
* @see org.apache.james.transport.MailProcessor#service(org.apache.mailet.Mail)
*/
public void service(Mail mail) throws MessagingException {
- try {
- producerTemplate.sendBody(getEndpoint(processorName), mail);
+ try {
+ long startProcessing = System.currentTimeMillis();
+
+ producerTemplate.sendBody(getEndpoint(processorName), mail);
+
+ long processTime = System.currentTimeMillis() - startProcessing;
+ if (processTime > slowestProcessing) {
+ slowestProcessing = processTime;
+ }
+ if (fastestProcessing == -1 || fastestProcessing > processTime) {
+ fastestProcessing = processTime;
+ }
+ successCount++;
} catch (CamelExecutionException ex) {
+ errorCount++;
throw new MessagingException("Unable to process mail " + mail.getName(),ex);
}
}
@@ -284,7 +317,7 @@ public class CamelMailProcessorList impl
* @see org.apache.james.transport.MailetContainer#getMailets()
*/
public List<Mailet> getMailets() {
- return mailets.get(processorName);
+ return new ArrayList<Mailet>(mailets.get(processorName));
}
/*
@@ -294,17 +327,135 @@ public class CamelMailProcessorList impl
public List<Matcher> getMatchers() {
return matchers.get(processorName);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.james.mailetcontainer.ProcessorDetailMBean#getHandledMailCount
+ * ()
+ */
+ public long getHandledMailCount() {
+ return getSuccessCount() + getErrorCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.james.mailetcontainer.ProcessorDetailMBean#getName()
+ */
+ public String getName() {
+ return processorName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.james.mailetcontainer.ProcessorDetailMBean#
+ * getFastestProcessing()
+ */
+ public long getFastestProcessing() {
+ return fastestProcessing;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.james.mailetcontainer.ProcessorDetailMBean#
+ * getSlowestProcessing()
+ */
+ public long getSlowestProcessing() {
+ return slowestProcessing;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.james.mailetcontainer.ProcessorDetailMBean#getErrorCount()
+ */
+ public long getErrorCount() {
+ return errorCount;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.james.mailetcontainer.ProcessorDetailMBean#getSuccessCount
+ * ()
+ */
+ public long getSuccessCount() {
+ return successCount;
+ }
}
public CamelContext getCamelContext() {
- return camelContext;
- }
+ return camelContext;
+ }
- public void setCamelContext(CamelContext camelContext) {
- this.camelContext = camelContext;
- }
-
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+
+ private void registerMBeans() {
+
+ String baseObjectName = "org.apache.james:type=component,name=processor,";
+
+ String[] processorNames = getProcessorNames();
+ for (int i = 0; i < processorNames.length; i++) {
+ String processorName = processorNames[i];
+ createProcessorMBean(baseObjectName, processorName, mbeanserver);
+ continue;
+ }
+ }
+
+ private void createProcessorMBean(String baseObjectName, String processorName, MBeanServer mBeanServer) {
+ String processorMBeanName = baseObjectName + "processor=" + processorName;
+ registerMBean(mBeanServer, processorMBeanName, (ProcessorDetailMBean) getProcessor(processorName));
+
+
+ // add all mailets but the last, because that is a terminator (see LinearProcessor.closeProcessorLists())
+ List<MailetMBeanWrapper> mailets = this.mailets.get(processorName);
+ for (int i = 0; i < mailets.size()-1; i++) {
+ MailetMBeanWrapper mailet = mailets.get(i);
+
+ String mailetMBeanName = processorMBeanName + ",subtype=mailet,index=" + (i+1) + ",mailetname=" + mailet.getMailetName();
+ registerMBean(mBeanServer, mailetMBeanName, mailet);
+ }
+
+
+ // add all matchers but the last, because that is a terminator (see LinearProcessor.closeProcessorLists())
+ List<Matcher> matchers = ((MailetContainer)getProcessor(processorName)).getMatchers();
+ for (int i = 0; i < matchers.size()-1; i++) {
+ MatcherConfig matcherConfig = matchers.get(i).getMatcherConfig();
+
+ String matcherMBeanName = processorMBeanName + ",subtype=matcher,index=" + (i+1) + ",matchername=" + matcherConfig.getMatcherName();
+ MatcherManagement matcherMBean = new MatcherManagement(matcherConfig);
+ registerMBean(mBeanServer, matcherMBeanName, matcherMBean);
+ }
+
+ }
+
+ private void registerMBean(MBeanServer mBeanServer, String mBeanName, Object object) {
+ ObjectName objectName = null;
+ try {
+ objectName = new ObjectName(mBeanName);
+ } catch (MalformedObjectNameException e) {
+ logger.info("Unable to register mbean", e);
+
+ return;
+ }
+ try {
+ mBeanServer.registerMBean(object, objectName);
+ } catch (javax.management.JMException e) {
+ logger.info("Unable to register mbean", e);
+ }
+ }
+
+
private final class SpoolRouteBuilder extends RouteBuilder {
/*
* (non-Javadoc)
@@ -324,7 +475,7 @@ public class CamelMailProcessorList impl
String processorName = processorConf.getString("[@name]");
- mailets.put(processorName, new ArrayList<Mailet>());
+ mailets.put(processorName, new ArrayList<MailetMBeanWrapper>());
matchers.put(processorName, new ArrayList<Matcher>());
RouteDefinition processorDef = from(getEndpoint(processorName)).inOnly()
@@ -400,28 +551,30 @@ public class CamelMailProcessorList impl
throw new ConfigurationException("Unable to init mailet", ex);
}
if (mailet != null && matcher != null) {
+ MailetMBeanWrapper wrappedMailet = new MailetMBeanWrapper(mailet);
String onMatchException = null;
- MailetConfig mailetConfig = mailet.getMailetConfig();
+ MailetConfig mailetConfig = wrappedMailet.getMailetConfig();
if (mailetConfig instanceof MailetConfigImpl) {
onMatchException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMatchException");
}
+ MailetProcessor mailetProccessor = new MailetProcessor(wrappedMailet, logger);
// Store the matcher to use for splitter in properties
processorDef
- .setProperty(MatcherSplitter.MATCHER_PROPERTY, constant(matcher)).setProperty(MatcherSplitter.ON_MATCH_EXCEPTION_PROPERTY, constant(onMatchException))
+ .setProperty(MatcherSplitter.MATCHER_PROPERTY, constant(matcher)).setProperty(MatcherSplitter.ON_MATCH_EXCEPTION_PROPERTY, constant(onMatchException))
// do splitting of the mail based on the stored matcher
.split().method(MatcherSplitter.class).aggregationStrategy(aggr).parallelProcessing()
- .choice().when(new MatcherMatch()).process(new MailetProcessor(mailet, logger)).end()
+ .choice().when(new MatcherMatch()).process(mailetProccessor).end()
.choice().when(new MailStateEquals(Mail.GHOST)).process(disposeProcessor).stop().otherwise().process(removePropsProcessor).end()
.choice().when(new MailStateNotEquals(processorName)).process(mailProcessor).stop().end();
// store mailet and matcher
- mailets.get(processorName).add(mailet);
+ mailets.get(processorName).add(wrappedMailet);
matchers.get(processorName).add(matcher);
}
@@ -448,5 +601,4 @@ public class CamelMailProcessorList impl
}
}
-
}
Added: james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MailetMBeanWrapper.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MailetMBeanWrapper.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MailetMBeanWrapper.java (added)
+++ james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MailetMBeanWrapper.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,178 @@
+/****************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.mail.MessagingException;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+
+/**
+ * Class which wraps a {@link Mailet} and expose statistics via JMX
+ *
+ *
+ *
+ *
+ */
+public final class MailetMBeanWrapper implements Mailet, MailetManagementMBean{
+
+ private final Mailet mailet;
+ private long errorCount = 0;
+ private long successCount = 0;
+ private long fastestProcessing = -1;
+ private long slowestProcessing = -1;
+
+ public MailetMBeanWrapper(final Mailet mailet) {
+ this.mailet = mailet;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.mailet.Mailet#destroy()
+ */
+ public void destroy() {
+ mailet.destroy();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.mailet.Mailet#getMailetConfig()
+ */
+ public MailetConfig getMailetConfig() {
+ return mailet.getMailetConfig();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.mailet.Mailet#getMailetInfo()
+ */
+ public String getMailetInfo() {
+ return mailet.getMailetInfo();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.mailet.Mailet#init(org.apache.mailet.MailetConfig)
+ */
+ public void init(MailetConfig config) throws MessagingException {
+ mailet.init(config);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.mailet.Mailet#service(org.apache.mailet.Mail)
+ */
+ public void service(Mail mail) throws MessagingException {
+ long startProcessing = System.currentTimeMillis();
+ try {
+ mailet.service(mail);
+ long processTime = System.currentTimeMillis() - startProcessing;
+ if (processTime > slowestProcessing) {
+ slowestProcessing = processTime;
+ }
+ if (fastestProcessing == -1 || fastestProcessing > processTime) {
+ fastestProcessing = processTime;
+ }
+ successCount++;
+ } catch (MessagingException e) {
+ errorCount++;
+ throw e;
+ }
+ }
+
+ /**
+ * Return the wrapped {@link Mailet}
+ *
+ * @return mailet
+ */
+ public Mailet getMailet() {
+ return mailet;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getMailetName()
+ */
+ public String getMailetName() {
+ return mailet.getMailetConfig().getMailetName();
+ }
+
+ /*
+ *
+ */
+ @SuppressWarnings("unchecked")
+ public String[] getMailetParameters() {
+ List<String> parameterList = new ArrayList<String>();
+ MailetConfig mailetConfig = getMailet().getMailetConfig();
+ Iterator<String> iterator = mailetConfig.getInitParameterNames();
+ while (iterator.hasNext()) {
+ String name = (String) iterator.next();
+ String value = mailetConfig.getInitParameter(name);
+ parameterList.add(name + "=" + value);
+ }
+ String[] result = (String[]) parameterList.toArray(new String[] {});
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getErrorCount()
+ */
+ public long getErrorCount() {
+ return errorCount;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getFastestProcessing()
+ */
+ public long getFastestProcessing() {
+ return fastestProcessing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getHandledMailCount()
+ */
+ public long getHandledMailCount() {
+ return getErrorCount() + getSuccessCount();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getSlowestProcessing()
+ */
+ public long getSlowestProcessing() {
+ return slowestProcessing;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailetcontainer.MailetManagementMBean#getSuccessCount()
+ */
+ public long getSuccessCount() {
+ return successCount;
+ }
+
+}
Added: james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherManagement.java?rev=1022183&view=auto
==============================================================================
--- james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherManagement.java (added)
+++ james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherManagement.java Wed Oct 13 16:51:40 2010
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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;
+
+import org.apache.mailet.MatcherConfig;
+
+public class MatcherManagement implements MatcherManagementMBean {
+ private MatcherConfig matcherConfig;
+
+ public MatcherManagement(MatcherConfig matcherConfig) {
+ this.matcherConfig = matcherConfig;
+ }
+
+ public String getMatcherName() {
+ return matcherConfig.getMatcherName();
+ }
+
+ public String getMatcherCondition() {
+ return matcherConfig.getCondition();
+ }
+}
+
Modified: james/server/trunk/management/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/management/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/management/pom.xml (original)
+++ james/server/trunk/management/pom.xml Wed Oct 13 16:51:40 2010
@@ -34,10 +34,6 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-domain-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>james-server-core-api</artifactId>
</dependency>
<dependency>
Modified: james/server/trunk/netty-socket/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/netty-socket/pom.xml (original)
+++ james/server/trunk/netty-socket/pom.xml Wed Oct 13 16:51:40 2010
@@ -90,10 +90,6 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-core-library</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>james-server-dnsservice-api</artifactId>
</dependency>
<dependency>
@@ -116,5 +112,10 @@
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: james/server/trunk/queue-activemq/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/pom.xml (original)
+++ james/server/trunk/queue-activemq/pom.xml Wed Oct 13 16:51:40 2010
@@ -38,10 +38,6 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>james-server-core-library</artifactId>
</dependency>
<dependency>
@@ -59,10 +55,6 @@
<version>5.4.1</version>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
</dependency>
@@ -70,9 +62,5 @@
<groupId>${javax.mail.groupId}</groupId>
<artifactId>${javax.mail.artifactId}</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- </dependency>
</dependencies>
</project>
Modified: james/server/trunk/queue-jms/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-jms/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/queue-jms/pom.xml (original)
+++ james/server/trunk/queue-jms/pom.xml Wed Oct 13 16:51:40 2010
@@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
+ <artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
Modified: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/CoreCmdHandlerLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/CoreCmdHandlerLoader.java?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/CoreCmdHandlerLoader.java (original)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/core/CoreCmdHandlerLoader.java Wed Oct 13 16:51:40 2010
@@ -41,10 +41,7 @@ public class CoreCmdHandlerLoader implem
private final static String IMPORTBAYESIANDATACMDHANDLER = ImportBayesianDataCmdHandler.class.getName();
private final static String LISTALLMAPPINGSCMDHANDLER = ListAllMappingsCmdHandler.class.getName();
private final static String LISTDOMAINSCMDHANDLER = ListDomainsCmdHandler.class.getName();
- private final static String LISTMAILETSCMDHANDLER = ListMailetsCmdHandler.class.getName();
private final static String LISTMAPPINGCMDHANDLER = ListMappingCmdHandler.class.getName();
- private final static String LISTMATCHERSCMDHANDLER = ListMatchersCmdHandler.class.getName();
- private final static String LISTPROCESSORSCMDHANDLER = ListProcessorsCmdHandler.class.getName();
//private final static String LISTSPOOLCMDHANDLER = ListSpoolCmdHandler.class.getName();
private final static String LISTUSERSCMDHANDLER = ListUsersCmdHandler.class.getName();
private final static String MEMSTATCMDHANDLER = MemStatCmdHandler.class.getName();
@@ -56,8 +53,6 @@ public class CoreCmdHandlerLoader implem
private final static String SETPASSWORDCMDHANDLER = SetPasswordCmdHandler.class.getName();
private final static String SHOWALIASCMDHANDLER = ShowAliasCmdHandler.class.getName();
private final static String SHOWFORWARDINGCMDHANDLER = ShowForwardingCmdHandler.class.getName();
- private final static String SHOWMAILETINFOCMDHANDLER = ShowMailetInfoCmdHandler.class.getName();
- private final static String SHOWMATCHERINFOCMDHANDLER = ShowMatcherInfoCmdHandler.class.getName();
private final static String SHUTDOWNCMDHANDLER = ShutdownCmdHandler.class.getName();
private final static String UNKNOWNCMDHANDLER = UnknownCmdHandler.class.getName();
private final static String UNSETALIASCMDHANDLER = UnsetAliasCmdHandler.class.getName();
@@ -86,10 +81,7 @@ public class CoreCmdHandlerLoader implem
commands.add(IMPORTBAYESIANDATACMDHANDLER);
commands.add(LISTALLMAPPINGSCMDHANDLER);
commands.add(LISTDOMAINSCMDHANDLER);
- commands.add(LISTMAILETSCMDHANDLER);
commands.add(LISTMAPPINGCMDHANDLER);
- commands.add(LISTMATCHERSCMDHANDLER);
- commands.add(LISTPROCESSORSCMDHANDLER);
//commands.add(LISTSPOOLCMDHANDLER);
commands.add(LISTUSERSCMDHANDLER);
commands.add(MEMSTATCMDHANDLER);
@@ -101,8 +93,6 @@ public class CoreCmdHandlerLoader implem
commands.add(SETPASSWORDCMDHANDLER);
commands.add(SHOWALIASCMDHANDLER);
commands.add(SHOWFORWARDINGCMDHANDLER);
- commands.add(SHOWMAILETINFOCMDHANDLER);
- commands.add(SHOWMATCHERINFOCMDHANDLER);
commands.add(SHUTDOWNCMDHANDLER);
commands.add(UNKNOWNCMDHANDLER);
commands.add(UNSETALIASCMDHANDLER);
Modified: james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java (original)
+++ james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java Wed Oct 13 16:51:40 2010
@@ -47,7 +47,6 @@ import org.apache.james.lifecycle.Lifecy
import org.apache.james.mailstore.MockMailStore;
import org.apache.james.management.BayesianAnalyzerManagementException;
import org.apache.james.management.BayesianAnalyzerManagementService;
-import org.apache.james.management.ProcessorManagementService;
import org.apache.james.management.SpoolFilter;
import org.apache.james.management.SpoolManagementException;
import org.apache.james.management.SpoolManagementService;
@@ -277,36 +276,7 @@ public abstract class AbstractRemoteMana
}
});
serviceManager.put("mailStore", new MockMailStore());
- serviceManager.put("processormanagement",
- new ProcessorManagementService() {
-
- public String[] getProcessorNames() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getMatcherParameters(String processorName,
- int matcherIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getMatcherNames(String processorName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getMailetParameters(String processorName,
- int mailetIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String[] getMailetNames(String processorName) {
- // TODO Auto-generated method stub
- return null;
- }
- });
+
}
private DNSService setUpDNSServer() {
Modified: james/server/trunk/spring-common/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-common/pom.xml?rev=1022183&r1=1022182&r2=1022183&view=diff
==============================================================================
--- james/server/trunk/spring-common/pom.xml (original)
+++ james/server/trunk/spring-common/pom.xml Wed Oct 13 16:51:40 2010
@@ -93,10 +93,6 @@
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>jsr250-api</artifactId>
- </dependency>
- <dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
</dependency>
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=1022183&r1=1022182&r2=1022183&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 Wed Oct 13 16:51:40 2010
@@ -53,7 +53,9 @@
</property>
</bean>
- <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" />
+ <bean id="mbeanserver" class="org.springframework.jmx.support.MBeanServerFactoryBean" >
+ <property name="locateExistingServerIfPossible" value="true"/>
+ </bean>
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="1099" />
@@ -179,13 +181,6 @@
<bean id="dnsservice" class="org.apache.james.dnsservice.dnsjava.DNSJavaService" />
- <!-- The Spool Management block -->
- <!--
- <bean id="spoolmanagement" class="org.apache.james.management.impl.SpoolManagement" />
- -->
-
- <bean id="processormanagement" class="org.apache.james.management.impl.ProcessorManagement" />
-
<bean id="bayesiananalyzermanagement" class="org.apache.james.management.impl.BayesianAnalyzerManagement" />
<!-- Async RemoteManager -->
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org