protected ManagementStrategy createManagementStrategy() {
ManagementStrategy answer = null;
if (disableJMX || Boolean.getBoolean(JmxSystemPropertyKeys.DISABLED)) {
LOG.info("JMX is disabled. Using DefaultManagementStrategy.");
answer = new DefaultManagementStrategy();
} else {
try {
LOG.info("JMX enabled. Using ManagedManagementStrategy.");
answer = new ManagedManagementStrategy(new DefaultManagementAgent(this));
// prefer to have it at first strategy
lifecycleStrategies.add(0, new DefaultManagementLifecycleStrategy(this));
} 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."
+ " Needed class is in spring-context.jar using Spring 2.5 or newer"
+ " (spring-jmx.jar using Spring 2.0.x)."
+ " NoClassDefFoundError: " + e.getMessage());
} catch (Exception e) {
LOG.warn("Cannot create JMX lifecycle strategy. Will fallback to use non JMX and this exception will be ignored.", e);
}
}
if (answer == null) {
LOG.warn("Cannot use JMX. Fallback to using DefaultManagementStrategy (non JMX).");
answer = new DefaultManagementStrategy();
}
// inject CamelContext
if (answer instanceof CamelContextAware) {
CamelContextAware aware = (CamelContextAware) answer;