Path: blob/master/src/java.management/share/classes/javax/management/MBeanServer.java
41155 views
/*1* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.management;262728// java import29import java.util.Set;30import java.io.ObjectInputStream;3132// RI import33import javax.management.loading.ClassLoaderRepository;3435/**36* <p>This is the interface for MBean manipulation on the agent37* side. It contains the methods necessary for the creation,38* registration, and deletion of MBeans as well as the access methods39* for registered MBeans. This is the core component of the JMX40* infrastructure.</p>41*42* <p>User code does not usually implement this interface. Instead,43* an object that implements this interface is obtained with one of44* the methods in the {@link javax.management.MBeanServerFactory} class.</p>45*46* <p>Every MBean which is added to the MBean server becomes47* manageable: its attributes and operations become remotely48* accessible through the connectors/adaptors connected to that MBean49* server. A Java object cannot be registered in the MBean server50* unless it is a JMX compliant MBean.</p>51*52* <p id="notif">When an MBean is registered or unregistered in the53* MBean server a {@link javax.management.MBeanServerNotification54* MBeanServerNotification} Notification is emitted. To register an55* object as listener to MBeanServerNotifications you should call the56* MBean server method {@link #addNotificationListener57* addNotificationListener} with <CODE>ObjectName</CODE> the58* <CODE>ObjectName</CODE> of the {@link59* javax.management.MBeanServerDelegate MBeanServerDelegate}. This60* <CODE>ObjectName</CODE> is: <BR>61* <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.</p>62*63* <p>An object obtained from the {@link64* MBeanServerFactory#createMBeanServer(String) createMBeanServer} or65* {@link MBeanServerFactory#newMBeanServer(String) newMBeanServer}66* methods of the {@link MBeanServerFactory} class applies security67* checks to its methods, as follows.</p>68*69* <p>First, if there is no security manager ({@link70* System#getSecurityManager()} is null), then an implementation of71* this interface is free not to make any checks.</p>72*73* <p>Assuming that there is a security manager, or that the74* implementation chooses to make checks anyway, the checks are made75* as detailed below. In what follows, and unless otherwise specified,76* {@code className} is the77* string returned by {@link MBeanInfo#getClassName()} for the target78* MBean.</p>79*80* <p>If a security check fails, the method throws {@link81* SecurityException}.</p>82*83* <p>For methods that can throw {@link InstanceNotFoundException},84* this exception is thrown for a non-existent MBean, regardless of85* permissions. This is because a non-existent MBean has no86* <code>className</code>.</p>87*88* <ul>89*90* <li><p>For the {@link #invoke invoke} method, the caller's91* permissions must imply {@link92* MBeanPermission#MBeanPermission(String,String,ObjectName,String)93* MBeanPermission(className, operationName, name, "invoke")}.</p>94*95* <li><p>For the {@link #getAttribute getAttribute} method, the96* caller's permissions must imply {@link97* MBeanPermission#MBeanPermission(String,String,ObjectName,String)98* MBeanPermission(className, attribute, name, "getAttribute")}.</p>99*100* <li><p>For the {@link #getAttributes getAttributes} method, the101* caller's permissions must imply {@link102* MBeanPermission#MBeanPermission(String,String,ObjectName,String)103* MBeanPermission(className, null, name, "getAttribute")}.104* Additionally, for each attribute <em>a</em> in the {@link105* AttributeList}, if the caller's permissions do not imply {@link106* MBeanPermission#MBeanPermission(String,String,ObjectName,String)107* MBeanPermission(className, <em>a</em>, name, "getAttribute")}, the108* MBean server will behave as if that attribute had not been in the109* supplied list.</p>110*111* <li><p>For the {@link #setAttribute setAttribute} method, the112* caller's permissions must imply {@link113* MBeanPermission#MBeanPermission(String,String,ObjectName,String)114* MBeanPermission(className, attrName, name, "setAttribute")}, where115* <code>attrName</code> is {@link Attribute#getName()116* attribute.getName()}.</p>117*118* <li><p>For the {@link #setAttributes setAttributes} method, the119* caller's permissions must imply {@link120* MBeanPermission#MBeanPermission(String,String,ObjectName,String)121* MBeanPermission(className, null, name, "setAttribute")}.122* Additionally, for each attribute <em>a</em> in the {@link123* AttributeList}, if the caller's permissions do not imply {@link124* MBeanPermission#MBeanPermission(String,String,ObjectName,String)125* MBeanPermission(className, <em>a</em>, name, "setAttribute")}, the126* MBean server will behave as if that attribute had not been in the127* supplied list.</p>128*129* <li><p>For the <code>addNotificationListener</code> methods,130* the caller's permissions must imply {@link131* MBeanPermission#MBeanPermission(String,String,ObjectName,String)132* MBeanPermission(className, null, name,133* "addNotificationListener")}.</p>134*135* <li><p>For the <code>removeNotificationListener</code> methods,136* the caller's permissions must imply {@link137* MBeanPermission#MBeanPermission(String,String,ObjectName,String)138* MBeanPermission(className, null, name,139* "removeNotificationListener")}.</p>140*141* <li><p>For the {@link #getMBeanInfo getMBeanInfo} method, the142* caller's permissions must imply {@link143* MBeanPermission#MBeanPermission(String,String,ObjectName,String)144* MBeanPermission(className, null, name, "getMBeanInfo")}.</p>145*146* <li><p>For the {@link #getObjectInstance getObjectInstance} method,147* the caller's permissions must imply {@link148* MBeanPermission#MBeanPermission(String,String,ObjectName,String)149* MBeanPermission(className, null, name, "getObjectInstance")}.</p>150*151* <li><p>For the {@link #isInstanceOf isInstanceOf} method, the152* caller's permissions must imply {@link153* MBeanPermission#MBeanPermission(String,String,ObjectName,String)154* MBeanPermission(className, null, name, "isInstanceOf")}.</p>155*156* <li><p>For the {@link #queryMBeans queryMBeans} method, the157* caller's permissions must imply {@link158* MBeanPermission#MBeanPermission(String,String,ObjectName,String)159* MBeanPermission(null, null, null, "queryMBeans")}.160* Additionally, for each MBean <em>n</em> that matches <code>name</code>,161* if the caller's permissions do not imply {@link162* MBeanPermission#MBeanPermission(String,String,ObjectName,String)163* MBeanPermission(className, null, <em>n</em>, "queryMBeans")}, the164* MBean server will behave as if that MBean did not exist.</p>165*166* <p>Certain query elements perform operations on the MBean server.167* If the caller does not have the required permissions for a given168* MBean, that MBean will not be included in the result of the query.169* The standard query elements that are affected are {@link170* Query#attr(String)}, {@link Query#attr(String,String)}, and {@link171* Query#classattr()}.</p>172*173* <li><p>For the {@link #queryNames queryNames} method, the checks174* are the same as for <code>queryMBeans</code> except that175* <code>"queryNames"</code> is used instead of176* <code>"queryMBeans"</code> in the <code>MBeanPermission</code>177* objects. Note that a <code>"queryMBeans"</code> permission implies178* the corresponding <code>"queryNames"</code> permission.</p>179*180* <li><p>For the {@link #getDomains getDomains} method, the caller's181* permissions must imply {@link182* MBeanPermission#MBeanPermission(String,String,ObjectName,String)183* MBeanPermission(null, null, null, "getDomains")}. Additionally,184* for each domain <var>d</var> in the returned array, if the caller's185* permissions do not imply {@link186* MBeanPermission#MBeanPermission(String,String,ObjectName,String)187* MBeanPermission(null, null, new ObjectName("<var>d</var>:x=x"),188* "getDomains")}, the domain is eliminated from the array. Here,189* <code>x=x</code> is any <var>key=value</var> pair, needed to190* satisfy ObjectName's constructor but not otherwise relevant.</p>191*192* <li><p>For the {@link #getClassLoader getClassLoader} method, the193* caller's permissions must imply {@link194* MBeanPermission#MBeanPermission(String,String,ObjectName,String)195* MBeanPermission(className, null, loaderName,196* "getClassLoader")}.</p>197*198* <li><p>For the {@link #getClassLoaderFor getClassLoaderFor} method,199* the caller's permissions must imply {@link200* MBeanPermission#MBeanPermission(String,String,ObjectName,String)201* MBeanPermission(className, null, mbeanName,202* "getClassLoaderFor")}.</p>203*204* <li><p>For the {@link #getClassLoaderRepository205* getClassLoaderRepository} method, the caller's permissions must206* imply {@link207* MBeanPermission#MBeanPermission(String,String,ObjectName,String)208* MBeanPermission(null, null, null, "getClassLoaderRepository")}.</p>209*210* <li><p>For the deprecated <code>deserialize</code> methods, the211* required permissions are the same as for the methods that replace212* them.</p>213*214* <li><p>For the <code>instantiate</code> methods, the caller's215* permissions must imply {@link216* MBeanPermission#MBeanPermission(String,String,ObjectName,String)217* MBeanPermission(className, null, null, "instantiate")},218* where {@code className} is the name of the class which is to219* be instantiated.</p>220*221* <li><p>For the {@link #registerMBean registerMBean} method, the222* caller's permissions must imply {@link223* MBeanPermission#MBeanPermission(String,String,ObjectName,String)224* MBeanPermission(className, null, name, "registerMBean")}.225*226* <p>If the <code>MBeanPermission</code> check succeeds, the MBean's227* class is validated by checking that its {@link228* java.security.ProtectionDomain ProtectionDomain} implies {@link229* MBeanTrustPermission#MBeanTrustPermission(String)230* MBeanTrustPermission("register")}.</p>231*232* <p>Finally, if the <code>name</code> argument is null, another233* <code>MBeanPermission</code> check is made using the234* <code>ObjectName</code> returned by {@link235* MBeanRegistration#preRegister MBeanRegistration.preRegister}.</p>236*237* <li><p>For the <code>createMBean</code> methods, the caller's238* permissions must imply the permissions needed by the equivalent239* <code>instantiate</code> followed by240* <code>registerMBean</code>.</p>241*242* <li><p>For the {@link #unregisterMBean unregisterMBean} method,243* the caller's permissions must imply {@link244* MBeanPermission#MBeanPermission(String,String,ObjectName,String)245* MBeanPermission(className, null, name, "unregisterMBean")}.</p>246*247* </ul>248*249* @since 1.5250*/251252/* DELETED:253*254* <li><p>For the {@link #isRegistered isRegistered} method, the255* caller's permissions must imply {@link256* MBeanPermission#MBeanPermission(String,String,ObjectName,String)257* MBeanPermission(null, null, name, "isRegistered")}.</p>258*/259public interface MBeanServer extends MBeanServerConnection {260261/**262* {@inheritDoc}263* <p>If this method successfully creates an MBean, a notification264* is sent as described <a href="#notif">above</a>.</p>265*266* @throws RuntimeOperationsException {@inheritDoc}267* @throws RuntimeMBeanException {@inheritDoc}268* @throws RuntimeErrorException {@inheritDoc}269*/270public ObjectInstance createMBean(String className, ObjectName name)271throws ReflectionException, InstanceAlreadyExistsException,272MBeanRegistrationException, MBeanException,273NotCompliantMBeanException;274275/**276* {@inheritDoc}277* <p>If this method successfully creates an MBean, a notification278* is sent as described <a href="#notif">above</a>.</p>279*280* @throws RuntimeOperationsException {@inheritDoc}281* @throws RuntimeMBeanException {@inheritDoc}282* @throws RuntimeErrorException {@inheritDoc}283*/284public ObjectInstance createMBean(String className, ObjectName name,285ObjectName loaderName)286throws ReflectionException, InstanceAlreadyExistsException,287MBeanRegistrationException, MBeanException,288NotCompliantMBeanException, InstanceNotFoundException;289290/**291* {@inheritDoc}292* <p>If this method successfully creates an MBean, a notification293* is sent as described <a href="#notif">above</a>.</p>294*295* @throws RuntimeOperationsException {@inheritDoc}296* @throws RuntimeMBeanException {@inheritDoc}297* @throws RuntimeErrorException {@inheritDoc}298*/299public ObjectInstance createMBean(String className, ObjectName name,300Object params[], String signature[])301throws ReflectionException, InstanceAlreadyExistsException,302MBeanRegistrationException, MBeanException,303NotCompliantMBeanException;304305/**306* {@inheritDoc}307* <p>If this method successfully creates an MBean, a notification308* is sent as described <a href="#notif">above</a>.</p>309*310* @throws RuntimeOperationsException {@inheritDoc}311* @throws RuntimeMBeanException {@inheritDoc}312* @throws RuntimeErrorException {@inheritDoc}313*/314public ObjectInstance createMBean(String className, ObjectName name,315ObjectName loaderName, Object params[],316String signature[])317throws ReflectionException, InstanceAlreadyExistsException,318MBeanRegistrationException, MBeanException,319NotCompliantMBeanException, InstanceNotFoundException;320321/**322* <p>Registers a pre-existing object as an MBean with the MBean323* server. If the object name given is null, the MBean must324* provide its own name by implementing the {@link325* javax.management.MBeanRegistration MBeanRegistration} interface326* and returning the name from the {@link327* MBeanRegistration#preRegister preRegister} method.328*329* <p>If this method successfully registers an MBean, a notification330* is sent as described <a href="#notif">above</a>.</p>331*332* @param object The MBean to be registered as an MBean.333* @param name The object name of the MBean. May be null.334*335* @return An <CODE>ObjectInstance</CODE>, containing the336* <CODE>ObjectName</CODE> and the Java class name of the newly337* registered MBean. If the contained <code>ObjectName</code>338* is <code>n</code>, the contained Java class name is339* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.340*341* @exception InstanceAlreadyExistsException The MBean is already342* under the control of the MBean server.343* @exception MBeanRegistrationException The344* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>345* interface) method of the MBean has thrown an exception. The346* MBean will not be registered.347* @exception RuntimeMBeanException If the <CODE>postRegister</CODE>348* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a349* <CODE>RuntimeException</CODE>, the <CODE>registerMBean</CODE> method will350* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean351* registration succeeded. In such a case, the MBean will be actually352* registered even though the <CODE>registerMBean</CODE> method353* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can354* also be thrown by <CODE>preRegister</CODE>, in which case the MBean355* will not be registered.356* @exception RuntimeErrorException If the <CODE>postRegister</CODE>357* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an358* <CODE>Error</CODE>, the <CODE>registerMBean</CODE> method will359* throw a <CODE>RuntimeErrorException</CODE>, although the MBean360* registration succeeded. In such a case, the MBean will be actually361* registered even though the <CODE>registerMBean</CODE> method362* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can363* also be thrown by <CODE>preRegister</CODE>, in which case the MBean364* will not be registered.365* @exception NotCompliantMBeanException This object is not a JMX366* compliant MBean367* @exception RuntimeOperationsException Wraps a368* <CODE>java.lang.IllegalArgumentException</CODE>: The object369* passed in parameter is null or no object name is specified.370* @see javax.management.MBeanRegistration371*/372public ObjectInstance registerMBean(Object object, ObjectName name)373throws InstanceAlreadyExistsException, MBeanRegistrationException,374NotCompliantMBeanException;375376/**377* {@inheritDoc}378*379* <p>If this method successfully unregisters an MBean, a notification380* is sent as described <a href="#notif">above</a>.</p>381*382* @throws RuntimeOperationsException {@inheritDoc}383* @throws RuntimeMBeanException {@inheritDoc}384* @throws RuntimeErrorException {@inheritDoc}385*/386public void unregisterMBean(ObjectName name)387throws InstanceNotFoundException, MBeanRegistrationException;388389// doc comment inherited from MBeanServerConnection390public ObjectInstance getObjectInstance(ObjectName name)391throws InstanceNotFoundException;392393/**394* {@inheritDoc}395* @throws RuntimeOperationsException {@inheritDoc}396*/397public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query);398399/**400* {@inheritDoc}401* @throws RuntimeOperationsException {@inheritDoc}402*/403public Set<ObjectName> queryNames(ObjectName name, QueryExp query);404405// doc comment inherited from MBeanServerConnection406/**407* @throws RuntimeOperationsException {@inheritDoc}408*/409public boolean isRegistered(ObjectName name);410411/**412* Returns the number of MBeans registered in the MBean server.413*414* @return the number of registered MBeans, wrapped in an Integer.415* If the caller's permissions are restricted, this number may416* be greater than the number of MBeans the caller can access.417*/418public Integer getMBeanCount();419420// doc comment inherited from MBeanServerConnection421/**422* @throws RuntimeOperationsException {@inheritDoc}423*/424public Object getAttribute(ObjectName name, String attribute)425throws MBeanException, AttributeNotFoundException,426InstanceNotFoundException, ReflectionException;427428// doc comment inherited from MBeanServerConnection429/**430* @throws RuntimeOperationsException {@inheritDoc}431*/432public AttributeList getAttributes(ObjectName name, String[] attributes)433throws InstanceNotFoundException, ReflectionException;434435// doc comment inherited from MBeanServerConnection436/**437* @throws RuntimeOperationsException {@inheritDoc}438*/439public void setAttribute(ObjectName name, Attribute attribute)440throws InstanceNotFoundException, AttributeNotFoundException,441InvalidAttributeValueException, MBeanException,442ReflectionException;443444// doc comment inherited from MBeanServerConnection445/**446* @throws RuntimeOperationsException {@inheritDoc}447*/448public AttributeList setAttributes(ObjectName name,449AttributeList attributes)450throws InstanceNotFoundException, ReflectionException;451452// doc comment inherited from MBeanServerConnection453public Object invoke(ObjectName name, String operationName,454Object params[], String signature[])455throws InstanceNotFoundException, MBeanException,456ReflectionException;457458// doc comment inherited from MBeanServerConnection459public String getDefaultDomain();460461// doc comment inherited from MBeanServerConnection462public String[] getDomains();463464// doc comment inherited from MBeanServerConnection, plus:465/**466* {@inheritDoc}467* If the source of the notification468* is a reference to an MBean object, the MBean server will replace it469* by that MBean's ObjectName. Otherwise the source is unchanged.470*/471public void addNotificationListener(ObjectName name,472NotificationListener listener,473NotificationFilter filter,474Object handback)475throws InstanceNotFoundException;476477/**478* {@inheritDoc}479* @throws RuntimeOperationsException {@inheritDoc}480*/481public void addNotificationListener(ObjectName name,482ObjectName listener,483NotificationFilter filter,484Object handback)485throws InstanceNotFoundException;486487// doc comment inherited from MBeanServerConnection488public void removeNotificationListener(ObjectName name,489ObjectName listener)490throws InstanceNotFoundException, ListenerNotFoundException;491492// doc comment inherited from MBeanServerConnection493public void removeNotificationListener(ObjectName name,494ObjectName listener,495NotificationFilter filter,496Object handback)497throws InstanceNotFoundException, ListenerNotFoundException;498499// doc comment inherited from MBeanServerConnection500public void removeNotificationListener(ObjectName name,501NotificationListener listener)502throws InstanceNotFoundException, ListenerNotFoundException;503504// doc comment inherited from MBeanServerConnection505public void removeNotificationListener(ObjectName name,506NotificationListener listener,507NotificationFilter filter,508Object handback)509throws InstanceNotFoundException, ListenerNotFoundException;510511// doc comment inherited from MBeanServerConnection512public MBeanInfo getMBeanInfo(ObjectName name)513throws InstanceNotFoundException, IntrospectionException,514ReflectionException;515516517// doc comment inherited from MBeanServerConnection518public boolean isInstanceOf(ObjectName name, String className)519throws InstanceNotFoundException;520521/**522* <p>Instantiates an object using the list of all class loaders523* registered in the MBean server's {@link524* javax.management.loading.ClassLoaderRepository Class Loader525* Repository}. The object's class should have a public526* constructor. This method returns a reference to the newly527* created object. The newly created object is not registered in528* the MBean server.</p>529*530* <p>This method is equivalent to {@link531* #instantiate(String,Object[],String[])532* instantiate(className, (Object[]) null, (String[]) null)}.</p>533*534* @param className The class name of the object to be instantiated.535*536* @return The newly instantiated object.537*538* @exception ReflectionException Wraps a539* <CODE>java.lang.ClassNotFoundException</CODE> or the540* <CODE>java.lang.Exception</CODE> that occurred when trying to541* invoke the object's constructor.542* @exception MBeanException The constructor of the object has543* thrown an exception544* @exception RuntimeOperationsException Wraps a545* <CODE>java.lang.IllegalArgumentException</CODE>: The className546* passed in parameter is null.547*/548public Object instantiate(String className)549throws ReflectionException, MBeanException;550551552/**553* <p>Instantiates an object using the class Loader specified by its554* <CODE>ObjectName</CODE>. If the loader name is null, the555* ClassLoader that loaded the MBean Server will be used. The556* object's class should have a public constructor. This method557* returns a reference to the newly created object. The newly558* created object is not registered in the MBean server.</p>559*560* <p>This method is equivalent to {@link561* #instantiate(String,ObjectName,Object[],String[])562* instantiate(className, loaderName, (Object[]) null, (String[])563* null)}.</p>564*565* @param className The class name of the MBean to be instantiated.566* @param loaderName The object name of the class loader to be used.567*568* @return The newly instantiated object.569*570* @exception ReflectionException Wraps a571* <CODE>java.lang.ClassNotFoundException</CODE> or the572* <CODE>java.lang.Exception</CODE> that occurred when trying to573* invoke the object's constructor.574* @exception MBeanException The constructor of the object has575* thrown an exception.576* @exception InstanceNotFoundException The specified class loader577* is not registered in the MBeanServer.578* @exception RuntimeOperationsException Wraps a579* <CODE>java.lang.IllegalArgumentException</CODE>: The className580* passed in parameter is null.581*/582public Object instantiate(String className, ObjectName loaderName)583throws ReflectionException, MBeanException,584InstanceNotFoundException;585586/**587* <p>Instantiates an object using the list of all class loaders588* registered in the MBean server {@link589* javax.management.loading.ClassLoaderRepository Class Loader590* Repository}. The object's class should have a public591* constructor. The call returns a reference to the newly created592* object. The newly created object is not registered in the593* MBean server.</p>594*595* @param className The class name of the object to be instantiated.596* @param params An array containing the parameters of the597* constructor to be invoked.598* @param signature An array containing the signature of the599* constructor to be invoked.600*601* @return The newly instantiated object.602*603* @exception ReflectionException Wraps a604* <CODE>java.lang.ClassNotFoundException</CODE> or the605* <CODE>java.lang.Exception</CODE> that occurred when trying to606* invoke the object's constructor.607* @exception MBeanException The constructor of the object has608* thrown an exception609* @exception RuntimeOperationsException Wraps a610* <CODE>java.lang.IllegalArgumentException</CODE>: The className611* passed in parameter is null.612*/613public Object instantiate(String className, Object params[],614String signature[])615throws ReflectionException, MBeanException;616617/**618* <p>Instantiates an object. The class loader to be used is619* identified by its object name. If the object name of the loader620* is null, the ClassLoader that loaded the MBean server will be621* used. The object's class should have a public constructor.622* The call returns a reference to the newly created object. The623* newly created object is not registered in the MBean server.</p>624*625* @param className The class name of the object to be instantiated.626* @param params An array containing the parameters of the627* constructor to be invoked.628* @param signature An array containing the signature of the629* constructor to be invoked.630* @param loaderName The object name of the class loader to be used.631*632* @return The newly instantiated object.633*634* @exception ReflectionException Wraps a <CODE>java.lang.ClassNotFoundException</CODE> or the <CODE>java.lang.Exception</CODE> that635* occurred when trying to invoke the object's constructor.636* @exception MBeanException The constructor of the object has637* thrown an exception638* @exception InstanceNotFoundException The specified class loader639* is not registered in the MBean server.640* @exception RuntimeOperationsException Wraps a641* <CODE>java.lang.IllegalArgumentException</CODE>: The className642* passed in parameter is null.643*/644public Object instantiate(String className, ObjectName loaderName,645Object params[], String signature[])646throws ReflectionException, MBeanException,647InstanceNotFoundException;648649/**650* <p>De-serializes a byte array in the context of the class loader651* of an MBean.</p>652*653* @param name The name of the MBean whose class loader should be654* used for the de-serialization.655* @param data The byte array to be de-sererialized.656*657* @implSpec This method throws {@link UnsupportedOperationException} by default.658*659* @return The de-serialized object stream.660*661* @exception InstanceNotFoundException The MBean specified is not662* found.663* @exception OperationsException Any of the usual Input/Output664* related exceptions.665*666* @deprecated Use {@link #getClassLoaderFor getClassLoaderFor} to667* obtain the appropriate class loader for deserialization.668*/669@Deprecated(since="1.5")670default public ObjectInputStream deserialize(ObjectName name, byte[] data)671throws InstanceNotFoundException, OperationsException {672throw new UnsupportedOperationException("Not supported.");673}674675/**676* <p>De-serializes a byte array in the context of a given MBean677* class loader. The class loader is found by loading the class678* <code>className</code> through the {@link679* javax.management.loading.ClassLoaderRepository Class Loader680* Repository}. The resultant class's class loader is the one to681* use.682*683* @param className The name of the class whose class loader should be684* used for the de-serialization.685* @param data The byte array to be de-sererialized.686*687* @implSpec This method throws {@link UnsupportedOperationException} by default.688*689* @return The de-serialized object stream.690*691* @exception OperationsException Any of the usual Input/Output692* related exceptions.693* @exception ReflectionException The specified class could not be694* loaded by the class loader repository695*696* @deprecated Use {@link #getClassLoaderRepository} to obtain the697* class loader repository and use it to deserialize.698*/699@Deprecated(since="1.5")700default public ObjectInputStream deserialize(String className, byte[] data)701throws OperationsException, ReflectionException {702throw new UnsupportedOperationException("Not supported.");703}704705706/**707* <p>De-serializes a byte array in the context of a given MBean708* class loader. The class loader is the one that loaded the709* class with name "className". The name of the class loader to710* be used for loading the specified class is specified. If null,711* the MBean Server's class loader will be used.</p>712*713* @param className The name of the class whose class loader should be714* used for the de-serialization.715* @param data The byte array to be de-sererialized.716* @param loaderName The name of the class loader to be used for717* loading the specified class. If null, the MBean Server's class718* loader will be used.719*720* @implSpec This method throws {@link UnsupportedOperationException} by default.721*722* @return The de-serialized object stream.723*724* @exception InstanceNotFoundException The specified class loader725* MBean is not found.726* @exception OperationsException Any of the usual Input/Output727* related exceptions.728* @exception ReflectionException The specified class could not be729* loaded by the specified class loader.730*731* @deprecated Use {@link #getClassLoader getClassLoader} to obtain732* the class loader for deserialization.733*/734@Deprecated(since="1.5")735default public ObjectInputStream deserialize(String className,736ObjectName loaderName,737byte[] data)738throws InstanceNotFoundException, OperationsException,739ReflectionException {740throw new UnsupportedOperationException("Not supported.");741}742743/**744* <p>Return the {@link java.lang.ClassLoader} that was used for745* loading the class of the named MBean.</p>746*747* @param mbeanName The ObjectName of the MBean.748*749* @return The ClassLoader used for that MBean. If <var>l</var>750* is the MBean's actual ClassLoader, and <var>r</var> is the751* returned value, then either:752*753* <ul>754* <li><var>r</var> is identical to <var>l</var>; or755* <li>the result of <var>r</var>{@link756* ClassLoader#loadClass(String) .loadClass(<var>s</var>)} is the757* same as <var>l</var>{@link ClassLoader#loadClass(String)758* .loadClass(<var>s</var>)} for any string <var>s</var>.759* </ul>760*761* What this means is that the ClassLoader may be wrapped in762* another ClassLoader for security or other reasons.763*764* @exception InstanceNotFoundException if the named MBean is not found.765*766*/767public ClassLoader getClassLoaderFor(ObjectName mbeanName)768throws InstanceNotFoundException;769770/**771* <p>Return the named {@link java.lang.ClassLoader}.</p>772*773* @param loaderName The ObjectName of the ClassLoader. May be774* null, in which case the MBean server's own ClassLoader is775* returned.776*777* @return The named ClassLoader. If <var>l</var> is the actual778* ClassLoader with that name, and <var>r</var> is the returned779* value, then either:780*781* <ul>782* <li><var>r</var> is identical to <var>l</var>; or783* <li>the result of <var>r</var>{@link784* ClassLoader#loadClass(String) .loadClass(<var>s</var>)} is the785* same as <var>l</var>{@link ClassLoader#loadClass(String)786* .loadClass(<var>s</var>)} for any string <var>s</var>.787* </ul>788*789* What this means is that the ClassLoader may be wrapped in790* another ClassLoader for security or other reasons.791*792* @exception InstanceNotFoundException if the named ClassLoader is793* not found.794*795*/796public ClassLoader getClassLoader(ObjectName loaderName)797throws InstanceNotFoundException;798799/**800* <p>Return the ClassLoaderRepository for this MBeanServer.801* @return The ClassLoaderRepository for this MBeanServer.802*803*/804public ClassLoaderRepository getClassLoaderRepository();805}806807808