Path: blob/master/src/java.management/share/classes/javax/management/MBeanServerConnection.java
41155 views
/*1* Copyright (c) 2002, 2013, 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.io.IOException;30import java.util.Set;313233/**34* This interface represents a way to talk to an MBean server, whether35* local or remote. The {@link MBeanServer} interface, representing a36* local MBean server, extends this interface.37*38*39* @since 1.540*/41public interface MBeanServerConnection {42/**43* <p>Instantiates and registers an MBean in the MBean server. The44* MBean server will use its {@link45* javax.management.loading.ClassLoaderRepository Default Loader46* Repository} to load the class of the MBean. An object name is47* associated with the MBean. If the object name given is null, the48* MBean must provide its own name by implementing the {@link49* javax.management.MBeanRegistration MBeanRegistration} interface50* and returning the name from the {@link51* MBeanRegistration#preRegister preRegister} method.</p>52*53* <p>This method is equivalent to {@link54* #createMBean(String,ObjectName,Object[],String[])55* createMBean(className, name, (Object[]) null, (String[])56* null)}.</p>57*58* @param className The class name of the MBean to be instantiated.59* @param name The object name of the MBean. May be null.60*61* @return An <CODE>ObjectInstance</CODE>, containing the62* <CODE>ObjectName</CODE> and the Java class name of the newly63* instantiated MBean. If the contained <code>ObjectName</code>64* is <code>n</code>, the contained Java class name is65* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.66*67* @exception ReflectionException Wraps a68* <CODE>java.lang.ClassNotFoundException</CODE> or a69* <CODE>java.lang.Exception</CODE> that occurred70* when trying to invoke the MBean's constructor.71* @exception InstanceAlreadyExistsException The MBean is already72* under the control of the MBean server.73* @exception MBeanRegistrationException The74* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>75* interface) method of the MBean has thrown an exception. The76* MBean will not be registered.77* @exception RuntimeMBeanException If the MBean's constructor or its78* {@code preRegister} or {@code postRegister} method threw79* a {@code RuntimeException}. If the <CODE>postRegister</CODE>80* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a81* <CODE>RuntimeException</CODE>, the <CODE>createMBean</CODE> method will82* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation83* and registration succeeded. In such a case, the MBean will be actually84* registered even though the <CODE>createMBean</CODE> method85* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can86* also be thrown by <CODE>preRegister</CODE>, in which case the MBean87* will not be registered.88* @exception RuntimeErrorException If the <CODE>postRegister</CODE>89* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an90* <CODE>Error</CODE>, the <CODE>createMBean</CODE> method will91* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation92* and registration succeeded. In such a case, the MBean will be actually93* registered even though the <CODE>createMBean</CODE> method94* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can95* also be thrown by <CODE>preRegister</CODE>, in which case the MBean96* will not be registered.97* @exception MBeanException The constructor of the MBean has98* thrown an exception99* @exception NotCompliantMBeanException This class is not a JMX100* compliant MBean101* @exception RuntimeOperationsException Wraps a102* <CODE>java.lang.IllegalArgumentException</CODE>: The className103* passed in parameter is null, the <CODE>ObjectName</CODE> passed104* in parameter contains a pattern or no <CODE>ObjectName</CODE>105* is specified for the MBean.106* @exception IOException A communication problem occurred when107* talking to the MBean server.108* @see javax.management.MBeanRegistration109*/110public ObjectInstance createMBean(String className, ObjectName name)111throws ReflectionException, InstanceAlreadyExistsException,112MBeanRegistrationException, MBeanException,113NotCompliantMBeanException, IOException;114115/**116* <p>Instantiates and registers an MBean in the MBean server. The117* class loader to be used is identified by its object name. An118* object name is associated with the MBean. If the object name of119* the loader is null, the ClassLoader that loaded the MBean120* server will be used. If the MBean's object name given is null,121* the MBean must provide its own name by implementing the {@link122* javax.management.MBeanRegistration MBeanRegistration} interface123* and returning the name from the {@link124* MBeanRegistration#preRegister preRegister} method.</p>125*126* <p>This method is equivalent to {@link127* #createMBean(String,ObjectName,ObjectName,Object[],String[])128* createMBean(className, name, loaderName, (Object[]) null,129* (String[]) null)}.</p>130*131* @param className The class name of the MBean to be instantiated.132* @param name The object name of the MBean. May be null.133* @param loaderName The object name of the class loader to be used.134*135* @return An <CODE>ObjectInstance</CODE>, containing the136* <CODE>ObjectName</CODE> and the Java class name of the newly137* instantiated MBean. If the contained <code>ObjectName</code>138* is <code>n</code>, the contained Java class name is139* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.140*141* @exception ReflectionException Wraps a142* <CODE>java.lang.ClassNotFoundException</CODE> or a143* <CODE>java.lang.Exception</CODE> that occurred when trying to144* invoke the MBean's constructor.145* @exception InstanceAlreadyExistsException The MBean is already146* under the control of the MBean server.147* @exception MBeanRegistrationException The148* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>149* interface) method of the MBean has thrown an exception. The150* MBean will not be registered.151* @exception RuntimeMBeanException If the MBean's constructor or its152* {@code preRegister} or {@code postRegister} method threw153* a {@code RuntimeException}. If the <CODE>postRegister</CODE>154* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a155* <CODE>RuntimeException</CODE>, the <CODE>createMBean</CODE> method will156* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation157* and registration succeeded. In such a case, the MBean will be actually158* registered even though the <CODE>createMBean</CODE> method159* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can160* also be thrown by <CODE>preRegister</CODE>, in which case the MBean161* will not be registered.162* @exception RuntimeErrorException If the <CODE>postRegister</CODE>163* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an164* <CODE>Error</CODE>, the <CODE>createMBean</CODE> method will165* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation166* and registration succeeded. In such a case, the MBean will be actually167* registered even though the <CODE>createMBean</CODE> method168* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can169* also be thrown by <CODE>preRegister</CODE>, in which case the MBean170* will not be registered.171* @exception MBeanException The constructor of the MBean has172* thrown an exception173* @exception NotCompliantMBeanException This class is not a JMX174* compliant MBean175* @exception InstanceNotFoundException The specified class loader176* is not registered in the MBean server.177* @exception RuntimeOperationsException Wraps a178* <CODE>java.lang.IllegalArgumentException</CODE>: The className179* passed in parameter is null, the <CODE>ObjectName</CODE> passed180* in parameter contains a pattern or no <CODE>ObjectName</CODE>181* is specified for the MBean.182* @exception IOException A communication problem occurred when183* talking to the MBean server.184* @see javax.management.MBeanRegistration185*/186public ObjectInstance createMBean(String className, ObjectName name,187ObjectName loaderName)188throws ReflectionException, InstanceAlreadyExistsException,189MBeanRegistrationException, MBeanException,190NotCompliantMBeanException, InstanceNotFoundException,191IOException;192193194/**195* Instantiates and registers an MBean in the MBean server. The196* MBean server will use its {@link197* javax.management.loading.ClassLoaderRepository Default Loader198* Repository} to load the class of the MBean. An object name is199* associated with the MBean. If the object name given is null, the200* MBean must provide its own name by implementing the {@link201* javax.management.MBeanRegistration MBeanRegistration} interface202* and returning the name from the {@link203* MBeanRegistration#preRegister preRegister} method.204*205* @param className The class name of the MBean to be instantiated.206* @param name The object name of the MBean. May be null.207* @param params An array containing the parameters of the208* constructor to be invoked.209* @param signature An array containing the signature of the210* constructor to be invoked.211*212* @return An <CODE>ObjectInstance</CODE>, containing the213* <CODE>ObjectName</CODE> and the Java class name of the newly214* instantiated MBean. If the contained <code>ObjectName</code>215* is <code>n</code>, the contained Java class name is216* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.217*218* @exception ReflectionException Wraps a219* <CODE>java.lang.ClassNotFoundException</CODE> or a220* <CODE>java.lang.Exception</CODE> that occurred when trying to221* invoke the MBean's constructor.222* @exception InstanceAlreadyExistsException The MBean is already223* under the control of the MBean server.224* @exception MBeanRegistrationException The225* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>226* interface) method of the MBean has thrown an exception. The227* MBean will not be registered.228* @exception RuntimeMBeanException If the MBean's constructor or its229* {@code preRegister} or {@code postRegister} method threw230* a {@code RuntimeException}. If the <CODE>postRegister</CODE>231* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a232* <CODE>RuntimeException</CODE>, the <CODE>createMBean</CODE> method will233* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation234* and registration succeeded. In such a case, the MBean will be actually235* registered even though the <CODE>createMBean</CODE> method236* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can237* also be thrown by <CODE>preRegister</CODE>, in which case the MBean238* will not be registered.239* @exception RuntimeErrorException If the <CODE>postRegister</CODE>240* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an241* <CODE>Error</CODE>, the <CODE>createMBean</CODE> method will242* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation243* and registration succeeded. In such a case, the MBean will be actually244* registered even though the <CODE>createMBean</CODE> method245* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can246* also be thrown by <CODE>preRegister</CODE>, in which case the MBean247* will not be registered.248* @exception MBeanException The constructor of the MBean has249* thrown an exception250* @exception NotCompliantMBeanException This class is not a JMX251* compliant MBean252* @exception RuntimeOperationsException Wraps a253* <CODE>java.lang.IllegalArgumentException</CODE>: The className254* passed in parameter is null, the <CODE>ObjectName</CODE> passed255* in parameter contains a pattern or no <CODE>ObjectName</CODE>256* is specified for the MBean.257* @exception IOException A communication problem occurred when258* talking to the MBean server.259* @see javax.management.MBeanRegistration260*/261public ObjectInstance createMBean(String className, ObjectName name,262Object params[], String signature[])263throws ReflectionException, InstanceAlreadyExistsException,264MBeanRegistrationException, MBeanException,265NotCompliantMBeanException, IOException;266267/**268* <p>Instantiates and registers an MBean in the MBean server. The269* class loader to be used is identified by its object name. An270* object name is associated with the MBean. If the object name of271* the loader is not specified, the ClassLoader that loaded the272* MBean server will be used. If the MBean object name given is273* null, the MBean must provide its own name by implementing the274* {@link javax.management.MBeanRegistration MBeanRegistration}275* interface and returning the name from the {@link276* MBeanRegistration#preRegister preRegister} method.277*278* @param className The class name of the MBean to be instantiated.279* @param name The object name of the MBean. May be null.280* @param params An array containing the parameters of the281* constructor to be invoked.282* @param signature An array containing the signature of the283* constructor to be invoked.284* @param loaderName The object name of the class loader to be used.285*286* @return An <CODE>ObjectInstance</CODE>, containing the287* <CODE>ObjectName</CODE> and the Java class name of the newly288* instantiated MBean. If the contained <code>ObjectName</code>289* is <code>n</code>, the contained Java class name is290* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.291*292* @exception ReflectionException Wraps a293* <CODE>java.lang.ClassNotFoundException</CODE> or a294* <CODE>java.lang.Exception</CODE> that occurred when trying to295* invoke the MBean's constructor.296* @exception InstanceAlreadyExistsException The MBean is already297* under the control of the MBean server.298* @exception MBeanRegistrationException The299* <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>300* interface) method of the MBean has thrown an exception. The301* MBean will not be registered.302* @exception RuntimeMBeanException The MBean's constructor or its303* {@code preRegister} or {@code postRegister} method threw304* a {@code RuntimeException}. If the <CODE>postRegister</CODE>305* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a306* <CODE>RuntimeException</CODE>, the <CODE>createMBean</CODE> method will307* throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation308* and registration succeeded. In such a case, the MBean will be actually309* registered even though the <CODE>createMBean</CODE> method310* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can311* also be thrown by <CODE>preRegister</CODE>, in which case the MBean312* will not be registered.313* @exception RuntimeErrorException If the <CODE>postRegister</CODE> method314* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an315* <CODE>Error</CODE>, the <CODE>createMBean</CODE> method will316* throw a <CODE>RuntimeErrorException</CODE>, although the MBean creation317* and registration succeeded. In such a case, the MBean will be actually318* registered even though the <CODE>createMBean</CODE> method319* threw an exception. Note that <CODE>RuntimeErrorException</CODE> can320* also be thrown by <CODE>preRegister</CODE>, in which case the MBean321* will not be registered.322* @exception MBeanException The constructor of the MBean has323* thrown an exception324* @exception NotCompliantMBeanException This class is not a JMX325* compliant MBean326* @exception InstanceNotFoundException The specified class loader327* is not registered in the MBean server.328* @exception RuntimeOperationsException Wraps a329* <CODE>java.lang.IllegalArgumentException</CODE>: The className330* passed in parameter is null, the <CODE>ObjectName</CODE> passed331* in parameter contains a pattern or no <CODE>ObjectName</CODE>332* is specified for the MBean.333* @exception IOException A communication problem occurred when334* talking to the MBean server.335* @see javax.management.MBeanRegistration336*/337public ObjectInstance createMBean(String className, ObjectName name,338ObjectName loaderName, Object params[],339String signature[])340throws ReflectionException, InstanceAlreadyExistsException,341MBeanRegistrationException, MBeanException,342NotCompliantMBeanException, InstanceNotFoundException,343IOException;344345/**346* Unregisters an MBean from the MBean server. The MBean is347* identified by its object name. Once the method has been348* invoked, the MBean may no longer be accessed by its object349* name.350*351* @param name The object name of the MBean to be unregistered.352*353* @exception InstanceNotFoundException The MBean specified is not354* registered in the MBean server.355* @exception MBeanRegistrationException The preDeregister356* ((<CODE>MBeanRegistration</CODE> interface) method of the MBean357* has thrown an exception.358* @exception RuntimeMBeanException If the <CODE>postDeregister</CODE>359* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a360* <CODE>RuntimeException</CODE>, the <CODE>unregisterMBean</CODE> method361* will throw a <CODE>RuntimeMBeanException</CODE>, although the MBean362* unregistration succeeded. In such a case, the MBean will be actually363* unregistered even though the <CODE>unregisterMBean</CODE> method364* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can365* also be thrown by <CODE>preDeregister</CODE>, in which case the MBean366* will remain registered.367* @exception RuntimeErrorException If the <CODE>postDeregister</CODE>368* (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws an369* <CODE>Error</CODE>, the <CODE>unregisterMBean</CODE> method will370* throw a <CODE>RuntimeErrorException</CODE>, although the MBean371* unregistration succeeded. In such a case, the MBean will be actually372* unregistered even though the <CODE>unregisterMBean</CODE> method373* threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can374* also be thrown by <CODE>preDeregister</CODE>, in which case the MBean375* will remain registered.376* @exception RuntimeOperationsException Wraps a377* <CODE>java.lang.IllegalArgumentException</CODE>: The object378* name in parameter is null or the MBean you are when trying to379* unregister is the {@link javax.management.MBeanServerDelegate380* MBeanServerDelegate} MBean.381* @exception IOException A communication problem occurred when382* talking to the MBean server.383* @see javax.management.MBeanRegistration384*/385public void unregisterMBean(ObjectName name)386throws InstanceNotFoundException, MBeanRegistrationException,387IOException;388389/**390* Gets the <CODE>ObjectInstance</CODE> for a given MBean391* registered with the MBean server.392*393* @param name The object name of the MBean.394*395* @return The <CODE>ObjectInstance</CODE> associated with the MBean396* specified by <VAR>name</VAR>. The contained <code>ObjectName</code>397* is <code>name</code> and the contained class name is398* <code>{@link #getMBeanInfo getMBeanInfo(name)}.getClassName()</code>.399*400* @exception InstanceNotFoundException The MBean specified is not401* registered in the MBean server.402* @exception IOException A communication problem occurred when403* talking to the MBean server.404*/405public ObjectInstance getObjectInstance(ObjectName name)406throws InstanceNotFoundException, IOException;407408/**409* Gets MBeans controlled by the MBean server. This method allows410* any of the following to be obtained: All MBeans, a set of411* MBeans specified by pattern matching on the412* <CODE>ObjectName</CODE> and/or a Query expression, a specific413* MBean. When the object name is null or no domain and key414* properties are specified, all objects are to be selected (and415* filtered if a query is specified). It returns the set of416* <CODE>ObjectInstance</CODE> objects (containing the417* <CODE>ObjectName</CODE> and the Java Class name) for the418* selected MBeans.419*420* @param name The object name pattern identifying the MBeans to421* be retrieved. If null or no domain and key properties are422* specified, all the MBeans registered will be retrieved.423* @param query The query expression to be applied for selecting424* MBeans. If null no query expression will be applied for425* selecting MBeans.426*427* @return A set containing the <CODE>ObjectInstance</CODE>428* objects for the selected MBeans. If no MBean satisfies the429* query an empty list is returned.430*431* @exception IOException A communication problem occurred when432* talking to the MBean server.433*/434public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)435throws IOException;436437/**438* Gets the names of MBeans controlled by the MBean server. This439* method enables any of the following to be obtained: The names440* of all MBeans, the names of a set of MBeans specified by441* pattern matching on the <CODE>ObjectName</CODE> and/or a Query442* expression, a specific MBean name (equivalent to testing443* whether an MBean is registered). When the object name is null444* or no domain and key properties are specified, all objects are445* selected (and filtered if a query is specified). It returns the446* set of ObjectNames for the MBeans selected.447*448* @param name The object name pattern identifying the MBean names449* to be retrieved. If null or no domain and key properties are450* specified, the name of all registered MBeans will be retrieved.451* @param query The query expression to be applied for selecting452* MBeans. If null no query expression will be applied for453* selecting MBeans.454*455* @return A set containing the ObjectNames for the MBeans456* selected. If no MBean satisfies the query, an empty list is457* returned.458*459* @exception IOException A communication problem occurred when460* talking to the MBean server.461*/462public Set<ObjectName> queryNames(ObjectName name, QueryExp query)463throws IOException;464465466467/**468* Checks whether an MBean, identified by its object name, is469* already registered with the MBean server.470*471* @param name The object name of the MBean to be checked.472*473* @return True if the MBean is already registered in the MBean474* server, false otherwise.475*476* @exception RuntimeOperationsException Wraps a477* <CODE>java.lang.IllegalArgumentException</CODE>: The object478* name in parameter is null.479* @exception IOException A communication problem occurred when480* talking to the MBean server.481*/482public boolean isRegistered(ObjectName name)483throws IOException;484485486/**487* Returns the number of MBeans registered in the MBean server.488*489* @return the number of MBeans registered.490*491* @exception IOException A communication problem occurred when492* talking to the MBean server.493*/494public Integer getMBeanCount()495throws IOException;496497/**498* Gets the value of a specific attribute of a named MBean. The MBean499* is identified by its object name.500*501* @param name The object name of the MBean from which the502* attribute is to be retrieved.503* @param attribute A String specifying the name of the attribute504* to be retrieved.505*506* @return The value of the retrieved attribute.507*508* @exception AttributeNotFoundException The attribute specified509* is not accessible in the MBean.510* @exception MBeanException Wraps an exception thrown by the511* MBean's getter.512* @exception InstanceNotFoundException The MBean specified is not513* registered in the MBean server.514* @exception ReflectionException Wraps a515* <CODE>java.lang.Exception</CODE> thrown when trying to invoke516* the setter.517* @exception RuntimeOperationsException Wraps a518* <CODE>java.lang.IllegalArgumentException</CODE>: The object519* name in parameter is null or the attribute in parameter is520* null.521* @exception IOException A communication problem occurred when522* talking to the MBean server.523*524* @see #setAttribute525*/526public Object getAttribute(ObjectName name, String attribute)527throws MBeanException, AttributeNotFoundException,528InstanceNotFoundException, ReflectionException,529IOException;530531532/**533* <p>Retrieves the values of several attributes of a named MBean. The MBean534* is identified by its object name.</p>535*536* <p>If one or more attributes cannot be retrieved for some reason, they537* will be omitted from the returned {@code AttributeList}. The caller538* should check that the list is the same size as the {@code attributes}539* array. To discover what problem prevented a given attribute from being540* retrieved, call {@link #getAttribute getAttribute} for that attribute.</p>541*542* <p>Here is an example of calling this method and checking that it543* succeeded in retrieving all the requested attributes:</p>544*545* <pre>546* String[] attrNames = ...;547* AttributeList list = mbeanServerConnection.getAttributes(objectName, attrNames);548* if (list.size() == attrNames.length)549* System.out.println("All attributes were retrieved successfully");550* else {551* {@code List<String>} missing = new {@code ArrayList<String>}(<!--552* -->{@link java.util.Arrays#asList Arrays.asList}(attrNames));553* for (Attribute a : list.asList())554* missing.remove(a.getName());555* System.out.println("Did not retrieve: " + missing);556* }557* </pre>558*559* @param name The object name of the MBean from which the560* attributes are retrieved.561* @param attributes A list of the attributes to be retrieved.562*563* @return The list of the retrieved attributes.564*565* @exception InstanceNotFoundException The MBean specified is not566* registered in the MBean server.567* @exception ReflectionException An exception occurred when568* trying to invoke the getAttributes method of a Dynamic MBean.569* @exception RuntimeOperationsException Wrap a570* <CODE>java.lang.IllegalArgumentException</CODE>: The object571* name in parameter is null or attributes in parameter is null.572* @exception IOException A communication problem occurred when573* talking to the MBean server.574*575* @see #setAttributes576*/577public AttributeList getAttributes(ObjectName name, String[] attributes)578throws InstanceNotFoundException, ReflectionException,579IOException;580581582/**583* Sets the value of a specific attribute of a named MBean. The MBean584* is identified by its object name.585*586* @param name The name of the MBean within which the attribute is587* to be set.588* @param attribute The identification of the attribute to be set589* and the value it is to be set to.590*591* @exception InstanceNotFoundException The MBean specified is not592* registered in the MBean server.593* @exception AttributeNotFoundException The attribute specified594* is not accessible in the MBean.595* @exception InvalidAttributeValueException The value specified596* for the attribute is not valid.597* @exception MBeanException Wraps an exception thrown by the598* MBean's setter.599* @exception ReflectionException Wraps a600* <CODE>java.lang.Exception</CODE> thrown when trying to invoke601* the setter.602* @exception RuntimeOperationsException Wraps a603* <CODE>java.lang.IllegalArgumentException</CODE>: The object604* name in parameter is null or the attribute in parameter is605* null.606* @exception IOException A communication problem occurred when607* talking to the MBean server.608*609* @see #getAttribute610*/611public void setAttribute(ObjectName name, Attribute attribute)612throws InstanceNotFoundException, AttributeNotFoundException,613InvalidAttributeValueException, MBeanException,614ReflectionException, IOException;615616617/**618* <p>Sets the values of several attributes of a named MBean. The MBean is619* identified by its object name.</p>620*621* <p>If one or more attributes cannot be set for some reason, they will be622* omitted from the returned {@code AttributeList}. The caller should check623* that the input {@code AttributeList} is the same size as the output one.624* To discover what problem prevented a given attribute from being retrieved,625* it will usually be possible to call {@link #setAttribute setAttribute}626* for that attribute, although this is not guaranteed to work. (For627* example, the values of two attributes may have been rejected because628* they were inconsistent with each other. Setting one of them alone might629* be allowed.)630*631* <p>Here is an example of calling this method and checking that it632* succeeded in setting all the requested attributes:</p>633*634* <pre>635* AttributeList inputAttrs = ...;636* AttributeList outputAttrs = mbeanServerConnection.setAttributes(<!--637* -->objectName, inputAttrs);638* if (inputAttrs.size() == outputAttrs.size())639* System.out.println("All attributes were set successfully");640* else {641* {@code List<String>} missing = new {@code ArrayList<String>}();642* for (Attribute a : inputAttrs.asList())643* missing.add(a.getName());644* for (Attribute a : outputAttrs.asList())645* missing.remove(a.getName());646* System.out.println("Did not set: " + missing);647* }648* </pre>649*650* @param name The object name of the MBean within which the651* attributes are to be set.652* @param attributes A list of attributes: The identification of653* the attributes to be set and the values they are to be set to.654*655* @return The list of attributes that were set, with their new656* values.657*658* @exception InstanceNotFoundException The MBean specified is not659* registered in the MBean server.660* @exception ReflectionException An exception occurred when661* trying to invoke the getAttributes method of a Dynamic MBean.662* @exception RuntimeOperationsException Wraps a663* <CODE>java.lang.IllegalArgumentException</CODE>: The object664* name in parameter is null or attributes in parameter is null.665* @exception IOException A communication problem occurred when666* talking to the MBean server.667*668* @see #getAttributes669*/670public AttributeList setAttributes(ObjectName name,671AttributeList attributes)672throws InstanceNotFoundException, ReflectionException, IOException;673674/**675* <p>Invokes an operation on an MBean.</p>676*677* <p>Because of the need for a {@code signature} to differentiate678* possibly-overloaded operations, it is much simpler to invoke operations679* through an {@linkplain JMX#newMBeanProxy(MBeanServerConnection, ObjectName,680* Class) MBean proxy} where possible. For example, suppose you have a681* Standard MBean interface like this:</p>682*683* <pre>684* public interface FooMBean {685* public int countMatches(String[] patterns, boolean ignoreCase);686* }687* </pre>688*689* <p>The {@code countMatches} operation can be invoked as follows:</p>690*691* <pre>692* String[] myPatterns = ...;693* int count = (Integer) mbeanServerConnection.invoke(694* objectName,695* "countMatches",696* new Object[] {myPatterns, true},697* new String[] {String[].class.getName(), boolean.class.getName()});698* </pre>699*700* <p>Alternatively, it can be invoked through a proxy as follows:</p>701*702* <pre>703* String[] myPatterns = ...;704* FooMBean fooProxy = JMX.newMBeanProxy(705* mbeanServerConnection, objectName, FooMBean.class);706* int count = fooProxy.countMatches(myPatterns, true);707* </pre>708*709* @param name The object name of the MBean on which the method is710* to be invoked.711* @param operationName The name of the operation to be invoked.712* @param params An array containing the parameters to be set when713* the operation is invoked714* @param signature An array containing the signature of the715* operation, an array of class names in the format returned by716* {@link Class#getName()}. The class objects will be loaded using the same717* class loader as the one used for loading the MBean on which the718* operation was invoked.719*720* @return The object returned by the operation, which represents721* the result of invoking the operation on the MBean specified.722*723* @exception InstanceNotFoundException The MBean specified is not724* registered in the MBean server.725* @exception MBeanException Wraps an exception thrown by the726* MBean's invoked method.727* @exception ReflectionException Wraps a728* <CODE>java.lang.Exception</CODE> thrown while trying to invoke729* the method.730* @exception IOException A communication problem occurred when731* talking to the MBean server.732*733*/734public Object invoke(ObjectName name, String operationName,735Object params[], String signature[])736throws InstanceNotFoundException, MBeanException,737ReflectionException, IOException;738739740741/**742* Returns the default domain used for naming the MBean.743* The default domain name is used as the domain part in the ObjectName744* of MBeans if no domain is specified by the user.745*746* @return the default domain.747*748* @exception IOException A communication problem occurred when749* talking to the MBean server.750*/751public String getDefaultDomain()752throws IOException;753754/**755* <p>Returns the list of domains in which any MBean is currently756* registered. A string is in the returned array if and only if757* there is at least one MBean registered with an ObjectName whose758* {@link ObjectName#getDomain() getDomain()} is equal to that759* string. The order of strings within the returned array is760* not defined.</p>761*762* @return the list of domains.763*764* @exception IOException A communication problem occurred when765* talking to the MBean server.766*767*/768public String[] getDomains()769throws IOException;770771/**772* <p>Adds a listener to a registered MBean.773* Notifications emitted by the MBean will be forwarded to the listener.</p>774*775* @param name The name of the MBean on which the listener should776* be added.777* @param listener The listener object which will handle the778* notifications emitted by the registered MBean.779* @param filter The filter object. If filter is null, no780* filtering will be performed before handling notifications.781* @param handback The context to be sent to the listener when a782* notification is emitted.783*784* @exception InstanceNotFoundException The MBean name provided785* does not match any of the registered MBeans.786* @exception IOException A communication problem occurred when787* talking to the MBean server.788*789* @see #removeNotificationListener(ObjectName, NotificationListener)790* @see #removeNotificationListener(ObjectName, NotificationListener,791* NotificationFilter, Object)792*/793public void addNotificationListener(ObjectName name,794NotificationListener listener,795NotificationFilter filter,796Object handback)797throws InstanceNotFoundException, IOException;798799800/**801* <p>Adds a listener to a registered MBean.</p>802*803* <p>A notification emitted by an MBean will be forwarded by the804* MBeanServer to the listener. If the source of the notification805* is a reference to an MBean object, the MBean server will806* replace it by that MBean's ObjectName. Otherwise the source is807* unchanged.</p>808*809* <p>The listener object that receives notifications is the one810* that is registered with the given name at the time this method811* is called. Even if it is subsequently unregistered, it will812* continue to receive notifications.</p>813*814* @param name The name of the MBean on which the listener should815* be added.816* @param listener The object name of the listener which will817* handle the notifications emitted by the registered MBean.818* @param filter The filter object. If filter is null, no819* filtering will be performed before handling notifications.820* @param handback The context to be sent to the listener when a821* notification is emitted.822*823* @exception InstanceNotFoundException The MBean name of the824* notification listener or of the notification broadcaster does825* not match any of the registered MBeans.826* @exception RuntimeOperationsException Wraps an {@link827* IllegalArgumentException}. The MBean named by828* <code>listener</code> exists but does not implement the {@link829* NotificationListener} interface.830* @exception IOException A communication problem occurred when831* talking to the MBean server.832*833* @see #removeNotificationListener(ObjectName, ObjectName)834* @see #removeNotificationListener(ObjectName, ObjectName,835* NotificationFilter, Object)836*/837public void addNotificationListener(ObjectName name,838ObjectName listener,839NotificationFilter filter,840Object handback)841throws InstanceNotFoundException, IOException;842843844/**845* Removes a listener from a registered MBean.846*847* <P> If the listener is registered more than once, perhaps with848* different filters or callbacks, this method will remove all849* those registrations.850*851* @param name The name of the MBean on which the listener should852* be removed.853* @param listener The object name of the listener to be removed.854*855* @exception InstanceNotFoundException The MBean name provided856* does not match any of the registered MBeans.857* @exception ListenerNotFoundException The listener is not858* registered in the MBean.859* @exception IOException A communication problem occurred when860* talking to the MBean server.861*862* @see #addNotificationListener(ObjectName, ObjectName,863* NotificationFilter, Object)864*/865public void removeNotificationListener(ObjectName name,866ObjectName listener)867throws InstanceNotFoundException, ListenerNotFoundException,868IOException;869870/**871* <p>Removes a listener from a registered MBean.</p>872*873* <p>The MBean must have a listener that exactly matches the874* given <code>listener</code>, <code>filter</code>, and875* <code>handback</code> parameters. If there is more than one876* such listener, only one is removed.</p>877*878* <p>The <code>filter</code> and <code>handback</code> parameters879* may be null if and only if they are null in a listener to be880* removed.</p>881*882* @param name The name of the MBean on which the listener should883* be removed.884* @param listener The object name of the listener to be removed.885* @param filter The filter that was specified when the listener886* was added.887* @param handback The handback that was specified when the888* listener was added.889*890* @exception InstanceNotFoundException The MBean name provided891* does not match any of the registered MBeans.892* @exception ListenerNotFoundException The listener is not893* registered in the MBean, or it is not registered with the given894* filter and handback.895* @exception IOException A communication problem occurred when896* talking to the MBean server.897*898* @see #addNotificationListener(ObjectName, ObjectName,899* NotificationFilter, Object)900*901*/902public void removeNotificationListener(ObjectName name,903ObjectName listener,904NotificationFilter filter,905Object handback)906throws InstanceNotFoundException, ListenerNotFoundException,907IOException;908909910/**911* <p>Removes a listener from a registered MBean.</p>912*913* <P> If the listener is registered more than once, perhaps with914* different filters or callbacks, this method will remove all915* those registrations.916*917* @param name The name of the MBean on which the listener should918* be removed.919* @param listener The listener to be removed.920*921* @exception InstanceNotFoundException The MBean name provided922* does not match any of the registered MBeans.923* @exception ListenerNotFoundException The listener is not924* registered in the MBean.925* @exception IOException A communication problem occurred when926* talking to the MBean server.927*928* @see #addNotificationListener(ObjectName, NotificationListener,929* NotificationFilter, Object)930*/931public void removeNotificationListener(ObjectName name,932NotificationListener listener)933throws InstanceNotFoundException, ListenerNotFoundException,934IOException;935936/**937* <p>Removes a listener from a registered MBean.</p>938*939* <p>The MBean must have a listener that exactly matches the940* given <code>listener</code>, <code>filter</code>, and941* <code>handback</code> parameters. If there is more than one942* such listener, only one is removed.</p>943*944* <p>The <code>filter</code> and <code>handback</code> parameters945* may be null if and only if they are null in a listener to be946* removed.</p>947*948* @param name The name of the MBean on which the listener should949* be removed.950* @param listener The listener to be removed.951* @param filter The filter that was specified when the listener952* was added.953* @param handback The handback that was specified when the954* listener was added.955*956* @exception InstanceNotFoundException The MBean name provided957* does not match any of the registered MBeans.958* @exception ListenerNotFoundException The listener is not959* registered in the MBean, or it is not registered with the given960* filter and handback.961* @exception IOException A communication problem occurred when962* talking to the MBean server.963*964* @see #addNotificationListener(ObjectName, NotificationListener,965* NotificationFilter, Object)966*967*/968public void removeNotificationListener(ObjectName name,969NotificationListener listener,970NotificationFilter filter,971Object handback)972throws InstanceNotFoundException, ListenerNotFoundException,973IOException;974975/**976* This method discovers the attributes and operations that an977* MBean exposes for management.978*979* @param name The name of the MBean to analyze980*981* @return An instance of <CODE>MBeanInfo</CODE> allowing the982* retrieval of all attributes and operations of this MBean.983*984* @exception IntrospectionException An exception occurred during985* introspection.986* @exception InstanceNotFoundException The MBean specified was987* not found.988* @exception ReflectionException An exception occurred when989* trying to invoke the getMBeanInfo of a Dynamic MBean.990* @exception IOException A communication problem occurred when991* talking to the MBean server.992*/993public MBeanInfo getMBeanInfo(ObjectName name)994throws InstanceNotFoundException, IntrospectionException,995ReflectionException, IOException;996997998/**999* <p>Returns true if the MBean specified is an instance of the1000* specified class, false otherwise.</p>1001*1002* <p>If <code>name</code> does not name an MBean, this method1003* throws {@link InstanceNotFoundException}.</p>1004*1005* <p>Otherwise, let<br>1006* X be the MBean named by <code>name</code>,<br>1007* L be the ClassLoader of X,<br>1008* N be the class name in X's {@link MBeanInfo}.</p>1009*1010* <p>If N equals <code>className</code>, the result is true.</p>1011*1012* <p>Otherwise, if L successfully loads <code>className</code>1013* and X is an instance of this class, the result is true.1014*1015* <p>Otherwise, if L successfully loads both N and1016* <code>className</code>, and the second class is assignable from1017* the first, the result is true.</p>1018*1019* <p>Otherwise, the result is false.</p>1020*1021* @param name The <CODE>ObjectName</CODE> of the MBean.1022* @param className The name of the class.1023*1024* @return true if the MBean specified is an instance of the1025* specified class according to the rules above, false otherwise.1026*1027* @exception InstanceNotFoundException The MBean specified is not1028* registered in the MBean server.1029* @exception IOException A communication problem occurred when1030* talking to the MBean server.1031*1032* @see Class#isInstance1033*/1034public boolean isInstanceOf(ObjectName name, String className)1035throws InstanceNotFoundException, IOException;1036}103710381039