1. /*
  2. * @(#)MBeanServerConnection.java 1.21 04/02/10
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management;
  8. // java import
  9. import java.io.IOException;
  10. import java.util.Set;
  11. /**
  12. * This interface represents a way to talk to an MBean server, whether
  13. * local or remote. The {@link MBeanServer} interface, representing a
  14. * local MBean server, extends this interface.
  15. *
  16. *
  17. * @since 1.5
  18. * @since.unbundled JMX 1.2
  19. */
  20. public interface MBeanServerConnection {
  21. /**
  22. * <p>Instantiates and registers an MBean in the MBean server. The
  23. * MBean server will use its {@link
  24. * javax.management.loading.ClassLoaderRepository Default Loader
  25. * Repository} to load the class of the MBean. An object name is
  26. * associated to the MBean. If the object name given is null, the
  27. * MBean must provide its own name by implementing the {@link
  28. * javax.management.MBeanRegistration MBeanRegistration} interface
  29. * and returning the name from the {@link
  30. * MBeanRegistration#preRegister preRegister} method.</p>
  31. *
  32. * <p>This method is equivalent to {@link
  33. * #createMBean(String,ObjectName,Object[],String[])
  34. * createMBean(className, name, (Object[]) null, (String[])
  35. * null)}.</p>
  36. *
  37. * @param className The class name of the MBean to be instantiated.
  38. * @param name The object name of the MBean. May be null.
  39. *
  40. * @return An <CODE>ObjectInstance</CODE>, containing the
  41. * <CODE>ObjectName</CODE> and the Java class name of the newly
  42. * instantiated MBean. If the contained <code>ObjectName</code>
  43. * is <code>n</code>, the contained Java class name is
  44. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  45. *
  46. * @exception ReflectionException Wraps a
  47. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  48. * <CODE><CODE>java.lang.Exception</CODE></CODE> that occurred
  49. * when trying to invoke the MBean's constructor.
  50. * @exception InstanceAlreadyExistsException The MBean is already
  51. * under the control of the MBean server.
  52. * @exception MBeanRegistrationException The
  53. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  54. * interface) method of the MBean has thrown an exception. The
  55. * MBean will not be registered.
  56. * @exception MBeanException The constructor of the MBean has
  57. * thrown an exception
  58. * @exception NotCompliantMBeanException This class is not a JMX
  59. * compliant MBean
  60. * @exception RuntimeOperationsException Wraps a
  61. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  62. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  63. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  64. * is specified for the MBean.
  65. * @exception IOException A communication problem occurred when
  66. * talking to the MBean server.
  67. *
  68. */
  69. public ObjectInstance createMBean(String className, ObjectName name)
  70. throws ReflectionException, InstanceAlreadyExistsException,
  71. MBeanRegistrationException, MBeanException,
  72. NotCompliantMBeanException, IOException;
  73. /**
  74. * <p>Instantiates and registers an MBean in the MBean server. The
  75. * class loader to be used is identified by its object name. An
  76. * object name is associated to the MBean. If the object name of
  77. * the loader is null, the ClassLoader that loaded the MBean
  78. * server will be used. If the MBean's object name given is null,
  79. * the MBean must provide its own name by implementing the {@link
  80. * javax.management.MBeanRegistration MBeanRegistration} interface
  81. * and returning the name from the {@link
  82. * MBeanRegistration#preRegister preRegister} method.</p>
  83. *
  84. * <p>This method is equivalent to {@link
  85. * #createMBean(String,ObjectName,ObjectName,Object[],String[])
  86. * createMBean(className, name, loaderName, (Object[]) null,
  87. * (String[]) null)}.</p>
  88. *
  89. * @param className The class name of the MBean to be instantiated.
  90. * @param name The object name of the MBean. May be null.
  91. * @param loaderName The object name of the class loader to be used.
  92. *
  93. * @return An <CODE>ObjectInstance</CODE>, containing the
  94. * <CODE>ObjectName</CODE> and the Java class name of the newly
  95. * instantiated MBean. If the contained <code>ObjectName</code>
  96. * is <code>n</code>, the contained Java class name is
  97. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  98. *
  99. * @exception ReflectionException Wraps a
  100. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  101. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  102. * invoke the MBean's constructor.
  103. * @exception InstanceAlreadyExistsException The MBean is already
  104. * under the control of the MBean server.
  105. * @exception MBeanRegistrationException The
  106. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  107. * interface) method of the MBean has thrown an exception. The
  108. * MBean will not be registered.
  109. * @exception MBeanException The constructor of the MBean has
  110. * thrown an exception
  111. * @exception NotCompliantMBeanException This class is not a JMX
  112. * compliant MBean
  113. * @exception InstanceNotFoundException The specified class loader
  114. * is not registered in the MBean server.
  115. * @exception RuntimeOperationsException Wraps a
  116. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  117. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  118. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  119. * is specified for the MBean.
  120. * @exception IOException A communication problem occurred when
  121. * talking to the MBean server.
  122. */
  123. public ObjectInstance createMBean(String className, ObjectName name,
  124. ObjectName loaderName)
  125. throws ReflectionException, InstanceAlreadyExistsException,
  126. MBeanRegistrationException, MBeanException,
  127. NotCompliantMBeanException, InstanceNotFoundException,
  128. IOException;
  129. /**
  130. * Instantiates and registers an MBean in the MBean server. The
  131. * MBean server will use its {@link
  132. * javax.management.loading.ClassLoaderRepository Default Loader
  133. * Repository} to load the class of the MBean. An object name is
  134. * associated to the MBean. If the object name given is null, the
  135. * MBean must provide its own name by implementing the {@link
  136. * javax.management.MBeanRegistration MBeanRegistration} interface
  137. * and returning the name from the {@link
  138. * MBeanRegistration#preRegister preRegister} method.
  139. *
  140. * @param className The class name of the MBean to be instantiated.
  141. * @param name The object name of the MBean. May be null.
  142. * @param params An array containing the parameters of the
  143. * constructor to be invoked.
  144. * @param signature An array containing the signature of the
  145. * constructor to be invoked.
  146. *
  147. * @return An <CODE>ObjectInstance</CODE>, containing the
  148. * <CODE>ObjectName</CODE> and the Java class name of the newly
  149. * instantiated MBean. If the contained <code>ObjectName</code>
  150. * is <code>n</code>, the contained Java class name is
  151. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  152. *
  153. * @exception ReflectionException Wraps a
  154. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  155. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  156. * invoke the MBean's constructor.
  157. * @exception InstanceAlreadyExistsException The MBean is already
  158. * under the control of the MBean server.
  159. * @exception MBeanRegistrationException The
  160. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  161. * interface) method of the MBean has thrown an exception. The
  162. * MBean will not be registered.
  163. * @exception MBeanException The constructor of the MBean has
  164. * thrown an exception
  165. * @exception NotCompliantMBeanException This class is not a JMX
  166. * compliant MBean
  167. * @exception RuntimeOperationsException Wraps a
  168. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  169. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  170. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  171. * is specified for the MBean.
  172. * @exception IOException A communication problem occurred when
  173. * talking to the MBean server.
  174. *
  175. */
  176. public ObjectInstance createMBean(String className, ObjectName name,
  177. Object params[], String signature[])
  178. throws ReflectionException, InstanceAlreadyExistsException,
  179. MBeanRegistrationException, MBeanException,
  180. NotCompliantMBeanException, IOException;
  181. /**
  182. * Instantiates and registers an MBean in the MBean server. The
  183. * class loader to be used is identified by its object name. An
  184. * object name is associated to the MBean. If the object name of
  185. * the loader is not specified, the ClassLoader that loaded the
  186. * MBean server will be used. If the MBean object name given is
  187. * null, the MBean must provide its own name by implementing the
  188. * {@link javax.management.MBeanRegistration MBeanRegistration}
  189. * interface and returning the name from the {@link
  190. * MBeanRegistration#preRegister preRegister} method.
  191. *
  192. * @param className The class name of the MBean to be instantiated.
  193. * @param name The object name of the MBean. May be null.
  194. * @param params An array containing the parameters of the
  195. * constructor to be invoked.
  196. * @param signature An array containing the signature of the
  197. * constructor to be invoked.
  198. * @param loaderName The object name of the class loader to be used.
  199. *
  200. * @return An <CODE>ObjectInstance</CODE>, containing the
  201. * <CODE>ObjectName</CODE> and the Java class name of the newly
  202. * instantiated MBean. If the contained <code>ObjectName</code>
  203. * is <code>n</code>, the contained Java class name is
  204. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  205. *
  206. * @exception ReflectionException Wraps a
  207. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  208. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  209. * invoke the MBean's constructor.
  210. * @exception InstanceAlreadyExistsException The MBean is already
  211. * under the control of the MBean server.
  212. * @exception MBeanRegistrationException The
  213. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  214. * interface) method of the MBean has thrown an exception. The
  215. * MBean will not be registered.
  216. * @exception MBeanException The constructor of the MBean has
  217. * thrown an exception
  218. * @exception NotCompliantMBeanException This class is not a JMX
  219. * compliant MBean
  220. * @exception InstanceNotFoundException The specified class loader
  221. * is not registered in the MBean server.
  222. * @exception RuntimeOperationsException Wraps a
  223. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  224. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  225. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  226. * is specified for the MBean.
  227. * @exception IOException A communication problem occurred when
  228. * talking to the MBean server.
  229. *
  230. */
  231. public ObjectInstance createMBean(String className, ObjectName name,
  232. ObjectName loaderName, Object params[],
  233. String signature[])
  234. throws ReflectionException, InstanceAlreadyExistsException,
  235. MBeanRegistrationException, MBeanException,
  236. NotCompliantMBeanException, InstanceNotFoundException,
  237. IOException;
  238. /**
  239. * Unregisters an MBean from the MBean server. The MBean is
  240. * identified by its object name. Once the method has been
  241. * invoked, the MBean may no longer be accessed by its object
  242. * name.
  243. *
  244. * @param name The object name of the MBean to be unregistered.
  245. *
  246. * @exception InstanceNotFoundException The MBean specified is not
  247. * registered in the MBean server.
  248. * @exception MBeanRegistrationException The preDeregister
  249. * ((<CODE>MBeanRegistration</CODE> interface) method of the MBean
  250. * has thrown an exception.
  251. * @exception RuntimeOperationsException Wraps a
  252. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  253. * name in parameter is null or the MBean you are when trying to
  254. * unregister is the {@link javax.management.MBeanServerDelegate
  255. * MBeanServerDelegate} MBean.
  256. * @exception IOException A communication problem occurred when
  257. * talking to the MBean server.
  258. *
  259. */
  260. public void unregisterMBean(ObjectName name)
  261. throws InstanceNotFoundException, MBeanRegistrationException,
  262. IOException;
  263. /**
  264. * Gets the <CODE>ObjectInstance</CODE> for a given MBean
  265. * registered with the MBean server.
  266. *
  267. * @param name The object name of the MBean.
  268. *
  269. * @return The <CODE>ObjectInstance</CODE> associated with the MBean
  270. * specified by <VAR>name</VAR>. The contained <code>ObjectName</code>
  271. * is <code>name</code> and the contained class name is
  272. * <code>{@link #getMBeanInfo getMBeanInfo(name)}.getClassName()</code>.
  273. *
  274. * @exception InstanceNotFoundException The MBean specified is not
  275. * registered in the MBean server.
  276. * @exception IOException A communication problem occurred when
  277. * talking to the MBean server.
  278. */
  279. public ObjectInstance getObjectInstance(ObjectName name)
  280. throws InstanceNotFoundException, IOException;
  281. /**
  282. * Gets MBeans controlled by the MBean server. This method allows
  283. * any of the following to be obtained: All MBeans, a set of
  284. * MBeans specified by pattern matching on the
  285. * <CODE>ObjectName</CODE> and/or a Query expression, a specific
  286. * MBean. When the object name is null or no domain and key
  287. * properties are specified, all objects are to be selected (and
  288. * filtered if a query is specified). It returns the set of
  289. * <CODE>ObjectInstance</CODE> objects (containing the
  290. * <CODE>ObjectName</CODE> and the Java Class name) for the
  291. * selected MBeans.
  292. *
  293. * @param name The object name pattern identifying the MBeans to
  294. * be retrieved. If null or no domain and key properties are
  295. * specified, all the MBeans registered will be retrieved.
  296. * @param query The query expression to be applied for selecting
  297. * MBeans. If null no query expression will be applied for
  298. * selecting MBeans.
  299. *
  300. * @return A set containing the <CODE>ObjectInstance</CODE>
  301. * objects for the selected MBeans. If no MBean satisfies the
  302. * query an empty list is returned.
  303. *
  304. * @exception IOException A communication problem occurred when
  305. * talking to the MBean server.
  306. */
  307. public Set queryMBeans(ObjectName name, QueryExp query)
  308. throws IOException;
  309. /**
  310. * Gets the names of MBeans controlled by the MBean server. This
  311. * method enables any of the following to be obtained: The names
  312. * of all MBeans, the names of a set of MBeans specified by
  313. * pattern matching on the <CODE>ObjectName</CODE> and/or a Query
  314. * expression, a specific MBean name (equivalent to testing
  315. * whether an MBean is registered). When the object name is null
  316. * or no domain and key properties are specified, all objects are
  317. * selected (and filtered if a query is specified). It returns the
  318. * set of ObjectNames for the MBeans selected.
  319. *
  320. * @param name The object name pattern identifying the MBean names
  321. * to be retrieved. If null or no domain and key properties are
  322. * specified, the name of all registered MBeans will be retrieved.
  323. * @param query The query expression to be applied for selecting
  324. * MBeans. If null no query expression will be applied for
  325. * selecting MBeans.
  326. *
  327. * @return A set containing the ObjectNames for the MBeans
  328. * selected. If no MBean satisfies the query, an empty list is
  329. * returned.
  330. *
  331. * @exception IOException A communication problem occurred when
  332. * talking to the MBean server.
  333. */
  334. public Set queryNames(ObjectName name, QueryExp query)
  335. throws IOException;
  336. /**
  337. * Checks whether an MBean, identified by its object name, is
  338. * already registered with the MBean server.
  339. *
  340. * @param name The object name of the MBean to be checked.
  341. *
  342. * @return True if the MBean is already registered in the MBean
  343. * server, false otherwise.
  344. *
  345. * @exception RuntimeOperationsException Wraps a
  346. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  347. * name in parameter is null.
  348. * @exception IOException A communication problem occurred when
  349. * talking to the MBean server.
  350. */
  351. public boolean isRegistered(ObjectName name)
  352. throws IOException;
  353. /**
  354. * Returns the number of MBeans registered in the MBean server.
  355. *
  356. * @return the number of MBeans registered.
  357. *
  358. * @exception IOException A communication problem occurred when
  359. * talking to the MBean server.
  360. */
  361. public Integer getMBeanCount()
  362. throws IOException;
  363. /**
  364. * Gets the value of a specific attribute of a named MBean. The MBean
  365. * is identified by its object name.
  366. *
  367. * @param name The object name of the MBean from which the
  368. * attribute is to be retrieved.
  369. * @param attribute A String specifying the name of the attribute
  370. * to be retrieved.
  371. *
  372. * @return The value of the retrieved attribute.
  373. *
  374. * @exception AttributeNotFoundException The attribute specified
  375. * is not accessible in the MBean.
  376. * @exception MBeanException Wraps an exception thrown by the
  377. * MBean's getter.
  378. * @exception InstanceNotFoundException The MBean specified is not
  379. * registered in the MBean server.
  380. * @exception ReflectionException Wraps a
  381. * <CODE>java.lang.Exception</CODE> thrown when trying to invoke
  382. * the setter.
  383. * @exception RuntimeOperationsException Wraps a
  384. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  385. * name in parameter is null or the attribute in parameter is
  386. * null.
  387. * @exception IOException A communication problem occurred when
  388. * talking to the MBean server.
  389. *
  390. * @see #setAttribute
  391. */
  392. public Object getAttribute(ObjectName name, String attribute)
  393. throws MBeanException, AttributeNotFoundException,
  394. InstanceNotFoundException, ReflectionException,
  395. IOException;
  396. /**
  397. * Enables the values of several attributes of a named MBean. The MBean
  398. * is identified by its object name.
  399. *
  400. * @param name The object name of the MBean from which the
  401. * attributes are retrieved.
  402. * @param attributes A list of the attributes to be retrieved.
  403. *
  404. * @return The list of the retrieved attributes.
  405. *
  406. * @exception InstanceNotFoundException The MBean specified is not
  407. * registered in the MBean server.
  408. * @exception ReflectionException An exception occurred when
  409. * trying to invoke the getAttributes method of a Dynamic MBean.
  410. * @exception RuntimeOperationsException Wrap a
  411. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  412. * name in parameter is null or attributes in parameter is null.
  413. * @exception IOException A communication problem occurred when
  414. * talking to the MBean server.
  415. *
  416. * @see #setAttributes
  417. */
  418. public AttributeList getAttributes(ObjectName name, String[] attributes)
  419. throws InstanceNotFoundException, ReflectionException,
  420. IOException;
  421. /**
  422. * Sets the value of a specific attribute of a named MBean. The MBean
  423. * is identified by its object name.
  424. *
  425. * @param name The name of the MBean within which the attribute is
  426. * to be set.
  427. * @param attribute The identification of the attribute to be set
  428. * and the value it is to be set to.
  429. *
  430. * @exception InstanceNotFoundException The MBean specified is not
  431. * registered in the MBean server.
  432. * @exception AttributeNotFoundException The attribute specified
  433. * is not accessible in the MBean.
  434. * @exception InvalidAttributeValueException The value specified
  435. * for the attribute is not valid.
  436. * @exception MBeanException Wraps an exception thrown by the
  437. * MBean's setter.
  438. * @exception ReflectionException Wraps a
  439. * <CODE>java.lang.Exception</CODE> thrown when trying to invoke
  440. * the setter.
  441. * @exception RuntimeOperationsException Wraps a
  442. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  443. * name in parameter is null or the attribute in parameter is
  444. * null.
  445. * @exception IOException A communication problem occurred when
  446. * talking to the MBean server.
  447. *
  448. * @see #getAttribute
  449. */
  450. public void setAttribute(ObjectName name, Attribute attribute)
  451. throws InstanceNotFoundException, AttributeNotFoundException,
  452. InvalidAttributeValueException, MBeanException,
  453. ReflectionException, IOException;
  454. /**
  455. * Sets the values of several attributes of a named MBean. The MBean is
  456. * identified by its object name.
  457. *
  458. * @param name The object name of the MBean within which the
  459. * attributes are to be set.
  460. * @param attributes A list of attributes: The identification of
  461. * the attributes to be set and the values they are to be set to.
  462. *
  463. * @return The list of attributes that were set, with their new
  464. * values.
  465. *
  466. * @exception InstanceNotFoundException The MBean specified is not
  467. * registered in the MBean server.
  468. * @exception ReflectionException An exception occurred when
  469. * trying to invoke the getAttributes method of a Dynamic MBean.
  470. * @exception RuntimeOperationsException Wraps a
  471. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  472. * name in parameter is null or attributes in parameter is null.
  473. * @exception IOException A communication problem occurred when
  474. * talking to the MBean server.
  475. *
  476. * @see #getAttributes
  477. */
  478. public AttributeList setAttributes(ObjectName name,
  479. AttributeList attributes)
  480. throws InstanceNotFoundException, ReflectionException, IOException;
  481. /**
  482. * Invokes an operation on an MBean.
  483. *
  484. * @param name The object name of the MBean on which the method is
  485. * to be invoked.
  486. * @param operationName The name of the operation to be invoked.
  487. * @param params An array containing the parameters to be set when
  488. * the operation is invoked
  489. * @param signature An array containing the signature of the
  490. * operation. The class objects will be loaded using the same
  491. * class loader as the one used for loading the MBean on which the
  492. * operation was invoked.
  493. *
  494. * @return The object returned by the operation, which represents
  495. * the result of invoking the operation on the MBean specified.
  496. *
  497. * @exception InstanceNotFoundException The MBean specified is not
  498. * registered in the MBean server.
  499. * @exception MBeanException Wraps an exception thrown by the
  500. * MBean's invoked method.
  501. * @exception ReflectionException Wraps a
  502. * <CODE>java.lang.Exception</CODE> thrown while trying to invoke
  503. * the method.
  504. * @exception IOException A communication problem occurred when
  505. * talking to the MBean server.
  506. *
  507. */
  508. public Object invoke(ObjectName name, String operationName,
  509. Object params[], String signature[])
  510. throws InstanceNotFoundException, MBeanException,
  511. ReflectionException, IOException;
  512. /**
  513. * Returns the default domain used for naming the MBean.
  514. * The default domain name is used as the domain part in the ObjectName
  515. * of MBeans if no domain is specified by the user.
  516. *
  517. * @return the default domain.
  518. *
  519. * @exception IOException A communication problem occurred when
  520. * talking to the MBean server.
  521. */
  522. public String getDefaultDomain()
  523. throws IOException;
  524. /**
  525. * <p>Returns the list of domains in which any MBean is currently
  526. * registered. A string is in the returned array if and only if
  527. * there is at least one MBean registered with an ObjectName whose
  528. * {@link ObjectName#getDomain() getDomain()} is equal to that
  529. * string. The order of strings within the returned array is
  530. * not defined.</p>
  531. *
  532. * @return the list of domains.
  533. *
  534. * @exception IOException A communication problem occurred when
  535. * talking to the MBean server.
  536. *
  537. * @since.unbundled JMX 1.2
  538. */
  539. public String[] getDomains()
  540. throws IOException;
  541. /**
  542. * <p>Adds a listener to a registered MBean.</p>
  543. *
  544. * <P> A notification emitted by an MBean will be forwarded by the
  545. * MBeanServer to the listener. If the source of the notification
  546. * is a reference to an MBean object, the MBean server will replace it
  547. * by that MBean's ObjectName. Otherwise the source is unchanged.
  548. *
  549. * @param name The name of the MBean on which the listener should
  550. * be added.
  551. * @param listener The listener object which will handle the
  552. * notifications emitted by the registered MBean.
  553. * @param filter The filter object. If filter is null, no
  554. * filtering will be performed before handling notifications.
  555. * @param handback The context to be sent to the listener when a
  556. * notification is emitted.
  557. *
  558. * @exception InstanceNotFoundException The MBean name provided
  559. * does not match any of the registered MBeans.
  560. * @exception IOException A communication problem occurred when
  561. * talking to the MBean server.
  562. *
  563. * @see #removeNotificationListener(ObjectName, NotificationListener)
  564. * @see #removeNotificationListener(ObjectName, NotificationListener,
  565. * NotificationFilter, Object)
  566. */
  567. public void addNotificationListener(ObjectName name,
  568. NotificationListener listener,
  569. NotificationFilter filter,
  570. Object handback)
  571. throws InstanceNotFoundException, IOException;
  572. /**
  573. * <p>Adds a listener to a registered MBean.</p>
  574. *
  575. * <p>A notification emitted by an MBean will be forwarded by the
  576. * MBeanServer to the listener. If the source of the notification
  577. * is a reference to an MBean object, the MBean server will
  578. * replace it by that MBean's ObjectName. Otherwise the source is
  579. * unchanged.</p>
  580. *
  581. * <p>The listener object that receives notifications is the one
  582. * that is registered with the given name at the time this method
  583. * is called. Even if it is subsequently unregistered, it will
  584. * continue to receive notifications.</p>
  585. *
  586. * @param name The name of the MBean on which the listener should
  587. * be added.
  588. * @param listener The object name of the listener which will
  589. * handle the notifications emitted by the registered MBean.
  590. * @param filter The filter object. If filter is null, no
  591. * filtering will be performed before handling notifications.
  592. * @param handback The context to be sent to the listener when a
  593. * notification is emitted.
  594. *
  595. * @exception InstanceNotFoundException The MBean name of the
  596. * notification listener or of the notification broadcaster does
  597. * not match any of the registered MBeans.
  598. * @exception RuntimeOperationsException Wraps an {@link
  599. * IllegalArgumentException}. The MBean named by
  600. * <code>listener</code> exists but does not implement the {@link
  601. * NotificationListener} interface.
  602. * @exception IOException A communication problem occurred when
  603. * talking to the MBean server.
  604. *
  605. * @see #removeNotificationListener(ObjectName, ObjectName)
  606. * @see #removeNotificationListener(ObjectName, ObjectName,
  607. * NotificationFilter, Object)
  608. */
  609. public void addNotificationListener(ObjectName name,
  610. ObjectName listener,
  611. NotificationFilter filter,
  612. Object handback)
  613. throws InstanceNotFoundException, IOException;
  614. /**
  615. * Removes a listener from a registered MBean.
  616. *
  617. * <P> If the listener is registered more than once, perhaps with
  618. * different filters or callbacks, this method will remove all
  619. * those registrations.
  620. *
  621. * @param name The name of the MBean on which the listener should
  622. * be removed.
  623. * @param listener The object name of the listener to be removed.
  624. *
  625. * @exception InstanceNotFoundException The MBean name provided
  626. * does not match any of the registered MBeans.
  627. * @exception ListenerNotFoundException The listener is not
  628. * registered in the MBean.
  629. * @exception IOException A communication problem occurred when
  630. * talking to the MBean server.
  631. *
  632. * @see #addNotificationListener(ObjectName, ObjectName,
  633. * NotificationFilter, Object)
  634. */
  635. public void removeNotificationListener(ObjectName name,
  636. ObjectName listener)
  637. throws InstanceNotFoundException, ListenerNotFoundException,
  638. IOException;
  639. /**
  640. * <p>Removes a listener from a registered MBean.</p>
  641. *
  642. * <p>The MBean must have a listener that exactly matches the
  643. * given <code>listener</code>, <code>filter</code>, and
  644. * <code>handback</code> parameters. If there is more than one
  645. * such listener, only one is removed.</p>
  646. *
  647. * <p>The <code>filter</code> and <code>handback</code> parameters
  648. * may be null if and only if they are null in a listener to be
  649. * removed.</p>
  650. *
  651. * @param name The name of the MBean on which the listener should
  652. * be removed.
  653. * @param listener A listener that was previously added to this
  654. * MBean.
  655. * @param filter The filter that was specified when the listener
  656. * was added.
  657. * @param handback The handback that was specified when the
  658. * listener was added.
  659. *
  660. * @exception InstanceNotFoundException The MBean name provided
  661. * does not match any of the registered MBeans.
  662. * @exception ListenerNotFoundException The listener is not
  663. * registered in the MBean, or it is not registered with the given
  664. * filter and handback.
  665. * @exception IOException A communication problem occurred when
  666. * talking to the MBean server.
  667. *
  668. * @see #addNotificationListener(ObjectName, ObjectName,
  669. * NotificationFilter, Object)
  670. *
  671. * @since.unbundled JMX 1.2
  672. */
  673. public void removeNotificationListener(ObjectName name,
  674. ObjectName listener,
  675. NotificationFilter filter,
  676. Object handback)
  677. throws InstanceNotFoundException, ListenerNotFoundException,
  678. IOException;
  679. /**
  680. * <p>Removes a listener from a registered MBean.</p>
  681. *
  682. * <P> If the listener is registered more than once, perhaps with
  683. * different filters or callbacks, this method will remove all
  684. * those registrations.
  685. *
  686. * @param name The name of the MBean on which the listener should
  687. * be removed.
  688. * @param listener The object name of the listener to be removed.
  689. *
  690. * @exception InstanceNotFoundException The MBean name provided
  691. * does not match any of the registered MBeans.
  692. * @exception ListenerNotFoundException The listener is not
  693. * registered in the MBean.
  694. * @exception IOException A communication problem occurred when
  695. * talking to the MBean server.
  696. *
  697. * @see #addNotificationListener(ObjectName, NotificationListener,
  698. * NotificationFilter, Object)
  699. */
  700. public void removeNotificationListener(ObjectName name,
  701. NotificationListener listener)
  702. throws InstanceNotFoundException, ListenerNotFoundException,
  703. IOException;
  704. /**
  705. * <p>Removes a listener from a registered MBean.</p>
  706. *
  707. * <p>The MBean must have a listener that exactly matches the
  708. * given <code>listener</code>, <code>filter</code>, and
  709. * <code>handback</code> parameters. If there is more than one
  710. * such listener, only one is removed.</p>
  711. *
  712. * <p>The <code>filter</code> and <code>handback</code> parameters
  713. * may be null if and only if they are null in a listener to be
  714. * removed.</p>
  715. *
  716. * @param name The name of the MBean on which the listener should
  717. * be removed.
  718. * @param listener A listener that was previously added to this
  719. * MBean.
  720. * @param filter The filter that was specified when the listener
  721. * was added.
  722. * @param handback The handback that was specified when the
  723. * listener was added.
  724. *
  725. * @exception InstanceNotFoundException The MBean name provided
  726. * does not match any of the registered MBeans.
  727. * @exception ListenerNotFoundException The listener is not
  728. * registered in the MBean, or it is not registered with the given
  729. * filter and handback.
  730. * @exception IOException A communication problem occurred when
  731. * talking to the MBean server.
  732. *
  733. * @see #addNotificationListener(ObjectName, NotificationListener,
  734. * NotificationFilter, Object)
  735. *
  736. * @since.unbundled JMX 1.2
  737. */
  738. public void removeNotificationListener(ObjectName name,
  739. NotificationListener listener,
  740. NotificationFilter filter,
  741. Object handback)
  742. throws InstanceNotFoundException, ListenerNotFoundException,
  743. IOException;
  744. /**
  745. * This method discovers the attributes and operations that an
  746. * MBean exposes for management.
  747. *
  748. * @param name The name of the MBean to analyze
  749. *
  750. * @return An instance of <CODE>MBeanInfo</CODE> allowing the
  751. * retrieval of all attributes and operations of this MBean.
  752. *
  753. * @exception IntrospectionException An exception occurred during
  754. * introspection.
  755. * @exception InstanceNotFoundException The MBean specified was
  756. * not found.
  757. * @exception ReflectionException An exception occurred when
  758. * trying to invoke the getMBeanInfo of a Dynamic MBean.
  759. * @exception IOException A communication problem occurred when
  760. * talking to the MBean server.
  761. */
  762. public MBeanInfo getMBeanInfo(ObjectName name)
  763. throws InstanceNotFoundException, IntrospectionException,
  764. ReflectionException, IOException;
  765. /**
  766. * <p>Returns true if the MBean specified is an instance of the
  767. * specified class, false otherwise.</p>
  768. *
  769. * <p>If <code>name</code> does not name an MBean, this method
  770. * throws {@link InstanceNotFoundException}.</p>
  771. *
  772. * <p>Otherwise, let<br>
  773. * X be the MBean named by <code>name</code>,<br>
  774. * L be the ClassLoader of X,<br>
  775. * N be the class name in X's {@link MBeanInfo}.</p>
  776. *
  777. * <p>If N equals <code>className</code>, the result is true.</p>
  778. *
  779. * <p>Otherwise, if L successfully loads both N and
  780. * <code>className</code>, and the second class is assignable from
  781. * the first, the result is true.</p>
  782. *
  783. * <p>Otherwise, the result is false.</p>
  784. *
  785. * @param name The <CODE>ObjectName</CODE> of the MBean.
  786. * @param className The name of the class.
  787. *
  788. * @return true if the MBean specified is an instance of the
  789. * specified class according to the rules above, false otherwise.
  790. *
  791. * @exception InstanceNotFoundException The MBean specified is not
  792. * registered in the MBean server.
  793. * @exception IOException A communication problem occurred when
  794. * talking to the MBean server.
  795. */
  796. public boolean isInstanceOf(ObjectName name, String className)
  797. throws InstanceNotFoundException, IOException;
  798. }