1. /*
  2. * @(#)MBeanServer.java 1.140 04/05/18
  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.util.Set;
  10. import java.io.ObjectInputStream;
  11. // RI import
  12. import javax.management.loading.ClassLoaderRepository;
  13. /**
  14. * <p>This is the interface for MBean manipulation on the agent
  15. * side. It contains the methods necessary for the creation,
  16. * registration, and deletion of MBeans as well as the access methods
  17. * for registered MBeans. This is the core component of the JMX
  18. * infrastructure.</p>
  19. *
  20. * <p>User code does not usually implement this interface. Instead,
  21. * an object that implements this interface is obtained with one of
  22. * the methods in the {@link MBeanServerFactory} class.</p>
  23. *
  24. * <p>Every MBean which is added to the MBean server becomes
  25. * manageable: its attributes and operations become remotely
  26. * accessible through the connectors/adaptors connected to that MBean
  27. * server. A Java object cannot be registered in the MBean server
  28. * unless it is a JMX compliant MBean.</p>
  29. *
  30. * <p>When an MBean is registered or unregistered in the MBean server
  31. * a {@link javax.management.MBeanServerNotification
  32. * MBeanServerNotification} Notification is emitted. To register an
  33. * object as listener to MBeanServerNotifications you should call the
  34. * MBean server method {@link #addNotificationListener
  35. * addNotificationListener} with <CODE>ObjectName</CODE> the
  36. * <CODE>ObjectName</CODE> of the {@link
  37. * javax.management.MBeanServerDelegate MBeanServerDelegate}. This
  38. * <CODE>ObjectName</CODE> is: <BR>
  39. * <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.</p>
  40. *
  41. * <p>An object obtained from the {@link
  42. * MBeanServerFactory#createMBeanServer(String) createMBeanServer} or
  43. * {@link MBeanServerFactory#newMBeanServer(String) newMBeanServer}
  44. * methods of the {@link MBeanServerFactory} class applies security
  45. * checks to its methods, as follows.</p>
  46. *
  47. * <p>First, if there is no security manager ({@link
  48. * System#getSecurityManager()} is null), then no checks are made.</p>
  49. *
  50. * <p>Assuming there is a security manager, the checks are made as
  51. * detailed below. In what follows, <code>className</code> is the
  52. * string returned by {@link MBeanInfo#getClassName()} for the target
  53. * MBean.</p>
  54. *
  55. * <p>If a security check fails, the method throws {@link
  56. * SecurityException}.</p>
  57. *
  58. * <p>For methods that can throw {@link InstanceNotFoundException},
  59. * this exception is thrown for a non-existent MBean, regardless of
  60. * permissions. This is because a non-existent MBean has no
  61. * <code>className</code>.</p>
  62. *
  63. * <ul>
  64. *
  65. * <li><p>For the {@link #invoke invoke} method, the caller's
  66. * permissions must imply {@link
  67. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  68. * MBeanPermission(className, operationName, name, "invoke")}.</p>
  69. *
  70. * <li><p>For the {@link #getAttribute getAttribute} method, the
  71. * caller's permissions must imply {@link
  72. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  73. * MBeanPermission(className, attribute, name, "getAttribute")}.</p>
  74. *
  75. * <li><p>For the {@link #getAttributes getAttributes} method, the
  76. * caller's permissions must imply {@link
  77. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  78. * MBeanPermission(className, null, name, "getAttribute")}.
  79. * Additionally, for each attribute <em>a</em> in the {@link
  80. * AttributeList}, if the caller's permissions do not imply {@link
  81. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  82. * MBeanPermission(className, <em>a</em>, name, "getAttribute")}, the
  83. * MBean server will behave as if that attribute had not been in the
  84. * supplied list.</p>
  85. *
  86. * <li><p>For the {@link #setAttribute setAttribute} method, the
  87. * caller's permissions must imply {@link
  88. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  89. * MBeanPermission(className, attrName, name, "setAttribute")}, where
  90. * <code>attrName</code> is {@link Attribute#getName()
  91. * attribute.getName()}.</p>
  92. *
  93. * <li><p>For the {@link #setAttributes setAttributes} method, the
  94. * caller's permissions must imply {@link
  95. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  96. * MBeanPermission(className, null, name, "setAttribute")}.
  97. * Additionally, for each attribute <em>a</em> in the {@link
  98. * AttributeList}, if the caller's permissions do not imply {@link
  99. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  100. * MBeanPermission(className, <em>a</em>, name, "setAttribute")}, the
  101. * MBean server will behave as if that attribute had not been in the
  102. * supplied list.</p>
  103. *
  104. * <li><p>For the <code>addNotificationListener</code> methods,
  105. * the caller's permissions must imply {@link
  106. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  107. * MBeanPermission(className, null, name,
  108. * "addNotificationListener")}.</p>
  109. *
  110. * <li><p>For the <code>removeNotificationListener</code> methods,
  111. * the caller's permissions must imply {@link
  112. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  113. * MBeanPermission(className, null, name,
  114. * "removeNotificationListener")}.</p>
  115. *
  116. * <li><p>For the {@link #getMBeanInfo getMBeanInfo} method, the
  117. * caller's permissions must imply {@link
  118. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  119. * MBeanPermission(className, null, name, "getMBeanInfo")}.</p>
  120. *
  121. * <li><p>For the {@link #getObjectInstance getObjectInstance} method,
  122. * the caller's permissions must imply {@link
  123. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  124. * MBeanPermission(className, null, name, "getObjectInstance")}.</p>
  125. *
  126. * <li><p>For the {@link #isInstanceOf isInstanceOf} method, the
  127. * caller's permissions must imply {@link
  128. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  129. * MBeanPermission(className, null, name, "isInstanceOf")}.</p>
  130. *
  131. * <li><p>For the {@link #queryMBeans queryMBeans} method, the
  132. * caller's permissions must imply {@link
  133. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  134. * MBeanPermission(null, null, name, "queryMBeans")}.
  135. * Additionally, for each MBean that matches <code>name</code>,
  136. * if the caller's permissions do not imply {@link
  137. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  138. * MBeanPermission(className, null, name, "queryMBeans")}, the
  139. * MBean server will behave as if that MBean did not exist.</p>
  140. *
  141. * <p>Certain query elements perform operations on the MBean server.
  142. * If the caller does not have the required permissions for a given
  143. * MBean, that MBean will not be included in the result of the query.
  144. * The standard query elements that are affected are {@link
  145. * Query#attr(String)}, {@link Query#attr(String,String)}, and {@link
  146. * Query#classattr()}.</p>
  147. *
  148. * <li><p>For the {@link #queryNames queryNames} method, the checks
  149. * are the same as for <code>queryMBeans</code> except that
  150. * <code>"queryNames"</code> is used instead of
  151. * <code>"queryMBeans"</code> in the <code>MBeanPermission</code>
  152. * objects. Note that a <code>"queryMBeans"</code> permission implies
  153. * the corresponding <code>"queryNames"</code> permission.</p>
  154. *
  155. * <li><p>For the {@link #getDomains getDomains} method, the caller's
  156. * permissions must imply {@link
  157. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  158. * MBeanPermission(null, null, name, "getDomains")}. Additionally,
  159. * for each domain <var>d</var> in the returned array, if the caller's
  160. * permissions do not imply {@link
  161. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  162. * MBeanPermission(null, null, new ObjectName("<var>d</var>:x=x"),
  163. * "getDomains")}, the domain is eliminated from the array. Here,
  164. * <code>x=x</code> is any <var>key=value</var> pair, needed to
  165. * satisfy ObjectName's constructor but not otherwise relevant.</p>
  166. *
  167. * <li><p>For the {@link #getClassLoader getClassLoader} method, the
  168. * caller's permissions must imply {@link
  169. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  170. * MBeanPermission(className, null, loaderName,
  171. * "getClassLoader")}.</p>
  172. *
  173. * <li><p>For the {@link #getClassLoaderFor getClassLoaderFor} method,
  174. * the caller's permissions must imply {@link
  175. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  176. * MBeanPermission(className, null, mbeanName,
  177. * "getClassLoaderFor")}.</p>
  178. *
  179. * <li><p>For the {@link #getClassLoaderRepository
  180. * getClassLoaderRepository} method, the caller's permissions must
  181. * imply {@link
  182. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  183. * MBeanPermission(null, null, null, "getClassLoaderRepository")}.</p>
  184. *
  185. * <li><p>For the deprecated <code>deserialize</code> methods, the
  186. * required permissions are the same as for the methods that replace
  187. * them.</p>
  188. *
  189. * <li><p>For the <code>instantiate</code> methods, the caller's
  190. * permissions must imply {@link
  191. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  192. * MBeanPermission(className, null, null, "instantiate")}.</p>
  193. *
  194. * <li><p>For the {@link #registerMBean registerMBean} method, the
  195. * caller's permissions must imply {@link
  196. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  197. * MBeanPermission(className, null, name, "registerMBean")}. Here
  198. * <code>className</code> is the string returned by {@link
  199. * MBeanInfo#getClassName()} for an object of this class.
  200. *
  201. * <p>If the <code>MBeanPermission</code> check succeeds, the MBean's
  202. * class is validated by checking that its {@link
  203. * java.security.ProtectionDomain ProtectionDomain} implies {@link
  204. * MBeanTrustPermission#MBeanTrustPermission(String)
  205. * MBeanTrustPermission("register")}.</p>
  206. *
  207. * <p>Finally, if the <code>name</code> argument is null, another
  208. * <code>MBeanPermission</code> check is made using the
  209. * <code>ObjectName</code> returned by {@link
  210. * MBeanRegistration#preRegister MBeanRegistration.preRegister}.</p>
  211. *
  212. * <li><p>For the <code>createMBean</code> methods, the caller's
  213. * permissions must imply the permissions needed by the equivalent
  214. * <code>instantiate</code> followed by
  215. * <code>registerMBean</code>.</p>
  216. *
  217. * <li><p>For the {@link #unregisterMBean unregisterMBean} method,
  218. * the caller's permissions must imply {@link
  219. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  220. * MBeanPermission(className, null, name, "unregisterMBean")}.</p>
  221. *
  222. * </ul>
  223. *
  224. * @since 1.5
  225. */
  226. /* DELETED:
  227. *
  228. * <li><p>For the {@link #isRegistered isRegistered} method, the
  229. * caller's permissions must imply {@link
  230. * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  231. * MBeanPermission(null, null, name, "isRegistered")}.</p>
  232. */
  233. public interface MBeanServer extends MBeanServerConnection {
  234. /**
  235. * <p>Instantiates and registers an MBean in the MBean server. The
  236. * MBean server will use its {@link
  237. * javax.management.loading.ClassLoaderRepository Default Loader
  238. * Repository} to load the class of the MBean. An object name is
  239. * associated to the MBean. If the object name given is null, the
  240. * MBean must provide its own name by implementing the {@link
  241. * javax.management.MBeanRegistration MBeanRegistration} interface
  242. * and returning the name from the {@link
  243. * MBeanRegistration#preRegister preRegister} method.</p>
  244. *
  245. * <p>This method is equivalent to {@link
  246. * #createMBean(String,ObjectName,Object[],String[])
  247. * createMBean(className, name, (Object[]) null, (String[])
  248. * null)}.</p>
  249. *
  250. * @param className The class name of the MBean to be instantiated.
  251. * @param name The object name of the MBean. May be null.
  252. *
  253. * @return An <CODE>ObjectInstance</CODE>, containing the
  254. * <CODE>ObjectName</CODE> and the Java class name of the newly
  255. * instantiated MBean. If the contained <code>ObjectName</code>
  256. * is <code>n</code>, the contained Java class name is
  257. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  258. *
  259. * @exception ReflectionException Wraps a
  260. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  261. * <CODE><CODE>java.lang.Exception</CODE></CODE> that occurred
  262. * when trying to invoke the MBean's constructor.
  263. * @exception InstanceAlreadyExistsException The MBean is already
  264. * under the control of the MBean server.
  265. * @exception MBeanRegistrationException The
  266. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  267. * interface) method of the MBean has thrown an exception. The
  268. * MBean will not be registered.
  269. * @exception MBeanException The constructor of the MBean has
  270. * thrown an exception
  271. * @exception NotCompliantMBeanException This class is not a JMX
  272. * compliant MBean
  273. * @exception RuntimeOperationsException Wraps a
  274. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  275. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  276. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  277. * is specified for the MBean.
  278. */
  279. public ObjectInstance createMBean(String className, ObjectName name)
  280. throws ReflectionException, InstanceAlreadyExistsException,
  281. MBeanRegistrationException, MBeanException,
  282. NotCompliantMBeanException;
  283. /**
  284. * <p>Instantiates and registers an MBean in the MBean server. The
  285. * class loader to be used is identified by its object name. An
  286. * object name is associated to the MBean. If the object name of
  287. * the loader is null, the ClassLoader that loaded the MBean
  288. * server will be used. If the MBean's object name given is null,
  289. * the MBean must provide its own name by implementing the {@link
  290. * javax.management.MBeanRegistration MBeanRegistration} interface
  291. * and returning the name from the {@link
  292. * MBeanRegistration#preRegister preRegister} method.</p>
  293. *
  294. * <p>This method is equivalent to {@link
  295. * #createMBean(String,ObjectName,ObjectName,Object[],String[])
  296. * createMBean(className, name, loaderName, (Object[]) null,
  297. * (String[]) null)}.</p>
  298. *
  299. * @param className The class name of the MBean to be instantiated.
  300. * @param name The object name of the MBean. May be null.
  301. * @param loaderName The object name of the class loader to be used.
  302. *
  303. * @return An <CODE>ObjectInstance</CODE>, containing the
  304. * <CODE>ObjectName</CODE> and the Java class name of the newly
  305. * instantiated MBean. If the contained <code>ObjectName</code>
  306. * is <code>n</code>, the contained Java class name is
  307. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  308. *
  309. * @exception ReflectionException Wraps a
  310. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  311. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  312. * invoke the MBean's constructor.
  313. * @exception InstanceAlreadyExistsException The MBean is already
  314. * under the control of the MBean server.
  315. * @exception MBeanRegistrationException The
  316. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  317. * interface) method of the MBean has thrown an exception. The
  318. * MBean will not be registered.
  319. * @exception MBeanException The constructor of the MBean has
  320. * thrown an exception
  321. * @exception NotCompliantMBeanException This class is not a JMX
  322. * compliant MBean
  323. * @exception InstanceNotFoundException The specified class loader
  324. * is not registered in the MBean server.
  325. * @exception RuntimeOperationsException Wraps a
  326. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  327. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  328. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  329. * is specified for the MBean.
  330. */
  331. public ObjectInstance createMBean(String className, ObjectName name,
  332. ObjectName loaderName)
  333. throws ReflectionException, InstanceAlreadyExistsException,
  334. MBeanRegistrationException, MBeanException,
  335. NotCompliantMBeanException, InstanceNotFoundException;
  336. /**
  337. * Instantiates and registers an MBean in the MBean server. The
  338. * MBean server will use its {@link
  339. * javax.management.loading.ClassLoaderRepository Default Loader
  340. * Repository} to load the class of the MBean. An object name is
  341. * associated to the MBean. If the object name given is null, the
  342. * MBean must provide its own name by implementing the {@link
  343. * javax.management.MBeanRegistration MBeanRegistration} interface
  344. * and returning the name from the {@link
  345. * MBeanRegistration#preRegister preRegister} method.
  346. *
  347. * @param className The class name of the MBean to be instantiated.
  348. * @param name The object name of the MBean. May be null.
  349. * @param params An array containing the parameters of the
  350. * constructor to be invoked.
  351. * @param signature An array containing the signature of the
  352. * constructor to be invoked.
  353. *
  354. * @return An <CODE>ObjectInstance</CODE>, containing the
  355. * <CODE>ObjectName</CODE> and the Java class name of the newly
  356. * instantiated MBean. If the contained <code>ObjectName</code>
  357. * is <code>n</code>, the contained Java class name is
  358. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  359. *
  360. * @exception ReflectionException Wraps a
  361. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  362. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  363. * invoke the MBean's constructor.
  364. * @exception InstanceAlreadyExistsException The MBean is already
  365. * under the control of the MBean server.
  366. * @exception MBeanRegistrationException The
  367. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  368. * interface) method of the MBean has thrown an exception. The
  369. * MBean will not be registered.
  370. * @exception MBeanException The constructor of the MBean has
  371. * thrown an exception
  372. * @exception NotCompliantMBeanException This class is not a JMX
  373. * compliant MBean
  374. * @exception RuntimeOperationsException Wraps a
  375. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  376. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  377. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  378. * is specified for the MBean.
  379. */
  380. public ObjectInstance createMBean(String className, ObjectName name,
  381. Object params[], String signature[])
  382. throws ReflectionException, InstanceAlreadyExistsException,
  383. MBeanRegistrationException, MBeanException,
  384. NotCompliantMBeanException;
  385. /**
  386. * Instantiates and registers an MBean in the MBean server. The
  387. * class loader to be used is identified by its object name. An
  388. * object name is associated to the MBean. If the object name of
  389. * the loader is not specified, the ClassLoader that loaded the
  390. * MBean server will be used. If the MBean object name given is
  391. * null, the MBean must provide its own name by implementing the
  392. * {@link javax.management.MBeanRegistration MBeanRegistration}
  393. * interface and returning the name from the {@link
  394. * MBeanRegistration#preRegister preRegister} method.
  395. *
  396. * @param className The class name of the MBean to be instantiated.
  397. * @param name The object name of the MBean. May be null.
  398. * @param params An array containing the parameters of the
  399. * constructor to be invoked.
  400. * @param signature An array containing the signature of the
  401. * constructor to be invoked.
  402. * @param loaderName The object name of the class loader to be used.
  403. *
  404. * @return An <CODE>ObjectInstance</CODE>, containing the
  405. * <CODE>ObjectName</CODE> and the Java class name of the newly
  406. * instantiated MBean. If the contained <code>ObjectName</code>
  407. * is <code>n</code>, the contained Java class name is
  408. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  409. *
  410. * @exception ReflectionException Wraps a
  411. * <CODE>java.lang.ClassNotFoundException</CODE> or a
  412. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  413. * invoke the MBean's constructor.
  414. * @exception InstanceAlreadyExistsException The MBean is already
  415. * under the control of the MBean server.
  416. * @exception MBeanRegistrationException The
  417. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  418. * interface) method of the MBean has thrown an exception. The
  419. * MBean will not be registered.
  420. * @exception MBeanException The constructor of the MBean has
  421. * thrown an exception
  422. * @exception NotCompliantMBeanException This class is not a JMX
  423. * compliant MBean
  424. * @exception InstanceNotFoundException The specified class loader
  425. * is not registered in the MBean server.
  426. * @exception RuntimeOperationsException Wraps a
  427. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  428. * passed in parameter is null, the <CODE>ObjectName</CODE> passed
  429. * in parameter contains a pattern or no <CODE>ObjectName</CODE>
  430. * is specified for the MBean.
  431. *
  432. */
  433. public ObjectInstance createMBean(String className, ObjectName name,
  434. ObjectName loaderName, Object params[],
  435. String signature[])
  436. throws ReflectionException, InstanceAlreadyExistsException,
  437. MBeanRegistrationException, MBeanException,
  438. NotCompliantMBeanException, InstanceNotFoundException;
  439. /**
  440. * Registers a pre-existing object as an MBean with the MBean
  441. * server. If the object name given is null, the MBean must
  442. * provide its own name by implementing the {@link
  443. * javax.management.MBeanRegistration MBeanRegistration} interface
  444. * and returning the name from the {@link
  445. * MBeanRegistration#preRegister preRegister} method.
  446. *
  447. * @param object The MBean to be registered as an MBean.
  448. * @param name The object name of the MBean. May be null.
  449. *
  450. * @return An <CODE>ObjectInstance</CODE>, containing the
  451. * <CODE>ObjectName</CODE> and the Java class name of the newly
  452. * registered MBean. If the contained <code>ObjectName</code>
  453. * is <code>n</code>, the contained Java class name is
  454. * <code>{@link #getMBeanInfo getMBeanInfo(n)}.getClassName()</code>.
  455. *
  456. * @exception InstanceAlreadyExistsException The MBean is already
  457. * under the control of the MBean server.
  458. * @exception MBeanRegistrationException The
  459. * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
  460. * interface) method of the MBean has thrown an exception. The
  461. * MBean will not be registered.
  462. * @exception NotCompliantMBeanException This object is not a JMX
  463. * compliant MBean
  464. * @exception RuntimeOperationsException Wraps a
  465. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  466. * passed in parameter is null or no object name is specified.
  467. */
  468. public ObjectInstance registerMBean(Object object, ObjectName name)
  469. throws InstanceAlreadyExistsException, MBeanRegistrationException,
  470. NotCompliantMBeanException;
  471. /**
  472. * Unregisters an MBean from the MBean server. The MBean is
  473. * identified by its object name. Once the method has been
  474. * invoked, the MBean may no longer be accessed by its object
  475. * name.
  476. *
  477. * @param name The object name of the MBean to be unregistered.
  478. *
  479. * @exception InstanceNotFoundException The MBean specified is not
  480. * registered in the MBean server.
  481. * @exception MBeanRegistrationException The preDeregister
  482. * ((<CODE>MBeanRegistration</CODE> interface) method of the MBean
  483. * has thrown an exception.
  484. * @exception RuntimeOperationsException Wraps a
  485. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  486. * name in parameter is null or the MBean you are when trying to
  487. * unregister is the {@link javax.management.MBeanServerDelegate
  488. * MBeanServerDelegate} MBean.
  489. *
  490. */
  491. public void unregisterMBean(ObjectName name)
  492. throws InstanceNotFoundException, MBeanRegistrationException;
  493. /**
  494. * Gets the <CODE>ObjectInstance</CODE> for a given MBean
  495. * registered with the MBean server.
  496. *
  497. * @param name The object name of the MBean.
  498. *
  499. * @return The <CODE>ObjectInstance</CODE> associated with the MBean
  500. * specified by <VAR>name</VAR>. The contained <code>ObjectName</code>
  501. * is <code>name</code> and the contained class name is
  502. * <code>{@link #getMBeanInfo getMBeanInfo(name)}.getClassName()</code>.
  503. *
  504. * @exception InstanceNotFoundException The MBean specified is not
  505. * registered in the MBean server.
  506. */
  507. public ObjectInstance getObjectInstance(ObjectName name)
  508. throws InstanceNotFoundException;
  509. /**
  510. * Gets MBeans controlled by the MBean server. This method allows
  511. * any of the following to be obtained: All MBeans, a set of
  512. * MBeans specified by pattern matching on the
  513. * <CODE>ObjectName</CODE> and/or a Query expression, a specific
  514. * MBean. When the object name is null or no domain and key
  515. * properties are specified, all objects are to be selected (and
  516. * filtered if a query is specified). It returns the set of
  517. * <CODE>ObjectInstance</CODE> objects (containing the
  518. * <CODE>ObjectName</CODE> and the Java Class name) for the
  519. * selected MBeans.
  520. *
  521. * @param name The object name pattern identifying the MBeans to
  522. * be retrieved. If null or no domain and key properties are
  523. * specified, all the MBeans registered will be retrieved.
  524. * @param query The query expression to be applied for selecting
  525. * MBeans. If null no query expression will be applied for
  526. * selecting MBeans.
  527. *
  528. * @return A set containing the <CODE>ObjectInstance</CODE>
  529. * objects for the selected MBeans. If no MBean satisfies the
  530. * query an empty set is returned.
  531. */
  532. public Set queryMBeans(ObjectName name, QueryExp query);
  533. /**
  534. * Gets the names of MBeans controlled by the MBean server. This
  535. * method enables any of the following to be obtained: The names
  536. * of all MBeans, the names of a set of MBeans specified by
  537. * pattern matching on the <CODE>ObjectName</CODE> and/or a Query
  538. * expression, a specific MBean name (equivalent to testing
  539. * whether an MBean is registered). When the object name is null
  540. * or no domain and key properties are specified, all objects are
  541. * selected (and filtered if a query is specified). It returns the
  542. * set of ObjectNames for the MBeans selected.
  543. *
  544. * @param name The object name pattern identifying the MBean names
  545. * to be retrieved. If null or no domain and key properties are
  546. * specified, the name of all registered MBeans will be retrieved.
  547. * @param query The query expression to be applied for selecting
  548. * MBeans. If null no query expression will be applied for
  549. * selecting MBeans.
  550. *
  551. * @return A set containing the ObjectNames for the MBeans
  552. * selected. If no MBean satisfies the query, an empty set is
  553. * returned.
  554. */
  555. public Set queryNames(ObjectName name, QueryExp query);
  556. /**
  557. * Checks whether an MBean, identified by its object name, is
  558. * already registered with the MBean server.
  559. *
  560. * @param name The object name of the MBean to be checked.
  561. *
  562. * @return True if the MBean is already registered in the MBean
  563. * server, false otherwise.
  564. *
  565. * @exception RuntimeOperationsException Wraps a
  566. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  567. * name in parameter is null.
  568. */
  569. public boolean isRegistered(ObjectName name);
  570. /**
  571. * Returns the number of MBeans registered in the MBean server.
  572. *
  573. * @return the number of registered MBeans, wrapped in an Integer.
  574. * If the caller's permissions are restricted, this number may
  575. * be greater than the number of MBeans the caller can access.
  576. */
  577. public Integer getMBeanCount();
  578. /**
  579. * Gets the value of a specific attribute of a named MBean. The MBean
  580. * is identified by its object name.
  581. *
  582. * @param name The object name of the MBean from which the
  583. * attribute is to be retrieved.
  584. * @param attribute A String specifying the name of the attribute
  585. * to be retrieved.
  586. *
  587. * @return The value of the retrieved attribute.
  588. *
  589. * @exception AttributeNotFoundException The attribute specified
  590. * is not accessible in the MBean.
  591. * @exception MBeanException Wraps an exception thrown by the
  592. * MBean's getter.
  593. * @exception InstanceNotFoundException The MBean specified is not
  594. * registered in the MBean server.
  595. * @exception ReflectionException Wraps a
  596. * <CODE>java.lang.Exception</CODE> thrown when trying to invoke
  597. * the setter.
  598. * @exception RuntimeOperationsException Wraps a
  599. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  600. * name in parameter is null or the attribute in parameter is
  601. * null.
  602. *
  603. * @see #setAttribute
  604. */
  605. public Object getAttribute(ObjectName name, String attribute)
  606. throws MBeanException, AttributeNotFoundException,
  607. InstanceNotFoundException, ReflectionException;
  608. /**
  609. * Gets the values of several attributes of a named MBean. The MBean
  610. * is identified by its object name.
  611. *
  612. * @param name The object name of the MBean from which the
  613. * attributes are retrieved.
  614. * @param attributes A list of the attributes to be retrieved.
  615. *
  616. * @return The list of the retrieved attributes.
  617. *
  618. * @exception InstanceNotFoundException The MBean specified is not
  619. * registered in the MBean server.
  620. * @exception ReflectionException An exception occurred when
  621. * trying to invoke the getAttributes method of a Dynamic MBean.
  622. * @exception RuntimeOperationsException Wrap a
  623. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  624. * name in parameter is null or attributes in parameter is null.
  625. *
  626. * @see #setAttributes
  627. */
  628. public AttributeList getAttributes(ObjectName name, String[] attributes)
  629. throws InstanceNotFoundException, ReflectionException;
  630. /**
  631. * Sets the value of a specific attribute of a named MBean. The MBean
  632. * is identified by its object name.
  633. *
  634. * @param name The name of the MBean within which the attribute is
  635. * to be set.
  636. * @param attribute The identification of the attribute to be set
  637. * and the value it is to be set to.
  638. *
  639. * @exception InstanceNotFoundException The MBean specified is not
  640. * registered in the MBean server.
  641. * @exception AttributeNotFoundException The attribute specified
  642. * is not accessible in the MBean.
  643. * @exception InvalidAttributeValueException The value specified
  644. * for the attribute is not valid.
  645. * @exception MBeanException Wraps an exception thrown by the
  646. * MBean's setter.
  647. * @exception ReflectionException Wraps a
  648. * <CODE>java.lang.Exception</CODE> thrown when trying to invoke
  649. * the setter.
  650. * @exception RuntimeOperationsException Wraps a
  651. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  652. * name in parameter is null or the attribute in parameter is
  653. * null.
  654. *
  655. * @see #getAttribute
  656. */
  657. public void setAttribute(ObjectName name, Attribute attribute)
  658. throws InstanceNotFoundException, AttributeNotFoundException,
  659. InvalidAttributeValueException, MBeanException,
  660. ReflectionException;
  661. /**
  662. * Sets the values of several attributes of a named MBean. The MBean is
  663. * identified by its object name.
  664. *
  665. * @param name The object name of the MBean within which the
  666. * attributes are to be set.
  667. * @param attributes A list of attributes: The identification of
  668. * the attributes to be set and the values they are to be set to.
  669. *
  670. * @return The list of attributes that were set, with their new
  671. * values.
  672. *
  673. * @exception InstanceNotFoundException The MBean specified is not
  674. * registered in the MBean server.
  675. * @exception ReflectionException An exception occurred when
  676. * trying to invoke the setAttributes method of a Dynamic MBean.
  677. * @exception RuntimeOperationsException Wraps a
  678. * <CODE>java.lang.IllegalArgumentException</CODE>: The object
  679. * name in parameter is null or attributes in parameter is null.
  680. *
  681. * @see #getAttributes
  682. */
  683. public AttributeList setAttributes(ObjectName name,
  684. AttributeList attributes)
  685. throws InstanceNotFoundException, ReflectionException;
  686. /**
  687. * Invokes an operation on an MBean.
  688. *
  689. * @param name The object name of the MBean on which the method is
  690. * to be invoked.
  691. * @param operationName The name of the operation to be invoked.
  692. * @param params An array containing the parameters to be set when
  693. * the operation is invoked
  694. * @param signature An array containing the signature of the
  695. * operation. The class objects will be loaded using the same
  696. * class loader as the one used for loading the MBean on which the
  697. * operation was invoked.
  698. *
  699. * @return The object returned by the operation, which represents
  700. * the result of invoking the operation on the MBean specified.
  701. *
  702. * @exception InstanceNotFoundException The MBean specified is not
  703. * registered in the MBean server.
  704. * @exception MBeanException Wraps an exception thrown by the
  705. * MBean's invoked method.
  706. * @exception ReflectionException Wraps a
  707. * <CODE>java.lang.Exception</CODE> thrown while trying to invoke
  708. * the method.
  709. */
  710. public Object invoke(ObjectName name, String operationName,
  711. Object params[], String signature[])
  712. throws InstanceNotFoundException, MBeanException,
  713. ReflectionException;
  714. /**
  715. * Returns the default domain used for naming the MBean.
  716. * The default domain name is used as the domain part in the ObjectName
  717. * of MBeans if no domain is specified by the user.
  718. *
  719. * @return the default domain.
  720. */
  721. public String getDefaultDomain();
  722. /**
  723. * <p>Returns the list of domains in which any MBean is currently
  724. * registered. A string is in the returned array if and only if
  725. * there is at least one MBean registered with an ObjectName whose
  726. * {@link ObjectName#getDomain() getDomain()} is equal to that
  727. * string. The order of strings within the returned array is
  728. * not defined.</p>
  729. *
  730. * @return the list of domains.
  731. *
  732. * @since.unbundled JMX 1.2
  733. */
  734. public String[] getDomains();
  735. /**
  736. * <p>Adds a listener to a registered MBean.</p>
  737. *
  738. * <P> A notification emitted by the MBean will be forwarded by the
  739. * MBeanServer to the listener. If the source of the notification
  740. * is a reference to the MBean object, the MBean server will replace it
  741. * by the MBean's ObjectName. Otherwise the source is unchanged.
  742. *
  743. * @param name The name of the MBean on which the listener should
  744. * be added.
  745. * @param listener The listener object which will handle the
  746. * notifications emitted by the registered MBean.
  747. * @param filter The filter object. If filter is null, no
  748. * filtering will be performed before handling notifications.
  749. * @param handback The context to be sent to the listener when a
  750. * notification is emitted.
  751. *
  752. * @exception InstanceNotFoundException The MBean name provided
  753. * does not match any of the registered MBeans.
  754. *
  755. * @see #removeNotificationListener(ObjectName, NotificationListener)
  756. * @see #removeNotificationListener(ObjectName, NotificationListener,
  757. * NotificationFilter, Object)
  758. */
  759. public void addNotificationListener(ObjectName name,
  760. NotificationListener listener,
  761. NotificationFilter filter,
  762. Object handback)
  763. throws InstanceNotFoundException;
  764. /**
  765. * <p>Adds a listener to a registered MBean.</p>
  766. *
  767. * <P> A notification emitted by the MBean will be forwarded by the
  768. * MBeanServer to the listener. If the source of the notification
  769. * is a reference to the MBean object, the MBean server will replace it
  770. * by the MBean's ObjectName. Otherwise the source is unchanged.
  771. *
  772. * <p>The listener object that receives notifications is the one
  773. * that is registered with the given name at the time this method
  774. * is called. Even if it is subsequently unregistered, it will
  775. * continue to receive notifications.</p>
  776. *
  777. * @param name The name of the MBean on which the listener should
  778. * be added.
  779. * @param listener The object name of the listener which will
  780. * handle the notifications emitted by the registered MBean.
  781. * @param filter The filter object. If filter is null, no
  782. * filtering will be performed before handling notifications.
  783. * @param handback The context to be sent to the listener when a
  784. * notification is emitted.
  785. *
  786. * @exception InstanceNotFoundException The MBean name of the
  787. * notification listener or of the notification broadcaster does
  788. * not match any of the registered MBeans.
  789. * @exception RuntimeOperationsException Wraps an {@link
  790. * IllegalArgumentException}. The MBean named by
  791. * <code>listener</code> exists but does not implement the {@link
  792. * NotificationListener} interface.
  793. *
  794. * @see #removeNotificationListener(ObjectName, ObjectName)
  795. * @see #removeNotificationListener(ObjectName, ObjectName,
  796. * NotificationFilter, Object)
  797. */
  798. public void addNotificationListener(ObjectName name,
  799. ObjectName listener,
  800. NotificationFilter filter,
  801. Object handback)
  802. throws InstanceNotFoundException;
  803. /**
  804. * Removes a listener from a registered MBean.
  805. *
  806. * <P> If the listener is registered more than once, perhaps with
  807. * different filters or callbacks, this method will remove all
  808. * those registrations.
  809. *
  810. * @param name The name of the MBean on which the listener should
  811. * be removed.
  812. * @param listener The object name of the listener to be removed.
  813. *
  814. * @exception InstanceNotFoundException The MBean name provided
  815. * does not match any of the registered MBeans.
  816. * @exception ListenerNotFoundException The listener is not
  817. * registered in the MBean.
  818. *
  819. * @see #addNotificationListener(ObjectName, ObjectName,
  820. * NotificationFilter, Object)
  821. */
  822. public void removeNotificationListener(ObjectName name,
  823. ObjectName listener)
  824. throws InstanceNotFoundException, ListenerNotFoundException;
  825. /**
  826. * <p>Removes a listener from a registered MBean.</p>
  827. *
  828. * <p>The MBean must have a listener that exactly matches the
  829. * given <code>listener</code>, <code>filter</code>, and
  830. * <code>handback</code> parameters. If there is more than one
  831. * such listener, only one is removed.</p>
  832. *
  833. * <p>The <code>filter</code> and <code>handback</code> parameters
  834. * may be null if and only if they are null in a listener to be
  835. * removed.</p>
  836. *
  837. * @param name The name of the MBean on which the listener should
  838. * be removed.
  839. * @param listener A listener that was previously added to this
  840. * MBean.
  841. * @param filter The filter that was specified when the listener
  842. * was added.
  843. * @param handback The handback that was specified when the
  844. * listener was added.
  845. *
  846. * @exception InstanceNotFoundException The MBean name provided
  847. * does not match any of the registered MBeans.
  848. * @exception ListenerNotFoundException The listener is not
  849. * registered in the MBean, or it is not registered with the given
  850. * filter and handback.
  851. *
  852. * @see #addNotificationListener(ObjectName, ObjectName,
  853. * NotificationFilter, Object)
  854. *
  855. * @since.unbundled JMX 1.2
  856. */
  857. public void removeNotificationListener(ObjectName name,
  858. ObjectName listener,
  859. NotificationFilter filter,
  860. Object handback)
  861. throws InstanceNotFoundException, ListenerNotFoundException;
  862. /**
  863. * <p>Removes a listener from a registered MBean.</p>
  864. *
  865. * <P> If the listener is registered more than once, perhaps with
  866. * different filters or callbacks, this method will remove all
  867. * those registrations.
  868. *
  869. * @param name The name of the MBean on which the listener should
  870. * be removed.
  871. * @param listener The object name of the listener to be removed.
  872. *
  873. * @exception InstanceNotFoundException The MBean name provided
  874. * does not match any of the registered MBeans.
  875. * @exception ListenerNotFoundException The listener is not
  876. * registered in the MBean.
  877. *
  878. * @see #addNotificationListener(ObjectName, NotificationListener,
  879. * NotificationFilter, Object)
  880. */
  881. public void removeNotificationListener(ObjectName name,
  882. NotificationListener listener)
  883. throws InstanceNotFoundException, ListenerNotFoundException;
  884. /**
  885. * <p>Removes a listener from a registered MBean.</p>
  886. *
  887. * <p>The MBean must have a listener that exactly matches the
  888. * given <code>listener</code>, <code>filter</code>, and
  889. * <code>handback</code> parameters. If there is more than one
  890. * such listener, only one is removed.</p>
  891. *
  892. * <p>The <code>filter</code> and <code>handback</code> parameters
  893. * may be null if and only if they are null in a listener to be
  894. * removed.</p>
  895. *
  896. * @param name The name of the MBean on which the listener should
  897. * be removed.
  898. * @param listener A listener that was previously added to this
  899. * MBean.
  900. * @param filter The filter that was specified when the listener
  901. * was added.
  902. * @param handback The handback that was specified when the
  903. * listener was added.
  904. *
  905. * @exception InstanceNotFoundException The MBean name provided
  906. * does not match any of the registered MBeans.
  907. * @exception ListenerNotFoundException The listener is not
  908. * registered in the MBean, or it is not registered with the given
  909. * filter and handback.
  910. *
  911. * @see #addNotificationListener(ObjectName, NotificationListener,
  912. * NotificationFilter, Object)
  913. *
  914. * @since.unbundled JMX 1.2
  915. */
  916. public void removeNotificationListener(ObjectName name,
  917. NotificationListener listener,
  918. NotificationFilter filter,
  919. Object handback)
  920. throws InstanceNotFoundException, ListenerNotFoundException;
  921. /**
  922. * This method discovers the attributes and operations that an
  923. * MBean exposes for management.
  924. *
  925. * @param name The name of the MBean to analyze
  926. *
  927. * @return An instance of <CODE>MBeanInfo</CODE> allowing the
  928. * retrieval of all attributes and operations of this MBean.
  929. *
  930. * @exception IntrospectionException An exception occurred during
  931. * introspection.
  932. * @exception InstanceNotFoundException The MBean specified was
  933. * not found.
  934. * @exception ReflectionException An exception occurred when
  935. * trying to invoke the getMBeanInfo of a Dynamic MBean.
  936. */
  937. public MBeanInfo getMBeanInfo(ObjectName name)
  938. throws InstanceNotFoundException, IntrospectionException,
  939. ReflectionException;
  940. /**
  941. * <p>Returns true if the MBean specified is an instance of the
  942. * specified class, false otherwise.</p>
  943. *
  944. * <p>If <code>name</code> does not name an MBean, this method
  945. * throws {@link InstanceNotFoundException}.</p>
  946. *
  947. * <p>Otherwise, let<br>
  948. * X be the MBean named by <code>name</code>,<br>
  949. * L be the ClassLoader of X,<br>
  950. * N be the class name in X's {@link MBeanInfo}.</p>
  951. *
  952. * <p>If N equals <code>className</code>, the result is true.</p>
  953. *
  954. * <p>Otherwise, if L successfully loads both N and
  955. * <code>className</code>, and the second class is assignable from
  956. * the first, the result is true.</p>
  957. *
  958. * <p>Otherwise, the result is false.</p>
  959. *
  960. * @param name The <CODE>ObjectName</CODE> of the MBean.
  961. * @param className The name of the class.
  962. *
  963. * @return true if the MBean specified is an instance of the
  964. * specified class according to the rules above, false otherwise.
  965. *
  966. * @exception InstanceNotFoundException The MBean specified is not
  967. * registered in the MBean server.
  968. *
  969. * @see Class#isAssignableFrom(Class)
  970. */
  971. public boolean isInstanceOf(ObjectName name, String className)
  972. throws InstanceNotFoundException;
  973. /**
  974. * <p>Instantiates an object using the list of all class loaders
  975. * registered in the MBean server's {@link
  976. * javax.management.loading.ClassLoaderRepository Class Loader
  977. * Repository}. The object's class should have a public
  978. * constructor. This method returns a reference to the newly
  979. * created object. The newly created object is not registered in
  980. * the MBean server.</p>
  981. *
  982. * <p>This method is equivalent to {@link
  983. * #instantiate(String,Object[],String[])
  984. * instantiate(className, (Object[]) null, (String[]) null)}.</p>
  985. *
  986. * @param className The class name of the object to be instantiated.
  987. *
  988. * @return The newly instantiated object.
  989. *
  990. * @exception ReflectionException Wraps a
  991. * <CODE>java.lang.ClassNotFoundException</CODE> or the
  992. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  993. * invoke the object's constructor.
  994. * @exception MBeanException The constructor of the object has
  995. * thrown an exception
  996. * @exception RuntimeOperationsException Wraps a
  997. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  998. * passed in parameter is null.
  999. */
  1000. public Object instantiate(String className)
  1001. throws ReflectionException, MBeanException;
  1002. /**
  1003. * <p>Instantiates an object using the class Loader specified by its
  1004. * <CODE>ObjectName</CODE>. If the loader name is null, the
  1005. * ClassLoader that loaded the MBean Server will be used. The
  1006. * object's class should have a public constructor. This method
  1007. * returns a reference to the newly created object. The newly
  1008. * created object is not registered in the MBean server.</p>
  1009. *
  1010. * <p>This method is equivalent to {@link
  1011. * #instantiate(String,ObjectName,Object[],String[])
  1012. * instantiate(className, loaderName, (Object[]) null, (String[])
  1013. * null)}.</p>
  1014. *
  1015. * @param className The class name of the MBean to be instantiated.
  1016. * @param loaderName The object name of the class loader to be used.
  1017. *
  1018. * @return The newly instantiated object.
  1019. *
  1020. * @exception ReflectionException Wraps a
  1021. * <CODE>java.lang.ClassNotFoundException</CODE> or the
  1022. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  1023. * invoke the object's constructor.
  1024. * @exception MBeanException The constructor of the object has
  1025. * thrown an exception.
  1026. * @exception InstanceNotFoundException The specified class loader
  1027. * is not registered in the MBeanServer.
  1028. * @exception RuntimeOperationsException Wraps a
  1029. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  1030. * passed in parameter is null.
  1031. */
  1032. public Object instantiate(String className, ObjectName loaderName)
  1033. throws ReflectionException, MBeanException,
  1034. InstanceNotFoundException;
  1035. /**
  1036. * <p>Instantiates an object using the list of all class loaders
  1037. * registered in the MBean server {@link
  1038. * javax.management.loading.ClassLoaderRepository Class Loader
  1039. * Repository}. The object's class should have a public
  1040. * constructor. The call returns a reference to the newly created
  1041. * object. The newly created object is not registered in the
  1042. * MBean server.</p>
  1043. *
  1044. * @param className The class name of the object to be instantiated.
  1045. * @param params An array containing the parameters of the
  1046. * constructor to be invoked.
  1047. * @param signature An array containing the signature of the
  1048. * constructor to be invoked.
  1049. *
  1050. * @return The newly instantiated object.
  1051. *
  1052. * @exception ReflectionException Wraps a
  1053. * <CODE>java.lang.ClassNotFoundException</CODE> or the
  1054. * <CODE>java.lang.Exception</CODE> that occurred when trying to
  1055. * invoke the object's constructor.
  1056. * @exception MBeanException The constructor of the object has
  1057. * thrown an exception
  1058. * @exception RuntimeOperationsException Wraps a
  1059. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  1060. * passed in parameter is null.
  1061. */
  1062. public Object instantiate(String className, Object params[],
  1063. String signature[])
  1064. throws ReflectionException, MBeanException;
  1065. /**
  1066. * <p>Instantiates an object. The class loader to be used is
  1067. * identified by its object name. If the object name of the loader
  1068. * is null, the ClassLoader that loaded the MBean server will be
  1069. * used. The object's class should have a public constructor.
  1070. * The call returns a reference to the newly created object. The
  1071. * newly created object is not registered in the MBean server.</p>
  1072. *
  1073. * @param className The class name of the object to be instantiated.
  1074. * @param params An array containing the parameters of the
  1075. * constructor to be invoked.
  1076. * @param signature An array containing the signature of the
  1077. * constructor to be invoked.
  1078. * @param loaderName The object name of the class loader to be used.
  1079. *
  1080. * @return The newly instantiated object.
  1081. *
  1082. * @exception ReflectionException Wraps a <CODE>java.lang.ClassNotFoundException</CODE> or the <CODE>java.lang.Exception</CODE> that
  1083. * occurred when trying to invoke the object's constructor.
  1084. * @exception MBeanException The constructor of the object has
  1085. * thrown an exception
  1086. * @exception InstanceNotFoundException The specified class loader
  1087. * is not registered in the MBean server.
  1088. * @exception RuntimeOperationsException Wraps a
  1089. * <CODE>java.lang.IllegalArgumentException</CODE>: The className
  1090. * passed in parameter is null.
  1091. */
  1092. public Object instantiate(String className, ObjectName loaderName,
  1093. Object params[], String signature[])
  1094. throws ReflectionException, MBeanException,
  1095. InstanceNotFoundException;
  1096. /**
  1097. * <p>De-serializes a byte array in the context of the class loader
  1098. * of an MBean.</p>
  1099. *
  1100. * @param name The name of the MBean whose class loader should be
  1101. * used for the de-serialization.
  1102. * @param data The byte array to be de-sererialized.
  1103. *
  1104. * @return The de-serialized object stream.
  1105. *
  1106. * @exception InstanceNotFoundException The MBean specified is not
  1107. * found.
  1108. * @exception OperationsException Any of the usual Input/Output
  1109. * related exceptions.
  1110. *
  1111. * @deprecated Use {@link #getClassLoaderFor getClassLoaderFor} to
  1112. * obtain the appropriate class loader for deserialization.
  1113. */
  1114. @Deprecated
  1115. public ObjectInputStream deserialize(ObjectName name, byte[] data)
  1116. throws InstanceNotFoundException, OperationsException;
  1117. /**
  1118. * <p>De-serializes a byte array in the context of a given MBean
  1119. * class loader. The class loader is found by loading the class
  1120. * <code>className</code> through the {@link
  1121. * javax.management.loading.ClassLoaderRepository Class Loader
  1122. * Repository}. The resultant class's class loader is the one to
  1123. * use.
  1124. *
  1125. * @param className The name of the class whose class loader should be
  1126. * used for the de-serialization.
  1127. * @param data The byte array to be de-sererialized.
  1128. *
  1129. * @return The de-serialized object stream.
  1130. *
  1131. * @exception OperationsException Any of the usual Input/Output
  1132. * related exceptions.
  1133. * @exception ReflectionException The specified class could not be
  1134. * loaded by the class loader repository
  1135. *
  1136. * @deprecated Use {@link #getClassLoaderRepository} to obtain the
  1137. * class loader repository and use it to deserialize.
  1138. */
  1139. @Deprecated
  1140. public ObjectInputStream deserialize(String className, byte[] data)
  1141. throws OperationsException, ReflectionException;
  1142. /**
  1143. * <p>De-serializes a byte array in the context of a given MBean
  1144. * class loader. The class loader is the one that loaded the
  1145. * class with name "className". The name of the class loader to
  1146. * be used for loading the specified class is specified. If null,
  1147. * the MBean Server's class loader will be used.</p>
  1148. *
  1149. * @param className The name of the class whose class loader should be
  1150. * used for the de-serialization.
  1151. * @param data The byte array to be de-sererialized.
  1152. * @param loaderName The name of the class loader to be used for
  1153. * loading the specified class. If null, the MBean Server's class
  1154. * loader will be used.
  1155. *
  1156. * @return The de-serialized object stream.
  1157. *
  1158. * @exception InstanceNotFoundException The specified class loader
  1159. * MBean is not found.
  1160. * @exception OperationsException Any of the usual Input/Output
  1161. * related exceptions.
  1162. * @exception ReflectionException The specified class could not be
  1163. * loaded by the specified class loader.
  1164. *
  1165. * @deprecated Use {@link #getClassLoader getClassLoader} to obtain
  1166. * the class loader for deserialization.
  1167. */
  1168. @Deprecated
  1169. public ObjectInputStream deserialize(String className,
  1170. ObjectName loaderName,
  1171. byte[] data)
  1172. throws InstanceNotFoundException, OperationsException,
  1173. ReflectionException;
  1174. /**
  1175. * <p>Return the {@link java.lang.ClassLoader} that was used for
  1176. * loading the class of the named MBean.</p>
  1177. *
  1178. * @param mbeanName The ObjectName of the MBean.
  1179. *
  1180. * @return The ClassLoader used for that MBean. If <var>l</var>
  1181. * is the MBean's actual ClassLoader, and <var>r</var> is the
  1182. * returned value, then either:
  1183. *
  1184. * <ul>
  1185. * <li><var>r</var> is identical to <var>l</var> or
  1186. * <li>the result of <var>r</var>{@link
  1187. * ClassLoader#loadClass(String) .loadClass(<var>s</var>)} is the
  1188. * same as <var>l</var>{@link ClassLoader#loadClass(String)
  1189. * .loadClass(<var>s</var>)} for any string <var>s</var>.
  1190. * </ul>
  1191. *
  1192. * What this means is that the ClassLoader may be wrapped in
  1193. * another ClassLoader for security or other reasons.
  1194. *
  1195. * @exception InstanceNotFoundException if the named MBean is not found.
  1196. *
  1197. * @since.unbundled JMX 1.2
  1198. */
  1199. public ClassLoader getClassLoaderFor(ObjectName mbeanName)
  1200. throws InstanceNotFoundException;
  1201. /**
  1202. * <p>Return the named {@link java.lang.ClassLoader}.</p>
  1203. *
  1204. * @param loaderName The ObjectName of the ClassLoader. May be
  1205. * null, in which case the MBean server's own ClassLoader is
  1206. * returned.
  1207. *
  1208. * @return The named ClassLoader. If <var>l</var> is the actual
  1209. * ClassLoader with that name, and <var>r</var> is the returned
  1210. * value, then either:
  1211. *
  1212. * <ul>
  1213. * <li><var>r</var> is identical to <var>l</var> or
  1214. * <li>the result of <var>r</var>{@link
  1215. * ClassLoader#loadClass(String) .loadClass(<var>s</var>)} is the
  1216. * same as <var>l</var>{@link ClassLoader#loadClass(String)
  1217. * .loadClass(<var>s</var>)} for any string <var>s</var>.
  1218. * </ul>
  1219. *
  1220. * What this means is that the ClassLoader may be wrapped in
  1221. * another ClassLoader for security or other reasons.
  1222. *
  1223. * @exception InstanceNotFoundException if the named ClassLoader is
  1224. * not found.
  1225. *
  1226. * @since.unbundled JMX 1.2
  1227. */
  1228. public ClassLoader getClassLoader(ObjectName loaderName)
  1229. throws InstanceNotFoundException;
  1230. /**
  1231. * <p>Return the ClassLoaderRepository for this MBeanServer.
  1232. * @return The ClassLoaderRepository for this MBeanServer.
  1233. *
  1234. * @since.unbundled JMX 1.2
  1235. */
  1236. public ClassLoaderRepository getClassLoaderRepository();
  1237. }