camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r657091 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/management/ camel-core/src/test/java/org/apache/camel/management/ components/camel-spring/src/main/java/org/apache/camel/spring/
Date Fri, 16 May 2008 15:01:58 GMT
Author: ningjiang
Date: Fri May 16 08:01:57 2008
New Revision: 657091

URL: http://svn.apache.org/viewvc?rev=657091&view=rev
Log:
CAMEL-512 Added more attributes for jmxAgent element

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationAgentImpl.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentType.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationAgentImpl.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationAgentImpl.java?rev=657091&r1=657090&r2=657091&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationAgentImpl.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationAgentImpl.java
Fri May 16 08:01:57 2008
@@ -58,6 +58,7 @@
     public static final String DEFAULT_DOMAIN = "org.apache.camel";
     public static final String DEFAULT_HOST = "localhost";
     public static final int DEFAULT_PORT = 1099;
+    public static final String DEFAULT_CONNECTOR_PATH = "/jmxrmi";
     private static final transient Log LOG = LogFactory.getLog(InstrumentationAgentImpl.class);
 
 
@@ -69,7 +70,10 @@
     private boolean jmxEnabled;
     private String jmxDomainName;
     private int jmxConnectorPort;
+    private String jmxConnectorPath;
     private CamelNamingStrategy namingStrategy;
+    private boolean createConnector = true;
+    private boolean usePlatformMBeanServer;
 
     public InstrumentationAgentImpl() {
         assembler = new MetadataMBeanInfoAssembler();
@@ -87,6 +91,14 @@
         context = camelContext;
     }
 
+    public void setCreateConnector(boolean flag) {
+        createConnector = flag;
+    }
+
+    public void setUsePlatformMBeanServer(boolean flag) {
+        usePlatformMBeanServer = flag;
+    }
+
     public void setMBeanServer(MBeanServer server) {
         this.server = server;
         jmxEnabled = true;
@@ -213,10 +225,15 @@
         }
     }
 
-    public void enableJmx(String domainName, int port) {
+    public void enableJmx() {
+        enableJmx(DEFAULT_DOMAIN, DEFAULT_CONNECTOR_PATH, DEFAULT_PORT);
+    }
+
+    public void enableJmx(String domainName, String connectorPath,  int port) {
         jmxEnabled = true;
         jmxDomainName = domainName;
         configureDomainName();
+        jmxConnectorPath = connectorPath;
         jmxConnectorPort = port;
     }
 
@@ -280,7 +297,7 @@
         }
 
         // jmx is enabled but there's no MBeanServer, so create one
-        if (Boolean.getBoolean(SYSTEM_PROPERTY_JMX_USE_PLATFORM_MBS)) {
+        if (Boolean.getBoolean(SYSTEM_PROPERTY_JMX_USE_PLATFORM_MBS) || usePlatformMBeanServer)
{
             server = ManagementFactory.getPlatformMBeanServer();
         } else {
             // jmx is enabled but there's no MBeanServer, so create one
@@ -291,9 +308,12 @@
                 server = (MBeanServer)servers.get(0);
             }
         }
-        // we need a connector too
+
         try {
-            createJmxConnector(hostName);
+            // Create the connector if we need
+            if (createConnector) {
+                createJmxConnector(hostName);
+            }
         } catch (IOException ioe) {
             LOG.warn("Could not create and start jmx connector.", ioe);
         }
@@ -304,13 +324,16 @@
             try {
                 LocateRegistry.createRegistry(jmxConnectorPort);
             } catch (RemoteException ex) {
-                // the registry may had been created
+                // The registry may had been created
                 LocateRegistry.getRegistry(jmxConnectorPort);
             }
 
+            if (jmxConnectorPath == null) {
+                jmxConnectorPath = DEFAULT_CONNECTOR_PATH;
+            }
             // Create an RMI connector and start it
             JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host
+ ":"
-                                                  + jmxConnectorPort + "/jmxrmi");
+                                                  + jmxConnectorPort + jmxConnectorPath);
             cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
 
             // Start the connector server asynchronously (in a separate thread).

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java?rev=657091&r1=657090&r2=657091&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
Fri May 16 08:01:57 2008
@@ -99,7 +99,7 @@
     }
 
     protected void enableJmx() {
-        iAgent.enableJmx(null, 0);
+        iAgent.enableJmx(null, null, 0);
     }
 
     protected CamelContext createCamelContext() throws Exception {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java?rev=657091&r1=657090&r2=657091&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationWithConnectorTest.java
Fri May 16 08:01:57 2008
@@ -22,6 +22,6 @@
     @Override
     protected void enableJmx() {
         domainName = "org.apache.camel-explicit";
-        iAgent.enableJmx(domainName, 1099);
+        iAgent.enableJmx(domainName, "/jmxtest", 1099);
     }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=657091&r1=657090&r2=657091&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Fri May 16 08:01:57 2008
@@ -137,9 +137,15 @@
         if (instrumentationAgent == null && isJmxEnabled()) {
             SpringInstrumentationAgent agent = new SpringInstrumentationAgent();
             if (camelJMXAgent != null) {
-                agent.enableJmx(camelJMXAgent.getJmxDomainName(), camelJMXAgent.getConnectorPort());
+                agent.enableJmx(camelJMXAgent.getJmxDomainName(), camelJMXAgent.getConnectorPath(),
camelJMXAgent.getConnectorPort());
+                if (camelJMXAgent.isCreateConnector() != null) {
+                    agent.setCreateConnector(camelJMXAgent.isCreateConnector());
+                }
+                if (camelJMXAgent.isUsePlatformMBeanServer() != null) {
+                    agent.setUsePlatformMBeanServer(camelJMXAgent.isUsePlatformMBeanServer());
+                }
             } else {
-                agent.enableJmx(SpringInstrumentationAgent.DEFAULT_DOMAIN, SpringInstrumentationAgent.DEFAULT_PORT);
+                agent.enableJmx();
             }
             agent.setCamelContext(getContext());
             String name = getMbeanServer();

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentType.java?rev=657091&r1=657090&r2=657091&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentType.java
Fri May 16 08:01:57 2008
@@ -28,15 +28,21 @@
  * The JAXB type class for the configuration of jmxAgent
  * @author Willem Jiang
  *
- * @version $Revision:$
+ * @version $Revision$
  */
 @XmlRootElement(name = "jmxAgent")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class CamelJMXAgentType extends IdentifiedType {
-    @XmlAttribute
+    @XmlAttribute(required = false)
     private Integer connectorPort;
-    @XmlAttribute
+    @XmlAttribute(required = false)
     private String jmxDomainName;
+    @XmlAttribute(required = false)
+    private String connectorPath;
+    @XmlAttribute(required = false)
+    private Boolean createConnector;
+    @XmlAttribute(required = false)
+    private Boolean usePlatformMBeanServer;
 
     public void setConnectorPort(Integer port) {
         connectorPort = port;
@@ -54,4 +60,27 @@
         return jmxDomainName;
     }
 
+    public void setConnectorPath(String path) {
+        connectorPath = path;
+    }
+
+    public String getConnectorPath() {
+        return connectorPath;
+    }
+
+    public void setCreateConnector(Boolean flag) {
+        createConnector = flag;
+    }
+
+    public Boolean isCreateConnector() {
+        return createConnector;
+    }
+
+    public void setUsePlatformMBeanServer(Boolean flag) {
+        usePlatformMBeanServer = flag;
+    }
+
+    public Boolean isUsePlatformMBeanServer() {
+        return usePlatformMBeanServer;
+    }
 }



Mime
View raw message