Author: davsclaus
Date: Thu Jul 17 03:40:45 2008
New Revision: 677554
URL: http://svn.apache.org/viewvc?rev=677554&view=rev
Log:
CAMEL-732: Will fallback to non JMX lifecycle strategy if not possible to
create such as missing spring-context.jar in the classpath. Then end-users just
using camel-core.jar can also use Camel out-of-the-box.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=677554&r1=677553&r2=677554&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Thu Jul 17 03:40:45 2008
@@ -94,10 +94,27 @@
public DefaultCamelContext() {
name = NAME_PREFIX + ++nameSuffix;
+
if (Boolean.getBoolean(JmxSystemPropertyKeys.DISABLED)) {
+ LOG.info("JMX is disabled. Using DefaultLifecycleStrategy.");
lifecycleStrategy = new DefaultLifecycleStrategy();
} else {
- lifecycleStrategy = new InstrumentationLifecycleStrategy();
+ try {
+ LOG.info("JMX enabled. Using
InstrumentationLifecycleStrategy.");
+ lifecycleStrategy = new InstrumentationLifecycleStrategy();
+ } catch (NoClassDefFoundError e) {
+ // if we can't instantiate the JMX enabled strategy then
fallback to default
+ // could be because of missing .jars on the classpath
+ LOG.warn("Could not find needed classes for JMX lifecycle
strategy."
+ + " Are you missing spring-context.jar by any chance?
NoClassDefFoundError: " + e.getMessage());
+ } catch (Exception e) {
+ LOG.warn("Could not create JMX lifecycle strategy, caused by:
" + e.getMessage());
+ }
+ // if not created then fallback to default
+ if (lifecycleStrategy == null) {
+ LOG.warn("Not possible to use JMX lifecycle strategy. Using
DefaultLifecycleStrategy instead.");
+ lifecycleStrategy = new DefaultLifecycleStrategy();
+ }
}
}