[jboss-cvs] JBossAS SVN: r61645 - in branches/JBoss_4_0_0_JBAS-4239: tomcat/src/main/org/jboss/web/tomcat/tc5 and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 23 13:48:17 EDT 2007


Author: darran.lofthouse at jboss.com
Date: 2007-03-23 13:48:17 -0400 (Fri, 23 Mar 2007)
New Revision: 61645

Modified:
   branches/JBoss_4_0_0_JBAS-4239/jmx/src/main/org/jboss/mx/util/MBeanProxyExt.java
   branches/JBoss_4_0_0_JBAS-4239/tomcat/src/main/org/jboss/web/tomcat/tc5/Tomcat5.java
Log:
JBAS-4239 - Fixes to remove InstanceNotFoundException when running JBoss with JConsole enabled.

Modified: branches/JBoss_4_0_0_JBAS-4239/jmx/src/main/org/jboss/mx/util/MBeanProxyExt.java
===================================================================
--- branches/JBoss_4_0_0_JBAS-4239/jmx/src/main/org/jboss/mx/util/MBeanProxyExt.java	2007-03-23 17:19:15 UTC (rev 61644)
+++ branches/JBoss_4_0_0_JBAS-4239/jmx/src/main/org/jboss/mx/util/MBeanProxyExt.java	2007-03-23 17:48:17 UTC (rev 61645)
@@ -39,9 +39,10 @@
  * </ul>
  *
  * @version <tt>$Revision$</tt>
- * @author <a href="mailto:rickard.oberg at telkel.com">Rickard Öberg</a>.
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:rickard.oberg at telkel.com">Rickard Öberg</a>.
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>.
  * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>.
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>.
  */
 public class MBeanProxyExt
    implements InvocationHandler, MBeanProxyInstance
@@ -56,7 +57,7 @@
    private final HashMap attributeMap = new HashMap();
    
    /**
-    * Construct a MBeanProxy.
+    * Construct an MBeanProxy.
     */
    MBeanProxyExt(final ObjectName name, final MBeanServer server)
    {
@@ -195,6 +196,55 @@
       return server;
    }
 
+   ///////////////////////////////////////////////////////////////////////////
+   //                          Object Overrides                             //
+   ///////////////////////////////////////////////////////////////////////////
+   
+   /**
+    * We need to override this because by default equals returns false
+    * when called on the proxy object and then relayed here.
+    */
+   public boolean equals(Object that)
+   {
+      if (that == null) return false;
+      if (that == this) return true;
+      
+      // check if 'that' is an MBeanProxyExt or a Proxy instance
+      // that implements the MBeanProxyInstance interface
+      if (that instanceof MBeanProxyInstance)
+      {
+         MBeanProxyInstance proxy = (MBeanProxyInstance)that;
+         
+         // assume equality if both the MBeanServer and ObjectName match
+         if (name.equals(proxy.getMBeanProxyObjectName()) &&
+             server.equals(proxy.getMBeanProxyMBeanServer()))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   /**
+    * As with equals, use the MBeanServer + ObjectName
+    * to calculate the hashCode
+    */
+   public int hashCode()
+   {
+      return name.hashCode() * 31 + server.hashCode();
+   }
+   
+   /**
+    * avoid the default printout, e.g. org.jboss.mx.util.MBeanProxyExt at 120540c
+    */
+   public String toString()
+   {
+      StringBuffer sbuf = new StringBuffer(128);
+      
+      sbuf.append("MBeanProxyExt[").append(name.toString()).append(']');
+      
+      return sbuf.toString();
+   }
 
    ///////////////////////////////////////////////////////////////////////////
    //                            Factory Methods                            //
@@ -244,7 +294,7 @@
     */
    public static Object create(final Class intf, final ObjectName name)
    {
-      return create(intf, name, MBeanServerLocator.locate());
+      return create(intf, name, MBeanServerLocator.locateJBoss());
    }
 
    /**
@@ -289,8 +339,7 @@
       };
       ClassLoader cl = (ClassLoader) AccessController.doPrivileged(action);
       Class[] ifaces = { MBeanProxyInstance.class, intf };
-      return Proxy.newProxyInstance(cl, ifaces, 
-                  new MBeanProxyExt(name, server));
+      return Proxy.newProxyInstance(cl, ifaces, new MBeanProxyExt(name, server));
    }
 }
 /*

Modified: branches/JBoss_4_0_0_JBAS-4239/tomcat/src/main/org/jboss/web/tomcat/tc5/Tomcat5.java
===================================================================
--- branches/JBoss_4_0_0_JBAS-4239/tomcat/src/main/org/jboss/web/tomcat/tc5/Tomcat5.java	2007-03-23 17:19:15 UTC (rev 61644)
+++ branches/JBoss_4_0_0_JBAS-4239/tomcat/src/main/org/jboss/web/tomcat/tc5/Tomcat5.java	2007-03-23 17:48:17 UTC (rev 61645)
@@ -19,13 +19,14 @@
 
 import org.apache.catalina.Connector;
 import org.apache.catalina.Lifecycle;
+import org.apache.commons.modeler.Registry;
 import org.jboss.deployment.DeploymentInfo;
+import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
 import org.jboss.system.server.Server;
 import org.jboss.system.server.ServerImplMBean;
 import org.jboss.web.AbstractWebContainer;
 import org.jboss.web.AbstractWebDeployer;
 import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
-import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
 
 
 /**
@@ -301,6 +302,9 @@
       String objectNameS = catalinaDomain + ":type=server";
       ObjectName objectName = new ObjectName(objectNameS);
 
+      // Set the modeler Registry MBeanServer to the that of the tomcat service
+      Registry.getRegistry().setMBeanServer(server);
+      
       server.createMBean("org.apache.commons.modeler.BaseModelMBean",
          objectName,
          new Object[]{"org.apache.catalina.startup.Catalina"},




More information about the jboss-cvs-commits mailing list