ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/admin/jmxmbean.htm

48 lines
7.1 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Customize using JMX MBeans</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h4><a name="jmxmbean"></a>Customize using JMX MBeans</h4>
<p>You can extend WebSphere Application Server - Express administration by supplying and registering new JMX MBeans in one of the WebSphere Application Server - Express processes. JMX MBeans represent the management interface for a particular piece of logic. All of the managed resources within the standard WebSphere Application Server - Express infrastructure are represented as JMX MBeans. There are a variety of ways to create your own MBeans and register them with the JMX MBeanServer running in any WebSphere process.</p>
<p>Perform the following steps to customize using JMX MBeans:</p>
<ol>
<li><p><strong>Create custom JMX MBeans</strong>.</p>
<p>You can use any existing JMX MBean from another application. You can register any MBean that you tested in a JMX MBeanServer outside of the WebSphere Application Server - Express environment in a WebSphere Application Server - Express process, including Standard MBeans, Dynamic MBeans, Open MBeans, and Model MBeans.</p>
<p>In addition to any existing JMX MBeans, and ones that were written and tested outside of the WebSphere Application Server - Express environment, you can use the special distributed extensions provided by WebSphere Application Server - Express to create a WebSphere ExtensionMBean provider. This alternative provides better integration with all of the distributed functions of WebSphere Application Server - Express administration. An ExtensionMBean provider implies that you supply an XML file that contains an MBean Descriptor based on the DTD shipped with WebSphere Application Server - Express. The DTD tells WebSphere Application Server - Express all of the attributes, operations, and notifications that your MBean supports. With this information, WebSphere Application Server - Express can route remote requests to your MBean and register remote Listeners to receive your MBean event notifications.</p>
<p>All of the internal WebSphere Application Server - Express MBeans follow the Model MBean pattern. For more information, see <a href="apidocs/mbean/index.html">Public MBean Interfaces</a> <img src="api.gif" width="18" height="15" alt="Link to API documentation">. Pure Java classes supply the real logic for management functions, and the WebSphere MBeanFactory class reads the description of these functions from the XML MBean Descriptor and creates an instance of a ModelMBean that matches the descriptor. This ModelMBean instance is bound to your Java classes and registered with the MBeanServer running in the same process as your classes. Your Java code becomes callable from any WebSphere Application Server - Express administrative client through the ModelMBean created and registered to represent it.</p>
</li>
<li><p><strong>Register the new MBeans</strong>.</p>
<p>There are several ways to register your MBean with the MBeanServer in a WebSphere Application Server - Express process. The following list describes the available options:</p>
<ul>
<li>Use the com.ibm.websphere.management.AdminService interface. For more information on this interface, see <a href="../program/apidocs/ae/com/ibm/websphere/management/AdminService.html">Interface AdminService</a> <img src="api.gif" width="18" height="15" alt="Link to API documentation">. You can call the registerMBean() method on the AdminService interface and the invocation is delegated to the underlying MBeanServer for the process, after appropriate security checks. You can obtain a reference to the AdminService using the getAdminService() method of the com.ibm.websphere.management.AdminServiceFactory class.</li>
<li>Get MBeanServer instances directly. You can get a direct reference to the JMX MBeanServer instance running in any WebSphere Application Server - Express process, by calling the getMBeanServer() method of the com.ibm.websphere.management.MBeanFactory class. You get a reference to the MBeanFactory class by calling the getMBeanFactory() method of the com.ibm.websphere.management.AdminService interface. Registering the MBean directly with the MBeanServer instance can result in that MBean not participating fully in the distributed features of WebSphere Application Server - Express administration.</li>
<li>Go through the com.ibm.websphere.management.MBeanFactory class. If you want the greatest possible integration with WebSphere Application Server - Express, use the MBeanFactory class to manage the life cycle of your MBean through the activateMBean and deactivateMBean methods of the MBeanFactory class. Use these methods by supplying a subclass of the RuntimeCollaborator abstract superclass and an XML MBean descriptor file. Using this approach, you supply a pure Java class that implements the management interface defined in the MBean descriptor. The MBeanFactory class creates the actual ModelMBean and registers it with WebSphere Application Server - Express administration on your behalf.</li>
<li>Use the com.ibm.websphere.management.JMXManageable and a CustomService interface. You can make the process of integrating with WebSphere Application Server - Express administration even easier, by implementing a CustomService interface, that also implements the JMXManageable interface. Using this approach, you can avoid supplying the RuntimeCollaborator. When your CustomService interface is initialized, the WebSphere Application Server - Express MBeanFactory class reads your XML MBean descriptor file and creates, binds, and registers an MBean to your CustomService interface automatically. After the shutdown method of your CustomService is called, WebSphere Application Server - Express automatically deactivates your MBean.
<!-- p>For more information on custom services, see the <em><a href="../program/custserv.htm">Custom services</a></em> topic.</p --></li>
</ul>
</li>
</ol>
<p><strong>Results</strong></p>
<p>Regardless of the approach used to create and register your MBean, you must set up proper J2EE security permissions for your new MBean code. WebSphere Application Server - Express AdminService and MBeanServer are tightly protected using J2EE security permissions, and if you do not explicitly grant your code base permissions, security exceptions are thrown when you attempt to invoke methods of these classes. If you are supplying your MBean as part of your application, you can set the permissions in the was.policy file that you supply as part of your application metadata. If you are using a CustomService interface or other code that is not delivered as an application, you can edit the library.policy file in the node configuration, or even the server.policy file in the properties directory for a specific installation. See <a href="jmxexj2ee.htm">Example: J2EE security permissions</a> for more information.</p>
</body>
</html>