From: Adrian B. <ej...@us...> - 2003-01-20 19:03:43
|
User: ejort Date: 03/01/20 11:03:42 Modified: src/main/org/jboss/mx/server MBeanServerImpl.java Log: Change MBeanServer.isInstanceOf for the jmx1.2 spec, also removed some unnecessary logging Revision Changes Path 1.38 +34 -7 jmx/src/main/org/jboss/mx/server/MBeanServerImpl.java Index: MBeanServerImpl.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/org/jboss/mx/server/MBeanServerImpl.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- MBeanServerImpl.java 20 Jan 2003 17:20:21 -0000 1.37 +++ MBeanServerImpl.java 20 Jan 2003 19:03:42 -0000 1.38 @@ -121,7 +121,7 @@ * @author <a href="mailto:ju...@jb...">Juha Lindfors</a>. * @author <a href="mailto:tr...@pr...">Trevor Squires</a>. * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>. - * @version $Revision: 1.37 $ + * @version $Revision: 1.38 $ */ public class MBeanServerImpl implements MBeanServer, ServerConstants, ServiceConstants, ModelMBeanConstants @@ -738,17 +738,44 @@ public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException { - // REVIEW: TCL required? - Object resourceInstance = registry.get(name).getResourceInstance(); + // Get the MBean's class name + String mbeanClassName = null; try { - Class clazz = DefaultLoaderRepository.loadClass(className); - return clazz.isInstance(resourceInstance); + mbeanClassName = getMBeanInfo(name).getClassName(); } - catch (ClassNotFoundException cfe) + catch (InstanceNotFoundException e) + { + throw e; + } + catch (Exception e) { - return false; + return false; // Correct? } + + // The names are the same + if (className.equals(mbeanClassName)) + return true; + + // Try to load both classes + Class mbeanClass = null; + Class testClass = null; + ClassLoader cl = getClassLoaderFor(name); + try + { + mbeanClass = cl.loadClass(mbeanClassName); + testClass = cl.loadClass(className); + } + catch (ClassNotFoundException e) + { + return false; + } + + // Check whether it is assignable + if (testClass.isAssignableFrom(mbeanClass)) + return true; + else + return false; } /** |