camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r755138 - in /camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/
Date Tue, 17 Mar 2009 07:35:32 GMT
Author: davsclaus
Date: Tue Mar 17 07:35:32 2009
New Revision: 755138

URL: http://svn.apache.org/viewvc?rev=755138&view=rev
Log:
Merged revisions 755136 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r755136 | davsclaus | 2009-03-17 08:08:06 +0100 (Tue, 17 Mar 2009) | 1 line
  
  CAMEL-1462: Camel will fallback to non JMX lifecycle if Camel cannot access it, eg. could
be because of lack of priviledges on the platform such as OC4j. This causes later a NPE in
DefaultCamelContext on endpoint lookup.
........

Modified:
    camel/branches/camel-1.x/   (props changed)
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/DefaultInstrumentationAgent.java
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 17 07:35:32 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=755138&r1=755137&r2=755138&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Tue Mar 17 07:35:32 2009
@@ -56,7 +56,6 @@
 import org.apache.camel.spi.LanguageResolver;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.Registry;
-import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.FactoryFinder;
 import org.apache.camel.util.NoFactoryAvailableException;
 import org.apache.camel.util.ObjectHelper;
@@ -630,7 +629,18 @@
             }
         }
 
-        lifecycleStrategy.onContextStart(this);
+        try {
+            lifecycleStrategy.onContextStart(this);
+        } catch (Exception e) {
+            // not all containers allow access to its MBeanServer (such as OC4j)
+            LOG.warn("Cannot start lifecycleStrategy: " + lifecycleStrategy + ". Cause: "
+ e.getMessage());
+            if (lifecycleStrategy instanceof InstrumentationLifecycleStrategy) {
+                // fallback to non JMX lifecycle to allow Camel to startup
+                LOG.warn("Will fallback to use default (non JMX) lifecycle strategy");
+                lifecycleStrategy = new DefaultLifecycleStrategy();
+                lifecycleStrategy.onContextStart(this);
+            }
+        }
 
         forceLazyInitialization();
         if (components != null) {

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/DefaultInstrumentationAgent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/DefaultInstrumentationAgent.java?rev=755138&r1=755137&r2=755138&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/DefaultInstrumentationAgent.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/DefaultInstrumentationAgent.java
Tue Mar 17 07:35:32 2009
@@ -73,29 +73,23 @@
 
     protected void finalizeSettings() {
         if (registryPort == null) {
-            registryPort = Integer.getInteger(JmxSystemPropertyKeys.REGISTRY_PORT,
-                    DEFAULT_REGISTRY_PORT);
+            registryPort = Integer.getInteger(JmxSystemPropertyKeys.REGISTRY_PORT, DEFAULT_REGISTRY_PORT);
         }
 
         if (connectorPort == null) {
-            connectorPort = Integer.getInteger(JmxSystemPropertyKeys.CONNECTOR_PORT,
-                    DEFAULT_CONNECTION_PORT);
+            connectorPort = Integer.getInteger(JmxSystemPropertyKeys.CONNECTOR_PORT, DEFAULT_CONNECTION_PORT);
         }
 
         if (mBeanServerDefaultDomain == null) {
-            mBeanServerDefaultDomain =
-                System.getProperty(JmxSystemPropertyKeys.DOMAIN, DEFAULT_DOMAIN);
+            mBeanServerDefaultDomain = System.getProperty(JmxSystemPropertyKeys.DOMAIN, DEFAULT_DOMAIN);
         }
 
         if (mBeanObjectDomainName == null) {
-            mBeanObjectDomainName =
-                System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN, DEFAULT_DOMAIN);
+            mBeanObjectDomainName = System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN,
DEFAULT_DOMAIN);
         }
 
         if (serviceUrlPath == null) {
-            serviceUrlPath =
-                System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH,
-                        DEFAULT_SERVICE_URL_PATH);
+            serviceUrlPath = System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH, DEFAULT_SERVICE_URL_PATH);
         }
 
         if (createConnector == null) {
@@ -149,12 +143,10 @@
         try {
             registerMBeanWithServer(obj, name, forceRegistration);
         } catch (NotCompliantMBeanException e) {
-            // If this is not a "normal" MBean, then try to deploy it using JMX
-            // annotations
-            ModelMBeanInfo mbi = null;
+            // If this is not a "normal" MBean, then try to deploy it using JMX annotations
+            ModelMBeanInfo mbi;
             mbi = assembler.getMBeanInfo(obj, name.toString());
-            RequiredModelMBean mbean = (RequiredModelMBean)server.instantiate(RequiredModelMBean.class
-                .getName());
+            RequiredModelMBean mbean = (RequiredModelMBean)server.instantiate(RequiredModelMBean.class.getName());
             mbean.setModelMBeanInfo(mbi);
             try {
                 mbean.setManagedResource(obj, "ObjectReference");
@@ -200,7 +192,7 @@
         Object[] mBeans = mbeans.toArray();
         int caught = 0;
         for (Object name : mBeans) {
-            mbeans.remove((ObjectName)name);
+            mbeans.remove(name);
             try {
                 unregister((ObjectName)name);
             } catch (JMException jmex) {
@@ -252,7 +244,7 @@
     }
 
     protected void createMBeanServer() {
-        String hostName = DEFAULT_HOST;
+        String hostName;
         boolean canAccessSystemProps = true;
         try {
             // we'll do it this way mostly to determine if we should lookup the
@@ -269,8 +261,7 @@
             try {
                 hostName = InetAddress.getLocalHost().getHostName();
             } catch (UnknownHostException uhe) {
-                LOG.info("Cannot determine localhost name. Using default: "
-                         + DEFAULT_REGISTRY_PORT, uhe);
+                LOG.info("Cannot determine localhost name. Using default: " + DEFAULT_REGISTRY_PORT,
uhe);
                 hostName = DEFAULT_HOST;
             }
         } else {
@@ -298,8 +289,7 @@
         }
 
         // look for the first mbean server that has match default domain name
-        List<MBeanServer> servers =
-            (List<MBeanServer>)MBeanServerFactory.findMBeanServer(null);
+        List<MBeanServer> servers = (List<MBeanServer>)MBeanServerFactory.findMBeanServer(null);
 
         for (MBeanServer server : servers) {
             if (LOG.isDebugEnabled()) {

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java?rev=755138&r1=755137&r2=755138&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
Tue Mar 17 07:35:32 2009
@@ -40,6 +40,7 @@
 import org.apache.camel.spi.InstrumentationAgent;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -89,7 +90,9 @@
                 ManagedService ms = new ManagedService(dc);
                 agent.register(ms, getNamingStrategy().getObjectName(dc));
             } catch (Exception e) {
-                LOG.warn("Could not register CamelContext MBean", e);
+                // must rethrow to allow CamelContext fallback to non JMX agent to allow
+                // Camel to continue to run
+                throw ObjectHelper.wrapRuntimeCamelException(e);
             }
         }
     }



Mime
View raw message