public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { ObjectInstance oi = registry.getObjectInstance(name); checkMBeanPermission(oi.getClassName(), null, name, "getObjectInstance"); return oi; }
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { ObjectInstance oi = registry.getObjectInstance(name); checkMBeanPermission(oi.getClassName(), null, name, "getObjectInstance"); return oi; }
public ClassLoader getClassLoaderFor(ObjectName name) throws InstanceNotFoundException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), null, name, "getClassLoaderFor"); ClassLoader cl = entry.getClassLoader(); if (cl == null) cl = entry.getResourceInstance().getClass().getClassLoader(); if (cl == null) cl = ClassLoader.getSystemClassLoader(); return cl; }
checkMBeanPermission(null, null, null, "getClassLoaderRepository");
public ClassLoader getClassLoaderFor(ObjectName name) throws InstanceNotFoundException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), null, name, "getClassLoaderFor"); ClassLoader cl = entry.getClassLoader(); if (cl == null) cl = entry.getResourceInstance().getClass().getClassLoader(); if (cl == null) cl = ClassLoader.getSystemClassLoader(); return cl; }
/** * * @param name The ObjectName of the ClassLoader. May be null, in which case * the MBean server's own ClassLoader is returned. * @return the classloader * @throws InstanceNotFoundException */ public ClassLoader getClassLoader(ObjectName name) throws InstanceNotFoundException { Object loader = null; if( name == null ) { checkMBeanPermission(null, null, name, "getClassLoader"); loader = getClass().getClassLoader(); if (loader == null) loader = ClassLoader.getSystemClassLoader(); } else { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), null, name, "getClassLoader"); loader = entry.getResourceInstance(); } if ((loader instanceof ClassLoader) == false) throw new InstanceNotFoundException("Not a classloader " + name); return (ClassLoader) loader; }
public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException { // Get the MBean's class name MBeanEntry entry = registry.get(name); String mbeanClassName = entry.getResourceClassName(); checkMBeanPermission(mbeanClassName, null, name, "isInstanceOf"); // 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; }
public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { MBeanEntry entry = registry.get(name); String attributeName = null; if (attribute != null) attributeName = attribute.getName(); checkMBeanPermission(entry.getResourceClassName(), attributeName, name, "setAttribute"); MBeanInvoker mbean = entry.getInvoker(); mbean.setAttribute(attribute); }
public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { MBeanEntry entry = registry.get(name); String attributeName = null; if (attribute != null) attributeName = attribute.getName(); checkMBeanPermission(entry.getResourceClassName(), attributeName, name, "setAttribute"); MBeanInvoker mbean = entry.getInvoker(); mbean.setAttribute(attribute); }
public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), attribute, name, "getAttribute"); MBeanInvoker mbean = entry.getInvoker(); return mbean.getAttribute(attribute); }
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), operationName, name, "invoke"); MBeanInvoker mbean = entry.getInvoker(); return mbean.invoke(operationName, params, signature); }
public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), attribute, name, "getAttribute"); MBeanInvoker mbean = entry.getInvoker(); return mbean.getAttribute(attribute); }
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), operationName, name, "invoke"); MBeanInvoker mbean = entry.getInvoker(); return mbean.invoke(operationName, params, signature); }
public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), null, name, "getMBeanInfo"); try { MBeanInvoker invoker = entry.getInvoker(); return invoker.getMBeanInfo(); } catch (Exception e) { JMException result = ExceptionHandler.handleException(e); if (result instanceof InstanceNotFoundException) throw (InstanceNotFoundException) result; if (result instanceof IntrospectionException) throw (IntrospectionException) result; if (result instanceof ReflectionException) throw (ReflectionException) result; throw new RuntimeException("Cannot obtain MBeanInfo " + name, result); } }
public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException { MBeanEntry entry = registry.get(name); checkMBeanPermission(entry.getResourceClassName(), null, name, "getMBeanInfo"); try { MBeanInvoker invoker = entry.getInvoker(); return invoker.getMBeanInfo(); } catch (Exception e) { JMException result = ExceptionHandler.handleException(e); if (result instanceof InstanceNotFoundException) throw (InstanceNotFoundException) result; if (result instanceof IntrospectionException) throw (IntrospectionException) result; if (result instanceof ReflectionException) throw (ReflectionException) result; throw new RuntimeException("Cannot obtain MBeanInfo " + name, result); } }
/** * Removes a listener from a registered MBean. * * If the listener is registered more than once, perhaps with different filters or callbacks, * this method will remove all those registrations. */ public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException { MBeanEntry entry = registry.get(name); if (NotificationBroadcaster.class.isInstance(entry.getResourceInstance()) == false) throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + name + " exists but does not implement the NotificationBroadcaster interface.")); checkMBeanPermission(entry.getResourceClassName(), null, name, "removeNotificationListener"); ClassLoader newTCL = entry.getClassLoader(); ClassLoader oldTCL = TCLAction.UTIL.getContextClassLoader(); final boolean setCl = newTCL != oldTCL && newTCL != null; try { if (setCl) TCLAction.UTIL.setContextClassLoader(newTCL); listeners.remove(entry.getObjectName(), listener); } finally { if (setCl) TCLAction.UTIL.setContextClassLoader(oldTCL); } }
throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + listener + " exists but does not implement the NotificationListener interface.")); checkMBeanPermission(entry.getResourceClassName(), null, name, "removeNotificationListener");
throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + listener + " exists but does not implement the NotificationListener interface.")); checkMBeanPermission(entry.getResourceClassName(), null, name, "removeNotificationListener");
throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + name + " exists but does not implement the NotificationBroadcaster interface.")); checkMBeanPermission(entry.getResourceClassName(), null, name, "removeNotificationListener");
/** * Removes a listener from a registered MBean. * * If the listener is registered more than once, perhaps with different filters or callbacks, * this method will remove all those registrations. */ public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException { MBeanEntry entry = registry.get(name); if (NotificationBroadcaster.class.isInstance(entry.getResourceInstance()) == false) throw new RuntimeOperationsException(new IllegalArgumentException("The MBean " + name + " exists but does not implement the NotificationBroadcaster interface.")); checkMBeanPermission(entry.getResourceClassName(), null, name, "removeNotificationListener"); ClassLoader newTCL = entry.getClassLoader(); ClassLoader oldTCL = TCLAction.UTIL.getContextClassLoader(); final boolean setCl = newTCL != oldTCL && newTCL != null; try { if (setCl) TCLAction.UTIL.setContextClassLoader(newTCL); listeners.remove(entry.getObjectName(), listener); } finally { if (setCl) TCLAction.UTIL.setContextClassLoader(oldTCL); } }