Author: hadrian
Date: Fri Jun 27 10:17:45 2008
New Revision: 672334
URL: http://svn.apache.org/viewvc?rev=672334&view=rev
Log:
CAMEL-637. Patch applied with many thanks!
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DisableJmxAgentTheOldWayTest.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml
Modified:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
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=672334&r1=672333&r2=672334&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 Jun 27 10:17:45 2008
@@ -159,26 +159,25 @@
// lets force any lazy creation
getContext().addRouteDefinitions(routes);
- if (camelJMXAgent != null && isJmxEnabled()) {
- if (camelJMXAgent.isDisabled() != null &&
camelJMXAgent.isDisabled()) {
- getContext().setLifecycleStrategy(new
DefaultLifecycleStrategy());
- } else {
+ if (!isJmxEnabled() ||
+ (camelJMXAgent != null && camelJMXAgent.isDisabled() != null
&& camelJMXAgent.isDisabled())) {
+ getContext().setLifecycleStrategy(new DefaultLifecycleStrategy());
+ } else if (camelJMXAgent != null) {
- if (lifecycleStrategy != null) {
- LOG.warn("lifecycleStrategy will be overriden by
InstrumentationLifecycleStrategy");
- }
-
- DefaultInstrumentationAgent agent = new
DefaultInstrumentationAgent();
- agent.setConnectorPort(camelJMXAgent.getConnectorPort());
- agent.setCreateConnector(camelJMXAgent.isCreateConnector());
-
agent.setMBeanObjectDomainName(camelJMXAgent.getMbeanObjectDomainName());
-
agent.setMBeanServerDefaultDomain(camelJMXAgent.getMbeanServerDefaultDomain());
- agent.setRegistryPort(camelJMXAgent.getRegistryPort());
- agent.setServiceUrlPath(camelJMXAgent.getServiceUrlPath());
-
agent.setUsePlatformMBeanServer(camelJMXAgent.isUsePlatformMBeanServer());
-
- getContext().setLifecycleStrategy(new
InstrumentationLifecycleStrategy(agent));
+ if (lifecycleStrategy != null) {
+ LOG.warn("lifecycleStrategy will be overriden by
InstrumentationLifecycleStrategy");
}
+
+ DefaultInstrumentationAgent agent = new
DefaultInstrumentationAgent();
+ agent.setConnectorPort(camelJMXAgent.getConnectorPort());
+ agent.setCreateConnector(camelJMXAgent.isCreateConnector());
+
agent.setMBeanObjectDomainName(camelJMXAgent.getMbeanObjectDomainName());
+
agent.setMBeanServerDefaultDomain(camelJMXAgent.getMbeanServerDefaultDomain());
+ agent.setRegistryPort(camelJMXAgent.getRegistryPort());
+ agent.setServiceUrlPath(camelJMXAgent.getServiceUrlPath());
+
agent.setUsePlatformMBeanServer(camelJMXAgent.isUsePlatformMBeanServer());
+
+ getContext().setLifecycleStrategy(new
InstrumentationLifecycleStrategy(agent));
}
if (LOG.isDebugEnabled()) {
@@ -310,8 +309,15 @@
return beanPostProcessor;
}
+ /**
+ * This method merely retrieves the value of the "useJmx" attribute and
does
+ * not consider the "dusabled" flag in jmxAgent element. The useJmx
+ * attribute will be removed in 2.0. Please the jmxAgent element instead.
+ *
+ * @deprecated
+ */
public boolean isJmxEnabled() {
- return useJmx != null && useJmx.booleanValue();
+ return useJmx.booleanValue();
}
public Boolean getUseJmx() {
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DisableJmxAgentTheOldWayTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DisableJmxAgentTheOldWayTest.java?rev=672334&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DisableJmxAgentTheOldWayTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/DisableJmxAgentTheOldWayTest.java
Fri Jun 27 10:17:45 2008
@@ -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.camel.spring;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Test that verifies JMX can be disabled via Spring the old way.
+ *
+ * @version $Revision$
+ *
+ */
+public class DisableJmxAgentTheOldWayTest extends DefaultJMXAgentTest {
+
+ @Override
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/spring/disableJmxTheOldWayConfig.xml");
+ }
+
+ public void testGetJMXConnector() throws Exception {
+ assertNull(mbsc);
+ }
+
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml?rev=672334&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxTheOldWayConfig.xml
Fri Jun 27 10:17:45 2008
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel" useJmx="false"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <jmxAgent id="agent" disabled="true"/>
+
+ <route>
+ <from uri="seda:start"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>