camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1446860 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: management/DefaultManagementAgent.java management/DefaultManagementMBeanAssembler.java management/MBeanInfoAssembler.java spi/ManagementMBeanAssembler.java
Date Sat, 16 Feb 2013 09:33:55 GMT
Author: davsclaus
Date: Sat Feb 16 09:33:55 2013
New Revision: 1446860

URL: http://svn.apache.org/r1446860
Log:
CAMEL-6079: Skip trying to regsiter proxy class as JMX MBeans

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementMBeanAssembler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/MBeanInfoAssembler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java?rev=1446860&r1=1446859&r2=1446860&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
Sat Feb 16 09:33:55 2013
@@ -229,8 +229,10 @@ public class DefaultManagementAgent exte
             ManagementMBeanAssembler assembler = camelContext.getManagementMBeanAssembler();
             ObjectHelper.notNull(assembler, "ManagementMBeanAssembler", camelContext);
             Object mbean = assembler.assemble(server, obj, name);
-            // and register the mbean
-            registerMBeanWithServer(mbean, name, forceRegistration);
+            if (mbean != null) {
+                // and register the mbean
+                registerMBeanWithServer(mbean, name, forceRegistration);
+            }
         }
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementMBeanAssembler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementMBeanAssembler.java?rev=1446860&r1=1446859&r2=1446860&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementMBeanAssembler.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementMBeanAssembler.java
Sat Feb 16 09:33:55 2013
@@ -71,6 +71,10 @@ public class DefaultManagementMBeanAssem
             mbi = assembler.getMBeanInfo(obj, null, name.toString());
         }
 
+        if (mbi == null) {
+            return null;
+        }
+
         RequiredModelMBean mbean = (RequiredModelMBean) mBeanServer.instantiate(RequiredModelMBean.class.getName());
         mbean.setModelMBeanInfo(mbi);
 
@@ -79,7 +83,7 @@ public class DefaultManagementMBeanAssem
         } catch (InvalidTargetObjectTypeException e) {
             throw new JMException(e.getMessage());
         }
-        
+
         // Allows the managed object to send notifications
         if (obj instanceof NotificationSenderAware) {
             ((NotificationSenderAware)obj).setNotificationSender(new NotificationSenderAdapter(mbean));

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/MBeanInfoAssembler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/MBeanInfoAssembler.java?rev=1446860&r1=1446859&r2=1446860&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/MBeanInfoAssembler.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/MBeanInfoAssembler.java
Sat Feb 16 09:33:55 2013
@@ -17,6 +17,7 @@
 package org.apache.camel.management;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
@@ -84,10 +85,16 @@ public class MBeanInfoAssembler implemen
      * @param defaultManagedBean  the default managed bean
      * @param customManagedBean   an optional custom managed bean
      * @param objectName   the object name
-     * @return the model info
+     * @return the model info, or <tt>null</tt> if not possible to create, for
example due the managed bean is a proxy class
      * @throws JMException is thrown if error creating the model info
      */
     public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean,
String objectName) throws JMException {
+        // skip proxy classes
+        if (Proxy.isProxyClass(defaultManagedBean.getClass())) {
+            LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
+            return null;
+        }
+
         // maps and lists to contain information about attributes and operations
         Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String,
ManagedAttributeInfo>();
         Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java?rev=1446860&r1=1446859&r2=1446860&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java
Sat Feb 16 09:33:55 2013
@@ -33,7 +33,7 @@ public interface ManagementMBeanAssemble
      * @param mBeanServer the mbean server
      * @param obj         the object
      * @param name        the object name to use in JMX
-     * @return the assembled {@link javax.management.modelmbean.ModelMBean}
+     * @return the assembled {@link javax.management.modelmbean.ModelMBean}, or <tt>null</tt>
if not possible to assemble an MBean
      * @throws JMException is thrown if error assembling the mbean
      */
     ModelMBean assemble(MBeanServer mBeanServer, Object obj, ObjectName name) throws JMException;



Mime
View raw message