Path: blob/master/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnection.java
41162 views
/*1* Copyright (c) 2002, 2017, 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.remote.rmi;2627import java.io.Closeable;28import java.io.IOException;29import java.rmi.MarshalledObject;30import java.rmi.Remote;31import java.util.Set;3233import javax.management.AttributeList;34import javax.management.AttributeNotFoundException;35import javax.management.InstanceAlreadyExistsException;36import javax.management.InstanceNotFoundException;37import javax.management.IntrospectionException;38import javax.management.InvalidAttributeValueException;39import javax.management.ListenerNotFoundException;40import javax.management.MBeanException;41import javax.management.MBeanInfo;42import javax.management.MBeanRegistrationException;43import javax.management.MBeanServerConnection;44import javax.management.NotCompliantMBeanException;4546import javax.management.ObjectInstance;47import javax.management.ObjectName;48import javax.management.ReflectionException;49import javax.management.RuntimeMBeanException;50import javax.management.RuntimeOperationsException;51import javax.management.remote.NotificationResult;52import javax.security.auth.Subject;5354/**55* <p>RMI object used to forward an MBeanServer request from a client56* to its MBeanServer implementation on the server side. There is one57* Remote object implementing this interface for each remote client58* connected to an RMI connector.</p>59*60* <p>User code does not usually refer to this interface. It is61* specified as part of the public API so that different62* implementations of that API will interoperate.</p>63*64* <p>To ensure that client parameters will be deserialized at the65* server side with the correct classloader, client parameters such as66* parameters used to invoke a method are wrapped in a {@link67* MarshalledObject}. An implementation of this interface must first68* get the appropriate class loader for the operation and its target,69* then deserialize the marshalled parameters with this classloader.70* Except as noted, a parameter that is a71* <code>MarshalledObject</code> or <code>MarshalledObject[]</code>72* must not be null; the behavior is unspecified if it is.</p>73*74* <p>Class loading aspects are detailed in the75* <a href="https://jcp.org/aboutJava/communityprocess/mrel/jsr160/index2.html">76* JMX Specification, version 1.4</a></p>77*78* <p>Most methods in this interface parallel methods in the {@link79* MBeanServerConnection} interface. Where an aspect of the behavior80* of a method is not specified here, it is the same as in the81* corresponding <code>MBeanServerConnection</code> method.82*83* @since 1.584*/85/*86* Notice that we omit the type parameter from MarshalledObject everywhere,87* even though it would add useful information to the documentation. The88* reason is that it was only added in Mustang (Java SE 6), whereas versions89* 1.4 and 2.0 of the JMX API must be implementable on Tiger per our90* commitments for JSR 255. This is also why we suppress rawtypes warnings.91*/92@SuppressWarnings("rawtypes")93public interface RMIConnection extends Closeable, Remote {94/**95* <p>Returns the connection ID. This string is different for96* every open connection to a given RMI connector server.</p>97*98* @return the connection ID99*100* @see RMIConnector#connect RMIConnector.connect101*102* @throws IOException if a general communication exception occurred.103*/104public String getConnectionId() throws IOException;105106/**107* <p>Closes this connection. On return from this method, the RMI108* object implementing this interface is unexported, so further109* remote calls to it will fail.</p>110*111* @throws IOException if the connection could not be closed,112* or the Remote object could not be unexported, or there was a113* communication failure when transmitting the remote close114* request.115*/116public void close() throws IOException;117118/**119* Handles the method {@link120* javax.management.MBeanServerConnection#createMBean(String,121* ObjectName)}.122*123* @param className The class name of the MBean to be instantiated.124* @param name The object name of the MBean. May be null.125* @param delegationSubject The <code>Subject</code> containing the126* delegation principals or <code>null</code> if the authentication127* principal is used instead.128*129* @return An <code>ObjectInstance</code>, containing the130* <code>ObjectName</code> and the Java class name of the newly131* instantiated MBean. If the contained <code>ObjectName</code>132* is <code>n</code>, the contained Java class name is133* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.134*135* @throws ReflectionException Wraps a136* <code>java.lang.ClassNotFoundException</code> or a137* <code>java.lang.Exception</code> that occurred138* when trying to invoke the MBean's constructor.139* @throws InstanceAlreadyExistsException The MBean is already140* under the control of the MBean server.141* @throws MBeanRegistrationException The142* <code>preRegister</code> (<code>MBeanRegistration</code>143* interface) method of the MBean has thrown an exception. The144* MBean will not be registered.145* @throws MBeanException The constructor of the MBean has146* thrown an exception.147* @throws NotCompliantMBeanException This class is not a JMX148* compliant MBean.149* @throws RuntimeOperationsException Wraps a150* <code>java.lang.IllegalArgumentException</code>: The className151* passed in parameter is null, the <code>ObjectName</code> passed152* in parameter contains a pattern or no <code>ObjectName</code>153* is specified for the MBean.154* @throws SecurityException if the client, or the delegated Subject155* if any, does not have permission to perform this operation.156* @throws IOException if a general communication exception occurred.157*/158public ObjectInstance createMBean(String className,159ObjectName name,160Subject delegationSubject)161throws162ReflectionException,163InstanceAlreadyExistsException,164MBeanRegistrationException,165MBeanException,166NotCompliantMBeanException,167IOException;168169/**170* Handles the method {@link171* javax.management.MBeanServerConnection#createMBean(String,172* ObjectName, ObjectName)}.173*174* @param className The class name of the MBean to be instantiated.175* @param name The object name of the MBean. May be null.176* @param loaderName The object name of the class loader to be used.177* @param delegationSubject The <code>Subject</code> containing the178* delegation principals or <code>null</code> if the authentication179* principal is used instead.180*181* @return An <code>ObjectInstance</code>, containing the182* <code>ObjectName</code> and the Java class name of the newly183* instantiated MBean. If the contained <code>ObjectName</code>184* is <code>n</code>, the contained Java class name is185* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.186*187* @throws ReflectionException Wraps a188* <code>java.lang.ClassNotFoundException</code> or a189* <code>java.lang.Exception</code> that occurred when trying to190* invoke the MBean's constructor.191* @throws InstanceAlreadyExistsException The MBean is already192* under the control of the MBean server.193* @throws MBeanRegistrationException The194* <code>preRegister</code> (<code>MBeanRegistration</code>195* interface) method of the MBean has thrown an exception. The196* MBean will not be registered.197* @throws MBeanException The constructor of the MBean has198* thrown an exception.199* @throws NotCompliantMBeanException This class is not a JMX200* compliant MBean.201* @throws InstanceNotFoundException The specified class loader202* is not registered in the MBean server.203* @throws RuntimeOperationsException Wraps a204* <code>java.lang.IllegalArgumentException</code>: The className205* passed in parameter is null, the <code>ObjectName</code> passed206* in parameter contains a pattern or no <code>ObjectName</code>207* is specified for the MBean.208* @throws SecurityException if the client, or the delegated Subject209* if any, does not have permission to perform this operation.210* @throws IOException if a general communication exception occurred.211*/212public ObjectInstance createMBean(String className,213ObjectName name,214ObjectName loaderName,215Subject delegationSubject)216throws217ReflectionException,218InstanceAlreadyExistsException,219MBeanRegistrationException,220MBeanException,221NotCompliantMBeanException,222InstanceNotFoundException,223IOException;224225/**226* Handles the method {@link227* javax.management.MBeanServerConnection#createMBean(String,228* ObjectName, Object[], String[])}. The <code>Object[]</code>229* parameter is wrapped in a <code>MarshalledObject</code>.230*231* @param className The class name of the MBean to be instantiated.232* @param name The object name of the MBean. May be null.233* @param params An array containing the parameters of the234* constructor to be invoked, encapsulated into a235* <code>MarshalledObject</code>. The encapsulated array can be236* null, equivalent to an empty array.237* @param signature An array containing the signature of the238* constructor to be invoked. Can be null, equivalent to an empty239* array.240* @param delegationSubject The <code>Subject</code> containing the241* delegation principals or <code>null</code> if the authentication242* principal is used instead.243*244* @return An <code>ObjectInstance</code>, containing the245* <code>ObjectName</code> and the Java class name of the newly246* instantiated MBean. If the contained <code>ObjectName</code>247* is <code>n</code>, the contained Java class name is248* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.249*250* @throws ReflectionException Wraps a251* <code>java.lang.ClassNotFoundException</code> or a252* <code>java.lang.Exception</code> that occurred when trying to253* invoke the MBean's constructor.254* @throws InstanceAlreadyExistsException The MBean is already255* under the control of the MBean server.256* @throws MBeanRegistrationException The257* <code>preRegister</code> (<code>MBeanRegistration</code>258* interface) method of the MBean has thrown an exception. The259* MBean will not be registered.260* @throws MBeanException The constructor of the MBean has261* thrown an exception.262* @throws NotCompliantMBeanException This class is not a JMX263* compliant MBean.264* @throws RuntimeOperationsException Wraps a265* <code>java.lang.IllegalArgumentException</code>: The className266* passed in parameter is null, the <code>ObjectName</code> passed267* in parameter contains a pattern, or no <code>ObjectName</code>268* is specified for the MBean.269* @throws SecurityException if the client, or the delegated Subject270* if any, does not have permission to perform this operation.271* @throws IOException if a general communication exception occurred.272*/273public ObjectInstance createMBean(String className,274ObjectName name,275MarshalledObject params,276String signature[],277Subject delegationSubject)278throws279ReflectionException,280InstanceAlreadyExistsException,281MBeanRegistrationException,282MBeanException,283NotCompliantMBeanException,284IOException;285286/**287* Handles the method {@link288* javax.management.MBeanServerConnection#createMBean(String,289* ObjectName, ObjectName, Object[], String[])}. The290* <code>Object[]</code> parameter is wrapped in a291* <code>MarshalledObject</code>.292*293* @param className The class name of the MBean to be instantiated.294* @param name The object name of the MBean. May be null.295* @param loaderName The object name of the class loader to be used.296* @param params An array containing the parameters of the297* constructor to be invoked, encapsulated into a298* <code>MarshalledObject</code>. The encapsulated array can be299* null, equivalent to an empty array.300* @param signature An array containing the signature of the301* constructor to be invoked. Can be null, equivalent to an empty302* array.303* @param delegationSubject The <code>Subject</code> containing the304* delegation principals or <code>null</code> if the authentication305* principal is used instead.306*307* @return An <code>ObjectInstance</code>, containing the308* <code>ObjectName</code> and the Java class name of the newly309* instantiated MBean. If the contained <code>ObjectName</code>310* is <code>n</code>, the contained Java class name is311* <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.312*313* @throws ReflectionException Wraps a314* <code>java.lang.ClassNotFoundException</code> or a315* <code>java.lang.Exception</code> that occurred when trying to316* invoke the MBean's constructor.317* @throws InstanceAlreadyExistsException The MBean is already318* under the control of the MBean server.319* @throws MBeanRegistrationException The320* <code>preRegister</code> (<code>MBeanRegistration</code>321* interface) method of the MBean has thrown an exception. The322* MBean will not be registered.323* @throws MBeanException The constructor of the MBean has324* thrown an exception.325* @throws NotCompliantMBeanException This class is not a JMX326* compliant MBean.327* @throws InstanceNotFoundException The specified class loader328* is not registered in the MBean server.329* @throws RuntimeOperationsException Wraps a330* <code>java.lang.IllegalArgumentException</code>: The className331* passed in parameter is null, the <code>ObjectName</code> passed332* in parameter contains a pattern, or no <code>ObjectName</code>333* is specified for the MBean.334* @throws SecurityException if the client, or the delegated Subject335* if any, does not have permission to perform this operation.336* @throws IOException if a general communication exception occurred.337*/338public ObjectInstance createMBean(String className,339ObjectName name,340ObjectName loaderName,341MarshalledObject params,342String signature[],343Subject delegationSubject)344throws345ReflectionException,346InstanceAlreadyExistsException,347MBeanRegistrationException,348MBeanException,349NotCompliantMBeanException,350InstanceNotFoundException,351IOException;352353/**354* Handles the method355* {@link javax.management.MBeanServerConnection#unregisterMBean(ObjectName)}.356*357* @param name The object name of the MBean to be unregistered.358* @param delegationSubject The <code>Subject</code> containing the359* delegation principals or <code>null</code> if the authentication360* principal is used instead.361*362* @throws InstanceNotFoundException The MBean specified is not363* registered in the MBean server.364* @throws MBeanRegistrationException The preDeregister365* ((<code>MBeanRegistration</code> interface) method of the MBean366* has thrown an exception.367* @throws RuntimeOperationsException Wraps a368* <code>java.lang.IllegalArgumentException</code>: The object369* name in parameter is null or the MBean you are when trying to370* unregister is the {@link javax.management.MBeanServerDelegate371* MBeanServerDelegate} MBean.372* @throws SecurityException if the client, or the delegated Subject373* if any, does not have permission to perform this operation.374* @throws IOException if a general communication exception occurred.375*/376public void unregisterMBean(ObjectName name, Subject delegationSubject)377throws378InstanceNotFoundException,379MBeanRegistrationException,380IOException;381382/**383* Handles the method384* {@link javax.management.MBeanServerConnection#getObjectInstance(ObjectName)}.385*386* @param name The object name of the MBean.387* @param delegationSubject The <code>Subject</code> containing the388* delegation principals or <code>null</code> if the authentication389* principal is used instead.390*391* @return The <code>ObjectInstance</code> associated with the MBean392* specified by <var>name</var>. The contained <code>ObjectName</code>393* is <code>name</code> and the contained class name is394* <code>{@link #getMBeanInfo getMBeanInfo(name)}.getClassName()</code>.395*396* @throws InstanceNotFoundException The MBean specified is not397* registered in the MBean server.398* @throws RuntimeOperationsException Wraps a399* <code>java.lang.IllegalArgumentException</code>: The object400* name in parameter is null.401* @throws SecurityException if the client, or the delegated Subject402* if any, does not have permission to perform this operation.403* @throws IOException if a general communication exception occurred.404*/405public ObjectInstance getObjectInstance(ObjectName name,406Subject delegationSubject)407throws InstanceNotFoundException, IOException;408409/**410* Handles the method {@link411* javax.management.MBeanServerConnection#queryMBeans(ObjectName,412* QueryExp)}. The <code>QueryExp</code> is wrapped in a413* <code>MarshalledObject</code>.414*415* @param name The object name pattern identifying the MBeans to416* be retrieved. If null or no domain and key properties are417* specified, all the MBeans registered will be retrieved.418* @param query The query expression to be applied for selecting419* MBeans, encapsulated into a <code>MarshalledObject</code>. If420* the <code>MarshalledObject</code> encapsulates a null value no421* query expression will be applied for selecting MBeans.422* @param delegationSubject The <code>Subject</code> containing the423* delegation principals or <code>null</code> if the authentication424* principal is used instead.425*426* @return A set containing the <code>ObjectInstance</code>427* objects for the selected MBeans. If no MBean satisfies the428* query an empty list is returned.429*430* @throws SecurityException if the client, or the delegated Subject431* if any, does not have permission to perform this operation.432* @throws IOException if a general communication exception occurred.433*/434public Set<ObjectInstance>435queryMBeans(ObjectName name,436MarshalledObject query,437Subject delegationSubject)438throws IOException;439440/**441* Handles the method {@link442* javax.management.MBeanServerConnection#queryNames(ObjectName,443* QueryExp)}. The <code>QueryExp</code> is wrapped in a444* <code>MarshalledObject</code>.445*446* @param name The object name pattern identifying the MBean names447* to be retrieved. If null or no domain and key properties are448* specified, the name of all registered MBeans will be retrieved.449* @param query The query expression to be applied for selecting450* MBeans, encapsulated into a <code>MarshalledObject</code>. If451* the <code>MarshalledObject</code> encapsulates a null value no452* query expression will be applied for selecting MBeans.453* @param delegationSubject The <code>Subject</code> containing the454* delegation principals or <code>null</code> if the authentication455* principal is used instead.456*457* @return A set containing the ObjectNames for the MBeans458* selected. If no MBean satisfies the query, an empty list is459* returned.460*461* @throws SecurityException if the client, or the delegated Subject462* if any, does not have permission to perform this operation.463* @throws IOException if a general communication exception occurred.464*/465public Set<ObjectName>466queryNames(ObjectName name,467MarshalledObject query,468Subject delegationSubject)469throws IOException;470471/**472* Handles the method473* {@link javax.management.MBeanServerConnection#isRegistered(ObjectName)}.474*475* @param name The object name of the MBean to be checked.476* @param delegationSubject The <code>Subject</code> containing the477* delegation principals or <code>null</code> if the authentication478* principal is used instead.479*480* @return True if the MBean is already registered in the MBean481* server, false otherwise.482*483* @throws RuntimeOperationsException Wraps a484* <code>java.lang.IllegalArgumentException</code>: The object485* name in parameter is null.486* @throws SecurityException if the client, or the delegated Subject487* if any, does not have permission to perform this operation.488* @throws IOException if a general communication exception occurred.489*/490public boolean isRegistered(ObjectName name, Subject delegationSubject)491throws IOException;492493/**494* Handles the method495* {@link javax.management.MBeanServerConnection#getMBeanCount()}.496*497* @param delegationSubject The <code>Subject</code> containing the498* delegation principals or <code>null</code> if the authentication499* principal is used instead.500*501* @return the number of MBeans registered.502*503* @throws SecurityException if the client, or the delegated Subject504* if any, does not have permission to perform this operation.505* @throws IOException if a general communication exception occurred.506*/507public Integer getMBeanCount(Subject delegationSubject)508throws IOException;509510/**511* Handles the method {@link512* javax.management.MBeanServerConnection#getAttribute(ObjectName,513* String)}.514*515* @param name The object name of the MBean from which the516* attribute is to be retrieved.517* @param attribute A String specifying the name of the attribute518* to be retrieved.519* @param delegationSubject The <code>Subject</code> containing the520* delegation principals or <code>null</code> if the authentication521* principal is used instead.522*523* @return The value of the retrieved attribute.524*525* @throws AttributeNotFoundException The attribute specified526* is not accessible in the MBean.527* @throws MBeanException Wraps an exception thrown by the528* MBean's getter.529* @throws InstanceNotFoundException The MBean specified is not530* registered in the MBean server.531* @throws ReflectionException Wraps a532* <code>java.lang.Exception</code> thrown when trying to invoke533* the getter.534* @throws RuntimeOperationsException Wraps a535* <code>java.lang.IllegalArgumentException</code>: The object536* name in parameter is null or the attribute in parameter is537* null.538* @throws RuntimeMBeanException Wraps a runtime exception thrown539* by the MBean's getter.540* @throws SecurityException if the client, or the delegated Subject541* if any, does not have permission to perform this operation.542* @throws IOException if a general communication exception occurred.543*544* @see #setAttribute545*/546public Object getAttribute(ObjectName name,547String attribute,548Subject delegationSubject)549throws550MBeanException,551AttributeNotFoundException,552InstanceNotFoundException,553ReflectionException,554IOException;555556/**557* Handles the method {@link558* javax.management.MBeanServerConnection#getAttributes(ObjectName,559* String[])}.560*561* @param name The object name of the MBean from which the562* attributes are retrieved.563* @param attributes A list of the attributes to be retrieved.564* @param delegationSubject The <code>Subject</code> containing the565* delegation principals or <code>null</code> if the authentication566* principal is used instead.567*568* @return The list of the retrieved attributes.569*570* @throws InstanceNotFoundException The MBean specified is not571* registered in the MBean server.572* @throws ReflectionException An exception occurred when573* trying to invoke the getAttributes method of a Dynamic MBean.574* @throws RuntimeOperationsException Wrap a575* <code>java.lang.IllegalArgumentException</code>: The object576* name in parameter is null or attributes in parameter is null.577* @throws SecurityException if the client, or the delegated Subject578* if any, does not have permission to perform this operation.579* @throws IOException if a general communication exception occurred.580*581* @see #setAttributes582*/583public AttributeList getAttributes(ObjectName name,584String[] attributes,585Subject delegationSubject)586throws587InstanceNotFoundException,588ReflectionException,589IOException;590591/**592* Handles the method {@link593* javax.management.MBeanServerConnection#setAttribute(ObjectName,594* Attribute)}. The <code>Attribute</code> parameter is wrapped595* in a <code>MarshalledObject</code>.596*597* @param name The name of the MBean within which the attribute is598* to be set.599* @param attribute The identification of the attribute to be set600* and the value it is to be set to, encapsulated into a601* <code>MarshalledObject</code>.602* @param delegationSubject The <code>Subject</code> containing the603* delegation principals or <code>null</code> if the authentication604* principal is used instead.605*606* @throws InstanceNotFoundException The MBean specified is not607* registered in the MBean server.608* @throws AttributeNotFoundException The attribute specified609* is not accessible in the MBean.610* @throws InvalidAttributeValueException The value specified611* for the attribute is not valid.612* @throws MBeanException Wraps an exception thrown by the613* MBean's setter.614* @throws ReflectionException Wraps a615* <code>java.lang.Exception</code> thrown when trying to invoke616* the setter.617* @throws RuntimeOperationsException Wraps a618* <code>java.lang.IllegalArgumentException</code>: The object619* name in parameter is null or the attribute in parameter is620* null.621* @throws SecurityException if the client, or the delegated Subject622* if any, does not have permission to perform this operation.623* @throws IOException if a general communication exception occurred.624*625* @see #getAttribute626*/627public void setAttribute(ObjectName name,628MarshalledObject attribute,629Subject delegationSubject)630throws631InstanceNotFoundException,632AttributeNotFoundException,633InvalidAttributeValueException,634MBeanException,635ReflectionException,636IOException;637638/**639* Handles the method {@link640* javax.management.MBeanServerConnection#setAttributes(ObjectName,641* AttributeList)}. The <code>AttributeList</code> parameter is642* wrapped in a <code>MarshalledObject</code>.643*644* @param name The object name of the MBean within which the645* attributes are to be set.646* @param attributes A list of attributes: The identification of647* the attributes to be set and the values they are to be set to,648* encapsulated into a <code>MarshalledObject</code>.649* @param delegationSubject The <code>Subject</code> containing the650* delegation principals or <code>null</code> if the authentication651* principal is used instead.652*653* @return The list of attributes that were set, with their new654* values.655*656* @throws InstanceNotFoundException The MBean specified is not657* registered in the MBean server.658* @throws ReflectionException An exception occurred when659* trying to invoke the getAttributes method of a Dynamic MBean.660* @throws RuntimeOperationsException Wraps a661* <code>java.lang.IllegalArgumentException</code>: The object662* name in parameter is null or attributes in parameter is null.663* @throws SecurityException if the client, or the delegated Subject664* if any, does not have permission to perform this operation.665* @throws IOException if a general communication exception occurred.666*667* @see #getAttributes668*/669public AttributeList setAttributes(ObjectName name,670MarshalledObject attributes,671Subject delegationSubject)672throws673InstanceNotFoundException,674ReflectionException,675IOException;676677/**678* Handles the method {@link679* javax.management.MBeanServerConnection#invoke(ObjectName,680* String, Object[], String[])}. The <code>Object[]</code>681* parameter is wrapped in a <code>MarshalledObject</code>.682*683* @param name The object name of the MBean on which the method is684* to be invoked.685* @param operationName The name of the operation to be invoked.686* @param params An array containing the parameters to be set when687* the operation is invoked, encapsulated into a688* <code>MarshalledObject</code>. The encapsulated array can be689* null, equivalent to an empty array.690* @param signature An array containing the signature of the691* operation. The class objects will be loaded using the same692* class loader as the one used for loading the MBean on which the693* operation was invoked. Can be null, equivalent to an empty694* array.695* @param delegationSubject The <code>Subject</code> containing the696* delegation principals or <code>null</code> if the authentication697* principal is used instead.698*699* @return The object returned by the operation, which represents700* the result of invoking the operation on the MBean specified.701*702* @throws InstanceNotFoundException The MBean specified is not703* registered in the MBean server.704* @throws MBeanException Wraps an exception thrown by the705* MBean's invoked method.706* @throws ReflectionException Wraps a707* <code>java.lang.Exception</code> thrown while trying to invoke708* the method.709* @throws SecurityException if the client, or the delegated Subject710* if any, does not have permission to perform this operation.711* @throws IOException if a general communication exception occurred.712* @throws RuntimeOperationsException Wraps an {@link713* IllegalArgumentException} when <code>name</code> or714* <code>operationName</code> is null.715*/716public Object invoke(ObjectName name,717String operationName,718MarshalledObject params,719String signature[],720Subject delegationSubject)721throws722InstanceNotFoundException,723MBeanException,724ReflectionException,725IOException;726727/**728* Handles the method729* {@link javax.management.MBeanServerConnection#getDefaultDomain()}.730*731* @param delegationSubject The <code>Subject</code> containing the732* delegation principals or <code>null</code> if the authentication733* principal is used instead.734*735* @return the default domain.736*737* @throws SecurityException if the client, or the delegated Subject738* if any, does not have permission to perform this operation.739* @throws IOException if a general communication exception occurred.740*/741public String getDefaultDomain(Subject delegationSubject)742throws IOException;743744/**745* Handles the method746* {@link javax.management.MBeanServerConnection#getDomains()}.747*748* @param delegationSubject The <code>Subject</code> containing the749* delegation principals or <code>null</code> if the authentication750* principal is used instead.751*752* @return the list of domains.753*754* @throws SecurityException if the client, or the delegated Subject755* if any, does not have permission to perform this operation.756* @throws IOException if a general communication exception occurred.757*/758public String[] getDomains(Subject delegationSubject)759throws IOException;760761/**762* Handles the method763* {@link javax.management.MBeanServerConnection#getMBeanInfo(ObjectName)}.764*765* @param name The name of the MBean to analyze766* @param delegationSubject The <code>Subject</code> containing the767* delegation principals or <code>null</code> if the authentication768* principal is used instead.769*770* @return An instance of <code>MBeanInfo</code> allowing the771* retrieval of all attributes and operations of this MBean.772*773* @throws IntrospectionException An exception occurred during774* introspection.775* @throws InstanceNotFoundException The MBean specified was776* not found.777* @throws ReflectionException An exception occurred when778* trying to invoke the getMBeanInfo of a Dynamic MBean.779* @throws SecurityException if the client, or the delegated Subject780* if any, does not have permission to perform this operation.781* @throws IOException if a general communication exception occurred.782* @throws RuntimeOperationsException Wraps a783* <code>java.lang.IllegalArgumentException</code>: The object784* name in parameter is null.785*/786public MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject)787throws788InstanceNotFoundException,789IntrospectionException,790ReflectionException,791IOException;792793/**794* Handles the method {@link795* javax.management.MBeanServerConnection#isInstanceOf(ObjectName,796* String)}.797*798* @param name The <code>ObjectName</code> of the MBean.799* @param className The name of the class.800* @param delegationSubject The <code>Subject</code> containing the801* delegation principals or <code>null</code> if the authentication802* principal is used instead.803*804* @return true if the MBean specified is an instance of the805* specified class according to the rules above, false otherwise.806*807* @throws InstanceNotFoundException The MBean specified is not808* registered in the MBean server.809* @throws SecurityException if the client, or the delegated Subject810* if any, does not have permission to perform this operation.811* @throws IOException if a general communication exception occurred.812* @throws RuntimeOperationsException Wraps a813* <code>java.lang.IllegalArgumentException</code>: The object814* name in parameter is null.815*/816public boolean isInstanceOf(ObjectName name,817String className,818Subject delegationSubject)819throws InstanceNotFoundException, IOException;820821/**822* Handles the method {@link823* javax.management.MBeanServerConnection#addNotificationListener(ObjectName,824* ObjectName, NotificationFilter, Object)}. The825* <code>NotificationFilter</code> parameter is wrapped in a826* <code>MarshalledObject</code>. The <code>Object</code>827* (handback) parameter is also wrapped in a828* <code>MarshalledObject</code>.829*830* @param name The name of the MBean on which the listener should831* be added.832* @param listener The object name of the listener which will833* handle the notifications emitted by the registered MBean.834* @param filter The filter object, encapsulated into a835* <code>MarshalledObject</code>. If filter encapsulated in the836* <code>MarshalledObject</code> has a null value, no filtering837* will be performed before handling notifications.838* @param handback The context to be sent to the listener when a839* notification is emitted, encapsulated into a840* <code>MarshalledObject</code>.841* @param delegationSubject The <code>Subject</code> containing the842* delegation principals or <code>null</code> if the authentication843* principal is used instead.844*845* @throws InstanceNotFoundException The MBean name of the846* notification listener or of the notification broadcaster does847* not match any of the registered MBeans.848* @throws RuntimeOperationsException Wraps an {@link849* IllegalArgumentException}. The MBean named by850* <code>listener</code> exists but does not implement the851* {@link javax.management.NotificationListener} interface,852* or <code>name</code> or <code>listener</code> is null.853* @throws SecurityException if the client, or the delegated Subject854* if any, does not have permission to perform this operation.855* @throws IOException if a general communication exception occurred.856*857* @see #removeNotificationListener(ObjectName, ObjectName, Subject)858* @see #removeNotificationListener(ObjectName, ObjectName,859* MarshalledObject, MarshalledObject, Subject)860*/861public void addNotificationListener(ObjectName name,862ObjectName listener,863MarshalledObject filter,864MarshalledObject handback,865Subject delegationSubject)866throws InstanceNotFoundException, IOException;867868/**869* Handles the method {@link870* javax.management.MBeanServerConnection#removeNotificationListener(ObjectName,871* ObjectName)}.872*873* @param name The name of the MBean on which the listener should874* be removed.875* @param listener The object name of the listener to be removed.876* @param delegationSubject The <code>Subject</code> containing the877* delegation principals or <code>null</code> if the authentication878* principal is used instead.879*880* @throws InstanceNotFoundException The MBean name provided881* does not match any of the registered MBeans.882* @throws ListenerNotFoundException The listener is not883* registered in the MBean.884* @throws SecurityException if the client, or the delegated Subject885* if any, does not have permission to perform this operation.886* @throws IOException if a general communication exception occurred.887* @throws RuntimeOperationsException Wraps an {@link888* IllegalArgumentException} when <code>name</code> or889* <code>listener</code> is null.890*891* @see #addNotificationListener892*/893public void removeNotificationListener(ObjectName name,894ObjectName listener,895Subject delegationSubject)896throws897InstanceNotFoundException,898ListenerNotFoundException,899IOException;900901/**902* Handles the method {@link903* javax.management.MBeanServerConnection#removeNotificationListener(ObjectName,904* ObjectName, NotificationFilter, Object)}. The905* <code>NotificationFilter</code> parameter is wrapped in a906* <code>MarshalledObject</code>. The <code>Object</code>907* parameter is also wrapped in a <code>MarshalledObject</code>.908*909* @param name The name of the MBean on which the listener should910* be removed.911* @param listener A listener that was previously added to this912* MBean.913* @param filter The filter that was specified when the listener914* was added, encapsulated into a <code>MarshalledObject</code>.915* @param handback The handback that was specified when the916* listener was added, encapsulated into a <code>MarshalledObject</code>.917* @param delegationSubject The <code>Subject</code> containing the918* delegation principals or <code>null</code> if the authentication919* principal is used instead.920*921* @throws InstanceNotFoundException The MBean name provided922* does not match any of the registered MBeans.923* @throws ListenerNotFoundException The listener is not924* registered in the MBean, or it is not registered with the given925* filter and handback.926* @throws SecurityException if the client, or the delegated Subject927* if any, does not have permission to perform this operation.928* @throws IOException if a general communication exception occurred.929* @throws RuntimeOperationsException Wraps an {@link930* IllegalArgumentException} when <code>name</code> or931* <code>listener</code> is null.932*933* @see #addNotificationListener934*/935public void removeNotificationListener(ObjectName name,936ObjectName listener,937MarshalledObject filter,938MarshalledObject handback,939Subject delegationSubject)940throws941InstanceNotFoundException,942ListenerNotFoundException,943IOException;944945// Special Handling of Notifications -------------------------------------946947/**948* <p>Handles the method {@link949* javax.management.MBeanServerConnection#addNotificationListener(ObjectName,950* NotificationListener, NotificationFilter, Object)}.</p>951*952* <p>Register for notifications from the given MBeans that match953* the given filters. The remote client can subsequently retrieve954* the notifications using the {@link #fetchNotifications955* fetchNotifications} method.</p>956*957* <p>For each listener, the original958* <code>NotificationListener</code> and <code>handback</code> are959* kept on the client side; in order for the client to be able to960* identify them, the server generates and returns a unique961* <code>listenerID</code>. This <code>listenerID</code> is962* forwarded with the <code>Notifications</code> to the remote963* client.</p>964*965* <p>If any one of the given (name, filter) pairs cannot be966* registered, then the operation fails with an exception, and no967* names or filters are registered.</p>968*969* @param names the <code>ObjectNames</code> identifying the970* MBeans emitting the Notifications.971* @param filters an array of marshalled representations of the972* <code>NotificationFilters</code>. Elements of this array can973* be null.974* @param delegationSubjects the <code>Subjects</code> on behalf975* of which the listeners are being added. Elements of this array976* can be null. Also, the <code>delegationSubjects</code>977* parameter itself can be null, which is equivalent to an array978* of null values with the same size as the <code>names</code> and979* <code>filters</code> arrays.980*981* @return an array of <code>listenerIDs</code> identifying the982* local listeners. This array has the same number of elements as983* the parameters.984*985* @throws IllegalArgumentException if <code>names</code> or986* <code>filters</code> is null, or if <code>names</code> contains987* a null element, or if the three arrays do not all have the same988* size.989* @throws ClassCastException if one of the elements of990* <code>filters</code> unmarshalls as a non-null object that is991* not a <code>NotificationFilter</code>.992* @throws InstanceNotFoundException if one of the993* <code>names</code> does not correspond to any registered MBean.994* @throws SecurityException if, for one of the MBeans, the995* client, or the delegated Subject if any, does not have996* permission to add a listener.997* @throws IOException if a general communication exception occurred.998*/999public Integer[] addNotificationListeners(ObjectName[] names,1000MarshalledObject[] filters,1001Subject[] delegationSubjects)1002throws InstanceNotFoundException, IOException;10031004/**1005* <p>Handles the1006* {@link javax.management.MBeanServerConnection#removeNotificationListener(ObjectName,NotificationListener)1007* removeNotificationListener(ObjectName, NotificationListener)} and1008* {@link javax.management.MBeanServerConnection#removeNotificationListener(ObjectName,NotificationListener,NotificationFilter,Object)1009* removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)} methods.</p>1010*1011* <p>This method removes one or more1012* <code>NotificationListener</code>s from a given MBean in the1013* MBean server.</p>1014*1015* <p>The <code>NotificationListeners</code> are identified by the1016* IDs which were returned by the {@link1017* #addNotificationListeners(ObjectName[], MarshalledObject[],1018* Subject[])} method.</p>1019*1020* @param name the <code>ObjectName</code> identifying the MBean1021* emitting the Notifications.1022* @param listenerIDs the list of the IDs corresponding to the1023* listeners to remove.1024* @param delegationSubject The <code>Subject</code> containing the1025* delegation principals or <code>null</code> if the authentication1026* principal is used instead.1027*1028* @throws InstanceNotFoundException if the given1029* <code>name</code> does not correspond to any registered MBean.1030* @throws ListenerNotFoundException if one of the listeners was1031* not found on the server side. This exception can happen if the1032* MBean discarded a listener for some reason other than a call to1033* <code>MBeanServer.removeNotificationListener</code>.1034* @throws SecurityException if the client, or the delegated Subject1035* if any, does not have permission to remove the listeners.1036* @throws IOException if a general communication exception occurred.1037* @throws IllegalArgumentException if <code>ObjectName</code> or1038* <code>listenerIds</code> is null or if <code>listenerIds</code>1039* contains a null element.1040*/1041public void removeNotificationListeners(ObjectName name,1042Integer[] listenerIDs,1043Subject delegationSubject)1044throws1045InstanceNotFoundException,1046ListenerNotFoundException,1047IOException;10481049/**1050* <p>Retrieves notifications from the connector server. This1051* method can block until there is at least one notification or1052* until the specified timeout is reached. The method can also1053* return at any time with zero notifications.</p>1054*1055* <p>A notification can be included in the result if its sequence1056* number is no less than <code>clientSequenceNumber</code> and1057* this client has registered at least one listener for the MBean1058* generating the notification, with a filter that accepts the1059* notification. Each listener that is interested in the1060* notification is identified by an Integer ID that was returned1061* by {@link #addNotificationListeners(ObjectName[],1062* MarshalledObject[], Subject[])}.</p>1063*1064* @param clientSequenceNumber the first sequence number that the1065* client is interested in. If negative, it is interpreted as1066* meaning the sequence number that the next notification will1067* have.1068*1069* @param maxNotifications the maximum number of different1070* notifications to return. The <code>TargetedNotification</code>1071* array in the returned <code>NotificationResult</code> can have1072* more elements than this if the same notification appears more1073* than once. The behavior is unspecified if this parameter is1074* negative.1075*1076* @param timeout the maximum time in milliseconds to wait for a1077* notification to arrive. This can be 0 to indicate that the1078* method should not wait if there are no notifications, but1079* should return at once. It can be <code>Long.MAX_VALUE</code>1080* to indicate that there is no timeout. The behavior is1081* unspecified if this parameter is negative.1082*1083* @return A <code>NotificationResult</code>.1084*1085* @throws IOException if a general communication exception occurred.1086*/1087public NotificationResult fetchNotifications(long clientSequenceNumber,1088int maxNotifications,1089long timeout)1090throws IOException;1091}109210931094