📄 jmxmbeanserver.java
字号:
* @exception ReflectionException Wraps the * <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the * <CODE>{@link java.lang.Exception}</CODE> that * occurred when trying to invoke the object's constructor. * @exception MBeanException The constructor of the object has thrown * an exception. * @exception RuntimeOperationsException Wraps an * <CODE>{@link java.lang.IllegalArgumentException}</CODE>: * The className passed in parameter is null. * */ public Object instantiate(String className) throws ReflectionException, MBeanException { /* Permission check */ checkMBeanPermission(className, null, null, "instantiate"); return instantiator.instantiate(className); } /** * Instantiates an object using the class Loader specified by its * <CODE>ObjectName</CODE>. * If the loader name is null, the ClassLoader that loaded the * MBean Server will be used. * The object's class should have a public constructor. * It returns a reference to the newly created object. * The newly created object is not registered in the MBean server. * * @param className The class name of the MBean to be instantiated. * @param loaderName The object name of the class loader to be used. * * @return The newly instantiated object. * * @exception ReflectionException Wraps the * <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the * <CODE>{@link java.lang.Exception}</CODE> that * occurred when trying to invoke the object's constructor. * @exception MBeanException The constructor of the object has thrown * an exception. * @exception InstanceNotFoundException The specified class loader * is not registered in the MBaenServer. * @exception RuntimeOperationsException Wraps an * <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The * className passed in parameter is null. * */ public Object instantiate(String className, ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException { /* Permission check */ checkMBeanPermission(className, null, null, "instantiate"); ClassLoader myLoader = outerShell.getClass().getClassLoader(); return instantiator.instantiate(className, loaderName, myLoader); } /** * Instantiates an object using the list of all class loaders registered * in the MBean server (using its * {@link javax.management.loading.ClassLoaderRepository Default Loader Repository}). * The object's class should have a public constructor. * The call returns a reference to the newly created object. * The newly created object is not registered in the MBean server. * * @param className The class name of the object to be instantiated. * @param params An array containing the parameters of the constructor * to be invoked. * @param signature An array containing the signature of the * constructor to be invoked. * * @return The newly instantiated object. * * @exception ReflectionException Wraps the * <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the * <CODE>{@link java.lang.Exception}</CODE> that * occurred when trying to invoke the object's constructor. * @exception MBeanException The constructor of the object has thrown * an exception. * @exception RuntimeOperationsException Wraps an * <CODE>{@link java.lang.IllegalArgumentException}</CODE>: * The className passed in parameter is null. * */ public Object instantiate(String className, Object params[], String signature[]) throws ReflectionException, MBeanException { /* Permission check */ checkMBeanPermission(className, null, null, "instantiate"); ClassLoader myLoader = outerShell.getClass().getClassLoader(); return instantiator.instantiate(className, params, signature, myLoader); } /** * Instantiates an object. The class loader to be used is identified * by its object name. If the object name of the loader is null, * the ClassLoader that loaded the MBean server will be used. * The object's class should have a public constructor. * The call returns a reference to the newly created object. * The newly created object is not registered in the MBean server. * * @param className The class name of the object to be instantiated. * @param params An array containing the parameters of the constructor * to be invoked. * @param signature An array containing the signature of the constructor * to be invoked. * @param loaderName The object name of the class loader to be used. * * @return The newly instantiated object. * * @exception ReflectionException Wraps the * <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the * <CODE>{@link java.lang.Exception}</CODE> that * occurred when trying to invoke the object's constructor. * @exception MBeanException The constructor of the object has thrown * an exception. * @exception InstanceNotFoundException The specified class loader * is not registered in the MBean server. * @exception RuntimeOperationsException Wraps an * <CODE>{@link java.lang.IllegalArgumentException}</CODE>: * The className passed in parameter is null. * */ public Object instantiate(String className, ObjectName loaderName, Object params[], String signature[]) throws ReflectionException, MBeanException, InstanceNotFoundException { /* Permission check */ checkMBeanPermission(className, null, null, "instantiate"); ClassLoader myLoader = outerShell.getClass().getClassLoader(); return instantiator.instantiate(className,loaderName,params,signature, myLoader); } /** * Returns true if the MBean specified is an instance of the specified * class, false otherwise. * * @param name The <CODE>ObjectName</CODE> of the MBean. * @param className The name of the class. * * @return true if the MBean specified is an instance of the specified * class, false otherwise. * * @exception InstanceNotFoundException The MBean specified is not * registered in the MBean server. */ public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException { return mbsInterceptor.isInstanceOf(cloneObjectName(name), className); } /** * De-serializes a byte array in the context of the class loader * of an MBean. * * @param name The name of the MBean whose class loader should * be used for the de-serialization. * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The MBean specified is not * found. * @exception OperationsException Any of the usual Input/Output * related exceptions. * */ @Deprecated public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException { /* Permission check */ // This call requires MBeanPermission 'getClassLoaderFor' final ClassLoader loader = getClassLoaderFor(name); return instantiator.deserialize(loader, data); } /** * De-serializes a byte array in the context of a given MBean class loader. * The class loader is the one that loaded the class with name "className". * * @param className The name of the class whose class loader should be * used for the de-serialization. * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output * related exceptions. * @exception ReflectionException The specified class could not be * loaded by the default loader repository * */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { if (className == null) { throw new RuntimeOperationsException( new IllegalArgumentException(), "Null className passed in parameter"); } /* Permission check */ // This call requires MBeanPermission 'getClassLoaderRepository' final ClassLoaderRepository clr = getClassLoaderRepository(); Class theClass; try { if (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException e) { throw new ReflectionException(e, "The given class could not be " + "loaded by the default loader " + "repository"); } return instantiator.deserialize(theClass.getClassLoader(), data); } /** * De-serializes a byte array in the context of a given MBean class loader. * The class loader is the one that loaded the class with name "className". * The name of the class loader to be used for loading the specified * class is specified. * If null, the MBean Server's class loader will be used. * * @param className The name of the class whose class loader should be * used for the de-serialization. * @param data The byte array to be de-sererialized. * @param loaderName The name of the class loader to be used for * loading the specified class. * If null, the MBean Server's class loader will be used. * * @return The de-serialized object stream. * * @exception InstanceNotFoundException The specified class loader * MBean is not found. * @exception OperationsException Any of the usual Input/Output * related exceptions. * @exception ReflectionException The specified class could not * be loaded by the specified class loader. * */ @Deprecated public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException { // Clone ObjectName // loaderName = cloneObjectName(loaderName); /* Permission check */ // Make this call just to force the 'getClassLoader' // permission check try { getClassLoader(loaderName); } catch (SecurityException e) { throw e; } catch (Exception e) { } ClassLoader myLoader = outerShell.getClass().getClassLoader(); return instantiator.deserialize(className, loaderName, data, myLoader); } /** * Initializes this MBeanServer, registering the MBeanServerDelegate. * <p>This method must be called once, before using the MBeanServer. **/ private void initialize() { if (instantiator == null) throw new IllegalStateException("instantiator must not be null."); // Registers the MBeanServer identification MBean try { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { public Object run() throws Exception { mbsInterceptor.registerMBean( mBeanServerDelegateObject, MBeanServerDelegate.DELEGATE_NAME); return null; } }); } catch (SecurityException e) { if (isDebugOn()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -