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/12/31 14:59:30 UTC

svn commit: r1054112 - in /james/server/trunk: container-spring/src/main/config/james/ container-spring/src/main/config/james/context/ container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ lmtpserver/src/main/java/...

Author: norman
Date: Fri Dec 31 13:59:29 2010
New Revision: 1054112

URL: http://svn.apache.org/viewvc?rev=1054112&view=rev
Log:
Make it more transparent to the user to enable / disable jmx support the handlerchain. See JAMES-1166

Added:
    james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
Modified:
    james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
    james/server/trunk/container-spring/src/main/config/james/lmtpserver.xml
    james/server/trunk/container-spring/src/main/config/james/pop3server.xml
    james/server/trunk/container-spring/src/main/config/james/smtpserver.xml
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java

Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1054112&r1=1054111&r2=1054112&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Fri Dec 31 13:59:29 2010
@@ -247,6 +247,7 @@
     </bean>
     <bean id="smtpProtocolHandlerChain" class="org.apache.james.container.spring.bean.postprocessor.ProtocolHandlerChainPostProcessor">
         <property name="coreHandlersPackage" value="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        <property name="jmxHandlersPackage" value="org.apache.james.smtpserver.jmx.JMXHandlersLoader"/>
         <property name="beanName" value="smtpserver"/>
     </bean>
 
@@ -258,6 +259,7 @@
     </bean>
     <bean id="lmtpProtocolHandlerChain" class="org.apache.james.container.spring.bean.postprocessor.ProtocolHandlerChainPostProcessor">
         <property name="coreHandlersPackage" value="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+        <property name="jmxHandlersPackage" value="org.apache.james.lmtpserver.jmx.JMXHandlersLoader"/>
         <property name="beanName" value="lmtpserver"/>
     </bean>
 
@@ -269,6 +271,7 @@
     </bean>
     <bean id="pop3ProtocolHandlerChain" class="org.apache.james.container.spring.bean.postprocessor.ProtocolHandlerChainPostProcessor">
         <property name="coreHandlersPackage" value="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+        <property name="jmxHandlersPackage" value="org.apache.james.pop3server.jmx.JMXHandlersLoader"/>
         <property name="beanName" value="pop3server"/>
     </bean>
 

Modified: james/server/trunk/container-spring/src/main/config/james/lmtpserver.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/lmtpserver.xml?rev=1054112&r1=1054111&r2=1054112&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/lmtpserver.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/lmtpserver.xml Fri Dec 31 13:59:29 2010
@@ -29,13 +29,8 @@
       <connectionLimit> 0 </connectionLimit>
       <connectionLimitPerIP> 0 </connectionLimitPerIP>
       <maxmessagesize>0</maxmessagesize>
-      <handlerchain>
+      <handlerchain enableJmx="true">
           <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
-          
-          <!-- jmx stats -->
-          <handler class="org.apache.james.lmtpserver.jmx.CommandHandlerResultJMXMonitor"/>
-          <handler class="org.apache.james.lmtpserver.jmx.ConnectHandlerResultJMXMonitor"/>
-          <handler class="org.apache.james.lmtpserver.jmx.LineHandlerResultJMXMonitor"/>
       </handlerchain>
   </handler>
 </lmtpserver>

Modified: james/server/trunk/container-spring/src/main/config/james/pop3server.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/pop3server.xml?rev=1054112&r1=1054111&r2=1054112&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/pop3server.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/pop3server.xml Fri Dec 31 13:59:29 2010
@@ -32,13 +32,8 @@
       <connectiontimeout>1200</connectiontimeout>
       <connectionLimit> 0 </connectionLimit>
       <connectionLimitPerIP> 0 </connectionLimitPerIP>
-      <handlerchain>
+      <handlerchain enableJmx="true">
           <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
-          
-         <!-- jmx stats -->
-         <handler class="org.apache.james.pop3server.jmx.CommandHandlerResultJMXMonitor"/>
-         <handler class="org.apache.james.pop3server.jmx.ConnectHandlerResultJMXMonitor"/>
-         <handler class="org.apache.james.pop3server.jmx.LineHandlerResultJMXMonitor"/>
       </handlerchain>
   </handler>
 </pop3server>

Modified: james/server/trunk/container-spring/src/main/config/james/smtpserver.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/smtpserver.xml?rev=1054112&r1=1054111&r2=1054112&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/smtpserver.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/smtpserver.xml Fri Dec 31 13:59:29 2010
@@ -32,14 +32,9 @@
      <authRequired>true</authRequired>
      <maxmessagesize>0</maxmessagesize>
      <addressBracketsEnforcement>true</addressBracketsEnforcement>
-     <handlerchain>
+     <handlerchain enableJmx="true">
          <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
-         <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
-         <!-- jmx stats -->
-         <handler class="org.apache.james.smtpserver.jmx.CommandHandlerResultJMXMonitor"/>
-         <handler class="org.apache.james.smtpserver.jmx.ConnectHandlerResultJMXMonitor"/>
-         <handler class="org.apache.james.smtpserver.jmx.LineHandlerResultJMXMonitor"/>
-         <handler class="org.apache.james.smtpserver.jmx.HookResultJMXMonitor"/>         
+         <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>       
      </handlerchain>            
   </handler>
 </smtpserver>

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java?rev=1054112&r1=1054111&r2=1054112&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java (original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/ProtocolHandlerChainFactoryPostProcessor.java Fri Dec 31 13:59:29 2010
@@ -62,6 +62,8 @@ public abstract class ProtocolHandlerCha
     private List<String> handlers = new LinkedList<String>();
     
     private String beanname;
+
+    private String jmxHandlersPackage;
     
     /**
      * Lookup the {@link HierarchicalConfiguration} for the beanname which was 
@@ -81,6 +83,7 @@ public abstract class ProtocolHandlerCha
             Log log = logProvider.getLog(beanname);
             
             HierarchicalConfiguration config = confProvider.getConfiguration(beanname);
+            
             HierarchicalConfiguration handlerchainConfig = config.configurationAt("handler.handlerchain");
             List<org.apache.commons.configuration.HierarchicalConfiguration> children = handlerchainConfig.configurationsAt("handler");
 
@@ -99,18 +102,21 @@ public abstract class ProtocolHandlerCha
             registry.registerBeanDefinition(coreCmdBeanName, def);
             HandlersPackage handlersPackage = beanFactory.getBean(coreCmdBeanName, HandlersPackage.class);
 
-            List<String> c = handlersPackage.getHandlers();
+            registerHandlersPackage(handlersPackage,children);
+          
+            String jmxCmdName = jmxHandlersPackage;
+            
+            if (handlerchainConfig.getBoolean("[@enableJmx]", true)) {
+                String jmxCmdBeanName = getBeanName(jmxCmdName);
 
-            for (Iterator<String> i = c.iterator(); i.hasNext();) {
-                String cName = i.next();
+                // now register the HandlerPackage for jmx
+                BeanDefinition jmxDef = BeanDefinitionBuilder.genericBeanDefinition(jmxCmdName).setLazyInit(false).getBeanDefinition();
+                registry.registerBeanDefinition(jmxCmdBeanName, jmxDef);
+                HandlersPackage jmxPackage = beanFactory.getBean(jmxCmdBeanName, HandlersPackage.class);
 
-                try {
-                    HierarchicalConfiguration cmdConf = addHandler(cName);
-                    children.add(cmdConf);
-                } catch (ConfigurationException e) {
-                    throw new FatalBeanException("Unable to create configuration for handler " + cName, e);
-                }
+                registerHandlersPackage(jmxPackage,children);
             }
+            
 
             for (int i = 0; i < children.size(); i++) {
                 HierarchicalConfiguration hConf = children.get(i);
@@ -142,12 +148,31 @@ public abstract class ProtocolHandlerCha
             throw new FatalBeanException("Unable to load configuration for bean " + beanname, e);
         }
 
+        
+    }
+    private void registerHandlersPackage(HandlersPackage handlersPackage, List<HierarchicalConfiguration> children) {
+        List<String> c = handlersPackage.getHandlers();
+
+        for (Iterator<String> i = c.iterator(); i.hasNext();) {
+            String cName = i.next();
+
+            try {
+                HierarchicalConfiguration cmdConf = addHandler(cName);
+                children.add(cmdConf);
+            } catch (ConfigurationException e) {
+                throw new FatalBeanException("Unable to create configuration for handler " + cName, e);
+            }
+        }
     }
 
     public void setCoreHandlersPackage(String coreHandlersPackage) {
         this.coreHandlersPackage = coreHandlersPackage;
     }
 
+    public void setJmxHandlersPackage(String jmxHandlersPackage) {
+        this.jmxHandlersPackage = jmxHandlersPackage;
+    }
+    
     /**
      * Return a DefaultConfiguration build on the given command name and
      * classname.

Added: james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java?rev=1054112&view=auto
==============================================================================
--- james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java (added)
+++ james/server/trunk/lmtpserver/src/main/java/org/apache/james/lmtpserver/jmx/JMXHandlersLoader.java Fri Dec 31 13:59:29 2010
@@ -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.lmtpserver.jmx;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.protocols.api.HandlersPackage;
+
+public class JMXHandlersLoader implements HandlersPackage{
+
+    private final List<String> handlers = new ArrayList<String>();
+    public JMXHandlersLoader() {
+        handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
+        handlers.add(CommandHandlerResultJMXMonitor.class.getName());
+        handlers.add(LineHandlerResultJMXMonitor.class.getName());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.HandlersPackage#getHandlers()
+     */
+    public List<String> getHandlers() {
+        return handlers;
+    }
+
+}

Added: james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java?rev=1054112&view=auto
==============================================================================
--- james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java (added)
+++ james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/jmx/JMXHandlersLoader.java Fri Dec 31 13:59:29 2010
@@ -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.pop3server.jmx;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.protocols.api.HandlersPackage;
+
+public class JMXHandlersLoader implements HandlersPackage{
+
+    private final List<String> handlers = new ArrayList<String>();
+    public JMXHandlersLoader() {
+        handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
+        handlers.add(CommandHandlerResultJMXMonitor.class.getName());
+        handlers.add(LineHandlerResultJMXMonitor.class.getName());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.HandlersPackage#getHandlers()
+     */
+    public List<String> getHandlers() {
+        return handlers;
+    }
+
+}

Added: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java?rev=1054112&view=auto
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java (added)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/jmx/JMXHandlersLoader.java Fri Dec 31 13:59:29 2010
@@ -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.smtpserver.jmx;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.protocols.api.HandlersPackage;
+
+public class JMXHandlersLoader implements HandlersPackage{
+
+    private final List<String> handlers = new ArrayList<String>();
+    public JMXHandlersLoader() {
+        handlers.add(ConnectHandlerResultJMXMonitor.class.getName());
+        handlers.add(CommandHandlerResultJMXMonitor.class.getName());
+        handlers.add(LineHandlerResultJMXMonitor.class.getName());
+        handlers.add(HookResultJMXMonitor.class.getName());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.HandlersPackage#getHandlers()
+     */
+    public List<String> getHandlers() {
+        return handlers;
+    }
+
+}



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