User: schaefera Date: 01/05/20 13:33:39 Modified: src/docs howtojmx.xml Log: Fixed the layout to make the code easier to read and adjusted to the latest changes in the JMX Connector. Revision Changes Path 1.3 +453 -455 manual/src/docs/howtojmx.xml Index: howtojmx.xml =================================================================== RCS file: /cvsroot/jboss/manual/src/docs/howtojmx.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- howtojmx.xml 2001/03/21 08:30:20 1.2 +++ howtojmx.xml 2001/05/20 20:33:39 1.3 @@ -1,460 +1,458 @@ <?xml version = "1.0" encoding = "UTF-8"?> <section> - <title>JMX Connector Description and HowTo</title> - <para>Author:<author> - <firstname>Andreas</firstname> - <surname>Shaefer</surname> - </author> - <email>[EMAIL PROTECTED]</email> - </para> - <section> - <title>Introduction</title> - <section> - <title>JMX Spec from Sun</title> - <para> - Sun release recently the final specification, API and Reference Implemenation to the - <ulink url = "http://www.javasoft.com/products/JavaManagement/index.html"> - <citetitle>Java Management - Extention(JMX)</citetitle> - </ulink>. - The idea behind this is to provide an API to which the component vendors can make their components - manageable and the management tools vendor can use this API to manage these components. </para> - <para> - Therefore the whole JMX is separated into 3 parts: <orderedlist> - <listitem> - <para> Components implement a certain API to offer their management API to - the JMX world. There are 3 ways: through an Interface, through a API - descriptions (Open MBean) and through a Model MBean (but for this - have a look at the spec). - </para> - </listitem> - <listitem> - <para> JMX Agent which contains a MBean Server, certain services like - dynamic download, timers, relations etc. and at least one Connector - or Adaptor. - </para> - </listitem> - <listitem> - <para> Management Tool using a Connector or Adaptor to manage the - components of the JMX Agent the tool is connected to. - </para> - </listitem> - </orderedlist> - </para> - </section> - <section> - <title> JMX Implementation in JBoss</title> - <para> At the moment (8th of September 2000) JBoss uses the final release JMX API for its services defined in the -jboss.conf file (in there you see that also HTML - Adaptor and the JMX Connector are manageable components). In addition JBoss use the MBean Server implementation -and the HTML adaptor from the JMX-RI. - The JMX Connector also follows the JMX final spec and API.</para> - - - <para> You use JMX first when you start JBoss because the Main class loads the MLET tags from the jboss.conf file and -hand it over to the MBeanServer which loads the - MBean dynamically (MLET is the tag to dynamically load a MBean by the MBeanServer). Afterwards it went through -the loaded MBeans and starts all the loaded - MBeans. </para> - <para> Afterwards you can use JMX either trough the JMX HMTL Adaptor on port 8082 or through the new JMX Connector. The -JMX HTML Adaptor is provided by the - JMX-RI and the source code is not available (it is part of Sun's JDMK which you have to buy when you want to get -the source as far as I know). The JMX - Connector is part of the JBoss code and should be considered as first draft because the Connector is mentioned -within the spec by not further specified. - </para> - - <para> Finally JMX is used within the shutdown hook to terminate all the services before JBoss is terminated itself -(whatever this means) by going through all available - MBeans and send them the stop signal (call the appropriate method). - </para> - </section> - </section> - - - - <section> - - <title>Design of the JMX Connector</title> - <section> - - - <title>Introduction</title> - <para> - According to the JMX spec the Connector should allow a management tool to work on a MBeanServer and its MBeans - from another JVM which can be on the same - computer or a remote computer. One particular Connector is bound to its protocol it supports but a MBeanServer - can offer more than one (a JMX agent has to offer - at least an Adaptor or a Connector) supporting different protocols. Because the spec does not say much about - Connectors I take the freedom and implemented the - actual Connector within JBoss to lay the base for a remote JBoss management which is a little bit more - comfortable than the HTML Adaptor.</para> - - <para>By the way I will take this opportunity to thanks Rickard Öberg for his support. </para> - </section> - - <section> - - - <title>Goals</title> - <para>These are my goals for a JMX Connector: - <itemizedlist> - <listitem> - <para>Ease of use</para> - </listitem> - <listitem> - <para>From the user perspective the Connector should appear like a local</para> - </listitem> - <listitem> - <para>MBeanServer</para> - </listitem> - - - <listitem> - <para>Unsupported methods throw an exception</para> - </listitem> - <listitem> - <para>Supports remote notification handling</para> - </listitem> - <listitem> - <para>First draft supports RMI protocol</para> - </listitem> - </itemizedlist> - </para> - <para> According to the spec the JMX Connector should offer the client a Proxy for a remote MBean but then the MBean - proxy must be available at compile time and this - compete with the JMX agent requirements that an JMX agent has to support dynamic loading of MBeans therefore this - is not supported now. </para> - <section> - - - <title>Design</title> - <para> The JMX Connector is separated into 4 parts: - <orderedlist> - <listitem> - <para>Server-side implementation </para> - </listitem> - <listitem> - <para>Client-side implementation </para> - </listitem> - <listitem> - <para>Connector Factory to lookup servers and protocols (optional)</para> - </listitem> - <listitem> - <para>Test client </para> - </listitem> - </orderedlist> - </para> - - <section> - - <title>Server-side implementation</title> - <para> The server-side implementation is loaded and started by the MBeanServer which should become available for remote - management. For this we have the necessary - MBean service classes, the Connector implementation and an Object Handler class. - The Object Handler class is a serializable class allowing the remote client to deal with remotely instantiated - classes. This eliminates problems with not serializable - classes and with the unique identification of serialized classes (on a round trip you get a copy of the original - instance). </para> - <para> The Object Handler is also used to avoid - troubles with not serializable classes used as a Handback object in the Notification handling. This class allows - the client to work on the JMX Connector as he - would work on a local MBeanServer.</para> - </section> - - - <section> - - <title> Client-side implementation</title> - <para> The client-side implementation can either be used directly by instantiating the RMIClientConnectorImpl or by - using the Connector Factory. The client-side - Connector is more or less a MBeanServer which sends the request over the supported protocol to the server-side - connector and returns the returned object back to - the caller. There are a few methods which cannot be supported and therefore throw a unsupported operation - exception. </para> - - <para> To make it clear and also for documentation purpose the client-side connector implements the JMXConnector - Interface. At the moment I want still keep this - interface even when MBeanServer is now an interface too because which all good programming techniques it is (at - least at the moment) not possible to make it - 100% transparent (but see later under limitations). </para> - </section> - - - <section> - - <title> Connector Factory</title> - <para> When I started with the JMX Connector I had a management tool in mind like the network administration tool from - CA or the proposed AppCenter from Inprise. - Therefore I want to make it as easy as possible for the client to connector as many remote MBeanServers as he/she - wants and which any protocol available. The - client should never have to worry about the protocol or to know which classes are behind. That's why I created - the Connector Factory which allows the client to - search for all the remote available MBeanServers and their supported protocols. The user only has to select a - server and then a protocol and the Connector Factory - returns the appropriate instance of the JMXConnector interface. </para> - </section> - - - <section> - <title> Test Client</title> - <para> - The JMX Connector Test Client is first a test tool that the JMX Connector is working and second a demonstration - how to use it. The test tool first starts a local - MBeanServer and register the Connector Factory as first and then only MBean. Now the test client ask the - Connector Factory for all available, remote - MBeanServers and let the user select one, then it asks the Connector Factory for all available Connectors or more - precise all the supported protocols of the - available Connectors. Now the user can select the protocol and the Test Client loads and starts the appropriate - Connector (if available) and register it as a new - MBean at the local MBeanServer. Afterwards it asks the Connector for all available MBeans on the remote server, - displays it wit all the attributes and operations - on this remote MBean. At the end it will try to register to all remote MBeans a notification listener which will - inform the client about notification send by the MBean. - That's why the test client will still run after finishing. When the user terminates the Test Client it will - remove all the notification listeners from the remote - MBeanServer and terminate the Test Client. </para> - </section> - - - </section> - - - </section> - - </section> - - <section> - - <title>How To use the JMX Connector</title> - <para>You need the following to use the JMX Connector: - - <itemizedlist> - <listitem> - <para>Connector.jar (from client directory) </para> - </listitem> - - <listitem> - <para>jnp-client.jar (from client directory) </para> - </listitem> - - <listitem> - <para>jmxri.jar (from lib directory) </para> - </listitem> - - <listitem> - <para>jndi.properties (from conf directory) which you probably have to - adjust</para> - </listitem> - - </itemizedlist> - </para> - - <section> - - <title>How to create a client with the server and protocol</title> - <para> - <orderedlist> - - <listitem> - <para> Instantiate the RMIClientConnectorImpl. - + <title>JMX Connector Description and HowTo</title> + <para>Author: + <author> + <firstname>Andreas</firstname> + <surname>Schaefer</surname> + </author> + <email>[EMAIL PROTECTED]</email> + </para> + <section> + <title>Introduction</title> + <section> + <title>JMX Spec from Sun</title> + <para> + Sun release in fall 2000 the final specification, API and Reference Implemenation to the + <ulink url = "http://www.javasoft.com/products/JavaManagement/index.html"> + <citetitle>Java Management Extention(JMX)</citetitle> + </ulink>. + The idea behind this is to provide an API to which the component vendors can make their + components manageable and the management tools vendor can use this API to manage these + components. + </para> + <para> + Therefore the whole JMX is separated into 3 parts: + <orderedlist> + <listitem> + <para> + Components implement a certain API to offer their management API to + the JMX world. There are 3 ways: through an Interface, through a API + descriptions (Open MBean) and through a Model MBean (but for this + have a look at the spec). + </para> + </listitem> + <listitem> + <para> + JMX Agent which contains a MBean Server, certain services like + dynamic download, timers, relations etc. and at least one Connector + or Adaptor. + </para> + </listitem> + <listitem> + <para> + Management Tool using a Connector or Adaptor to manage the + components of the JMX Agent the tool is connected to. + </para> + </listitem> + </orderedlist> + </para> + </section> + <section> + <title>JMX Implementation in JBoss</title> + <para> + At the moment (8th of September 2000) JBoss uses the final release JMX API for its services + defined in the jboss.conf file (in there you see that also HTML Adaptor and the JMX Connector + are manageable components). In addition JBoss use the MBean Server implementation and the + HTML adaptor from the JMX-RI. The JMX Connector also follows the JMX final spec and API. + </para> + <para> + You use JMX first when you start JBoss because the Main class loads the <mbean> tags + from the jboss.jcml file and hand it over to the MBeanServer which loads the MBean dynamically + (originally in JMX MLET tags are used to dynamically load a MBean by the MBeanServer but they + were troublesome use). Afterwards it went through the loaded MBeans and starts all the loaded + MBeans. + </para> + <para> + Afterwards you can use JMX either trough the JMX HMTL Adaptor on port 8082 or through the new + JMX Connector. The JMX HTML Adaptor is provided by the JMX-RI and the source code is not + available (it is part of Sun's JDMK which you have to buy when you want to get the source + as far as I know). The JMX Connector is part of the JBoss code and should be considered as + first draft because the Connector is mentioned within the spec by not further specified (Sun's + JDMK also has a RMI-Connector but JDMK is very pricy). + </para> + <para> + Finally JMX is used within the shutdown hook and ServiceControl MBean to terminate all the + services before JBoss is terminated itself (whatever this means) by going through all available + MBeans and send them the stop signal (call the appropriate method). This let you shutdown + JBoss gracefully even programatically. + </para> + </section> + </section> + <section> + <title>Design of the JMX Connector</title> + <section> + <title>Introduction</title> + <para> + According to the JMX spec the Connector should allow a management tool to work on a MBeanServer + and its MBeans from another JVM which can be on the same computer or a remote computer. One + particular Connector is bound to its protocol it supports but a MBeanServer can offer more + than one (a JMX agent has to offer at least an Adaptor or a Connector) supporting different + protocols. Because the spec does not say much about Connectors I take the freedom and + implemented the actual Connector within JBoss to lay the base for a remote JBoss management + which is a little bit more comfortable than the HTML Adaptor. + </para> + <para>By the way I will take this opportunity to thanks Rickard Öberg for his support.</para> + </section> + <section> + <title>Goals</title> + <para> + These are my goals for a JMX Connector: + <itemizedlist> + <listitem> + <para>Ease of use</para> + </listitem> + <listitem> + <para>From the user perspective the Connector should appear like a local</para> + </listitem> + <listitem> + <para>MBeanServer</para> + </listitem> + <listitem> + <para>Unsupported methods throw an exception</para> + </listitem> + <listitem> + <para>Supports remote notification handling</para> + </listitem> + <listitem> + <para>First draft supports RMI protocol</para> + </listitem> + </itemizedlist> + </para> + <para> + According to the spec the JMX Connector should offer the client a Proxy for a remote MBean + but then the MBean proxy must be available at compile time and this compete with the JMX + agent requirements that an JMX agent has to support dynamic loading of MBeans therefore this + is not supported now. + </para> + </section> + <section> + <title>Design</title> + <para> + The JMX Connector is separated into 4 parts: + <orderedlist> + <listitem> + <para>Server-side implementation </para> + </listitem> + <listitem> + <para>Client-side implementation </para> + </listitem> + <listitem> + <para>Connector Factory to lookup servers and protocols (optional)</para> + </listitem> + <listitem> + <para>Test client </para> + </listitem> + </orderedlist> + </para> + </section> + <section> + <title>Server-side implementation</title> + <para> + The server-side implementation is loaded and started by the MBeanServer which should become + available for remote management. For this we have the necessary MBean service classes, the + Connector implementation and an Object Handler class. The Object Handler class is a + serializable class allowing the remote client to deal with remotely instantiated classes. + This eliminates problems with not serializable classes and with the unique identification + of serialized classes (on a round trip you get a copy of the original instance). + </para> + <para> + The Object Handler is also used to avoid troubles with not serializable classes used as a + Handback object in the Notification handling. This class allows the client to work on the + JMX Connector as he would work on a local MBeanServer. + </para> + </section> + </section> + <section> + <title> Client-side implementation</title> + <para> + The client-side implementation can either be used directly by instantiating the + RMIClientConnectorImpl or by using the Connector Factory. The client-side Connector is more or + less a MBeanServer which sends the request over the supported protocol to the server-side connector and returns the returned object back to + the caller. There are a few methods which cannot be supported and therefore throw a unsupported + operation exception. + </para> + <para> + To make it clear and also for documentation purpose the client-side connector implements the + JMXConnector Interface. At the moment I want still keep this interface even when MBeanServer + is now an interface too because which all good programming techniques it is (at least at the + moment) not possible to make it 100% transparent (but see later under limitations). + </para> + </section> + <section> + <title> Connector Factory</title> + <para> + When I started with the JMX Connector I had a management tool in mind like the network + administration tool from CA or the proposed AppCenter from Inprise. Therefore I want to make + it as easy as possible for the client to connector as many remote MBeanServers as he/she wants + and which any protocol available. The client should never have to worry about the protocol or + to know which classes are behind. That's why I created the Connector Factory which allows the + client to search for all the remote available MBeanServers and their supported protocols. + The user only has to select a server and then a protocol and the Connector Factory returns the + appropriate instance of the JMXConnector interface. + </para> + </section> + <section> + <title> Test Client</title> + <para> + The JMX Connector Test Client is first a test tool that the JMX Connector is working and second + a demonstration how to use it. The test tool first starts a local MBeanServer and register the + Connector Factory as first and then only MBean. Now the test client ask the Connector Factory + for all available, remote MBeanServers and let the user select one, then it asks the Connector + Factory for all available Connectors or more precise all the supported protocols of the available + Connectors. Now the user can select the protocol and the Test Client loads and starts the + appropriate Connector (if available) and register it as a new MBean at the local MBeanServer. + Afterwards it asks the Connector for all available MBeans on the remote server, displays it wit + all the attributes and operations on this remote MBean. At the end it will try to register to + all remote MBeans a notification listener which will inform the client about notification send + by the MBean. That's why the test client will still run after finishing. When the user terminates + the Test Client it will remove all the notification listeners from the remote MBeanServer and + terminate the Test Client. + </para> + </section> + <section> + <title>How To use the JMX Connector</title> + <para>You need the following to use the JMX Connector: + <itemizedlist> + <listitem> + <para>Connector.jar (from client directory) </para> + </listitem> + <listitem> + <para>jnp-client.jar (from client directory) </para> + </listitem> + <listitem> + <para>jmxri.jar (from lib directory) </para> + </listitem> + <listitem> + <para> + jndi.properties (from conf directory) which you probably have to + adjust + </para> + </listitem> + </itemizedlist> + </para> + </section> + <section> + <title>How to create a client with the server and protocol</title> + <para> + <orderedlist> + <listitem> + <para> + Instantiate the RMIClientConnectorImpl. <programlisting> - JMXConnector lConnector = new RMIClientConnectorImpl("server-name" ); </programlisting> - </para> - </listitem> - - <listitem> - <para> Use either instance or its interface JMXConnector or MBeanServer. If you got back an instance you can now - work on the remote MBeanServer like it would be a local one. - </para> - </listitem> - - <listitem> - <para> Look up for the available MBeans, its attributes and operations. You can now retrieve and set the - attributes or perform an operation on the remote MBean. - </para> - </listitem> - <listitem> - <para> - If you register a Notification Listener then stop this instance before terminating the program otherwise - the remote MBeanServer will throw an exception when this Notification Listener is called. - lConnector.stop(); - - </para> - </listitem> - </orderedlist> - </para> - </section> - - - <section> - - <title>How to create a client without the server and protocol/H3> </title> - <para> First you have to make sure that the JNDI property: - java.naming.provider.url points to the JNDI server your JMX Connectors - are registered to. At the moment you can only have one JMX Connector - running at the same computer (but serveral can be registered at the same - JNDI server) and you can only have one JNDI server. </para> - - <orderedlist> - - <listitem> - <para> Import the necessary classes - - <programlisting> import com.sun.management.jmx.MBeanServerImpl; - import javax.management.MBeanAttributeInfo; - import javax.management.MBeanInfo; - import javax.management.MBeanOperationInfo; - import javax.management.MBeanServer; - import javax.management.Notification; - import javax.management.NotificationFilter; - import javax.management.NotificationListener; - import javax.management.ObjectInstance; - import javax.management.ObjectName; - import javax.management.ReflectionException; - import javax.management.RuntimeErrorException; - import javax.management.RuntimeMBeanException; - import javax.management.RuntimeOperationsException; - import javax.naming.InitialContext; - import org.jboss.jmx.interfaces.JMXConnector; - import org.jboss.jmx.client.RMIClientConnectorImpl; </programlisting> - </para> - </listitem> - - <listitem> - <para> Instantiate a local MBeanServer (MBeanServerImpl) - - <programlisting> final MBeanServer lLocalServer = new MBeanServerImpl(); </programlisting> The local variable is made final because it is needed in the shutdown hook. - </para> - </listitem> - - <listitem> - <para> Load the logger MBean (is needed now because the Connector Factory - is a standard JBoss MBean but maybe I should make it to a normal - MBean to make it leaner). - - <programlisting> lLocalServer.createMBean( "org.jboss.logging.Logger", new - ObjectName( "DefaultDomain :name=Logger" ) ); </programlisting> - </para> - </listitem> - <listitem> - <para> Load and start the ConnectorFactory MBean - - <programlisting> final ObjectInstance lFactoryInstance = - lLocalServer.createMBean( - "org.jboss.jmx.client.ConnectorFactoryService", new - ObjectName( "DefaultDomain:name=ConnectorFactory" ) );</programlisting> - </para> - </listitem> - <listitem> - <para> - Look for the list of servers (if a null is passed as parameter this - method returns all the servers at the given JNDI server) - - <programlisting> Collection lServers = (Collection) lLocalServer.invoke( - lFactoryInstance.getObjectName(), "getServers", new - String[] {null}, new String[] {"java.lang.String"} );</programlisting> and within a server for the list of protocols (if a null or empty string is passed then all protocols at - the given JNDI server will be listed) - - <programlisting> Collection lProtocols = (Collection) lLocalServer.invoke( - lFactoryInstance.getObjectName(), "getProtocols", new - String[] {lServer}, new String[] {"java.lang.String"} ); </programlisting> - </para> - </listitem> - <listitem> - <para> Create a connection to the selected Connector - - <programlisting> - JMXConnector lConnector = (JMXConnector)lLocalServer.invoke( - lFactoryInstance.getObjectName(),"createConnection", new Object[] - {lServer,lProtocol}, new String[] {"java.lang.String","java.lang.String"); - - </programlisting> - - - </para> - </listitem> - <listitem> - <para> Use the new Connector MBean on the local MBeanServer to get and set the attributes and perform - operation on the chosen MBeans on the remote MBeanServer. - - <programlisting> Iterator i = pConnector.queryMBeans( null, null).iterator(); - while( i.hasNext() ) { - MBeanInfo info = pConnector.getMBeanInfo( ( (ObjectInstance) i.next()).getObjectName() ); - MBeanAttributeInfo[] aInfos = info.getAttributes(); - . - . - . MBeanOperationInfo[] oInfos = info.getOperations(); - }</programlisting> - </para> - </listitem> - <listitem> - <para> Register a Notification Listener on a remote MBean and wait for notification events sent from the - remote MBean. - - <programlisting> Iterator i = pConnector.queryMBeans( null, nullitemizedlist).iterator(); - int j = 0; - while( i.hasNext() ) { - ObjectInstance lBean = (ObjectInstance) i.next(); - try { - pConnector.addNotificationListener( lBean.getObjectName(), - (NotificationListener) new Listener(),(NotificationFilter) null, - new NotSerializableHandback(lBean.getObjectName() + "" + j++ ) - ); ... </programlisting> But when you terminate the connector you have to remove the connection by using the Connector - Factory to remove all the Notification Listener from the remote MBeanServer. - - <programlisting> lLocalServer.invoke( lFactoryInstance.getObjectName(), - "removeConnection", new Object[] {lServer,lProtocol}, new - String[] {"java.lang.String","java.lang.String"} );</programlisting> - </para> - </listitem> - </orderedlist> - - </section> - - </section> - - <section> - <title>ToDo List</title> - <para>This list contains all the stuff to be done to make the JMX Connector full - fledged: - <itemizedlist> - <listitem> - <para>Implement the server lookup in the Connector Factory to work with JNDI</para> - </listitem> - - <listitem> - <para>Implement the protocol lookup in the Connector Factory to work with JNDI</para> - </listitem> - - <listitem> - <para>Test all to make sure that it works from any other JVM that the JBoss VM </para> - </listitem> - - </itemizedlist> - </para> - <para> This list contains all the stuff to be done around JMX + JMXConnector lConnector = new RMIClientConnectorImpl("server-name" ); + </programlisting> + </para> + </listitem> + <listitem> + <para> + Use either instance or its interface JMXConnector or MBeanServer. If you got back an + instance you can now work on the remote MBeanServer like it would be a local one. + </para> + </listitem> + <listitem> + <para> + Look up for the available MBeans, its attributes and operations. You can now retrieve + and set the attributes or perform an operation on the remote MBean. + </para> + </listitem> + <listitem> + <para> + If you register a Notification Listener then stop this instance before terminating the + program otherwise the remote MBeanServer will throw an exception when this Notification + Listener is called lConnector.stop(); + </para> + </listitem> + </orderedlist> + </para> + </section> + <section> + <title>How to create a client without the server and protocol/H3> </title> + <para> + First you have to make sure that the JNDI property: + java.naming.provider.url points to the JNDI server your JMX Connectors + are registered to. At the moment you can only have one JMX Connector + running at the same computer (but serveral can be registered at the same + JNDI server) and you can only have one JNDI server. + </para> + <orderedlist> + <listitem> + <para> + Import the necessary classes + <programlisting> + import com.sun.management.jmx.MBeanServerImpl; + import javax.management.MBeanAttributeInfo; + import javax.management.MBeanInfo; + import javax.management.MBeanOperationInfo; + import javax.management.MBeanServer; + import javax.management.Notification; + import javax.management.NotificationFilter; + import javax.management.NotificationListener; + import javax.management.ObjectInstance; + import javax.management.ObjectName; + import javax.management.ReflectionException; + import javax.management.RuntimeErrorException; + import javax.management.RuntimeMBeanException; + import javax.management.RuntimeOperationsException; + import javax.naming.InitialContext; + import org.jboss.jmx.interfaces.JMXConnector; + import org.jboss.jmx.client.RMIClientConnectorImpl; + </programlisting> + </para> + </listitem> + <listitem> + <para> + Instantiate a local MBeanServer (MBeanServerImpl) + <programlisting> + final MBeanServer lLocalServer = new MBeanServerImpl(); + </programlisting> + The local variable is made final because it is needed in the shutdown hook. + </para> + </listitem> + <listitem> + <para> + Load the logger MBean (is needed now because the Connector Factory + is a standard JBoss MBean but maybe I should make it to a normal + MBean to make it leaner). + <programlisting> + lLocalServer.createMBean( + "org.jboss.logging.Logger", + new ObjectName( "DefaultDomain :name=Logger" ) + ); + </programlisting> + </para> + </listitem> + <listitem> + <para> + Load and start the ConnectorFactory MBean + <programlisting> + final ObjectInstance lFactoryInstance = lLocalServer.createMBean( + "org.jboss.jmx.client.ConnectorFactoryService", + new ObjectName( "DefaultDomain:name=ConnectorFactory" ) + ); + </programlisting> + </para> + </listitem> + <listitem> + <para> + Look for the list of remote Connectors at a given JNDI server (lContext.getEnvironment() + returns the actual properties from a given InitialContext). + <programlisting> + Hashtable lProperties = lContext.getEnvironment(); + ConnectorFactoryImpl.JBossConnectorTester lTester = new ConnectorFactoryImpl.JBossConnectorTester(); + Iterator lConnectors = (Iterator) lLocalServer.invoke( + lFactoryInstance.getObjectName(), + "getConnectors", + new Object[] { + lProperties, + lTester + }, + new String[] { + lProperties.getClass().getName(), + lTester.getClass().getName() + } + ); + </programlisting> + </para> + </listitem> + <listitem> + <para> + Create a connection to the selected Connector (lConnectorName is an instance returned + by the previous retrieved iterator). The ConnectorName contains the information about + the server, protocol and the JNDI name of a found JMX Connector. + <programlisting> + JMXConnector lConnector = (JMXConnector) lLocalServer.invoke( + lFactoryInstance.getObjectName(), + "createConnection", + new Object[] { + lConnectorName + }, + new String[] { + lConnectorName.getClass().getName() + } + ); + </programlisting> + </para> + </listitem> + <listitem> + <para> + Use the new Connector MBean on the local MBeanServer to get and set the attributes and + perform operation on the chosen MBeans on the remote MBeanServer. + <programlisting> + Iterator i = pConnector.queryMBeans( null, null).iterator(); + while( i.hasNext() ) { + MBeanInfo info = pConnector.getMBeanInfo( ( (ObjectInstance) i.next()).getObjectName() ); + MBeanAttributeInfo[] aInfos = info.getAttributes(); + ... + MBeanOperationInfo[] oInfos = info.getOperations(); + } + </programlisting> + </para> + </listitem> + <listitem> + <para> + Register a Notification Listener on a remote MBean and wait for notification events sent + from the remote MBean. The NotSerializableHandback is a helper class to be a serializable + proxy for a Handback which maybe is not serializable. + <programlisting> + Iterator i = pConnector.queryMBeans( null, nullitemizedlist).iterator(); + int j = 0; + while( i.hasNext() ) { + ObjectInstance lBean = (ObjectInstance) i.next(); + try { + pConnector.addNotificationListener( + lBean.getObjectName(), + (NotificationListener) new Listener(), + (NotificationFilter) null, + new NotSerializableHandback( lBean.getObjectName() + "" + j++ ) + ); ... + </programlisting> + But when you terminate the connector you have to remove the connection by using the + Connector Factory to remove all the Notification Listener from the remote MBeanServer. + <programlisting> + lLocalServer.invoke( lFactoryInstance.getObjectName(), + "removeConnection", + new Object[] { + lConnectorName + }, + new String[] { + lConnectorName.getClass().getName() + } + ); + </programlisting> + </para> + </listitem> + </orderedlist> + </section> + <section> + <title>ToDo List</title> + <para> + This list contains all the stuff to be done to make the JMX Connector full + fledged: + <itemizedlist> + <listitem> + <para>Test all to make sure that it works from any other JVM that the JBoss VM </para> + </listitem> + </itemizedlist> + </para> + <para> + This list contains all the stuff to be done around JMX <itemizedlist> - <listitem> - <para>Initiate and start full fledged JMX Agent project</para> - </listitem> - - - <listitem> - <para>Design and implement Relation Service for the JMX Agent</para> - </listitem> - - <listitem> - <para>Design and implement graphic management tool for JBoss</para> - </listitem> - - </itemizedlist> - </para> - - <para> If anything is wrong or not correct please contact me at - [EMAIL PROTECTED] Also if you want to know more in detail - or have a request for changes in the JMX Connector. + <listitem> + <para>Initiate and start full fledged JMX Agent project</para> + </listitem> + <listitem> + <para>Design and implement Relation Service for the JMX Agent</para> + </listitem> + <listitem> + <para>Design and implement graphic management tool for JBoss</para> + </listitem> + </itemizedlist> + </para> + <para> + If anything is wrong or not correct please contact me at + [EMAIL PROTECTED] Also if you want to know more in detail + or have a request for changes in the JMX Connector. </para> - </section> -</section> \ No newline at end of file + </section> +</section> _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development