The content of this guide is the following:
This chapter is intended for advanced JOnAS users who are interested in understanding management facilities that JOnAS provides, and possibly extending these facilities for their application needs.
JOnAS management facilities are based on Management Beans (MBeans) compliant to JMX Specification. Moreover, JOnAS implements JSR 77 specification, which defines the management model for J2EE platforms.
MBeans provide access to management functions such as configuration, deployment/undeployment, monitoring of resources and application modules.
MBeans are created not only by the different JOnAS services, but also by the components integrated in JOnAS (Web server Tomcat or Jetty, JORAM MOM, etc.). They are registered in the current MBean Server, which is started by each JOnAS server instance. Remote access to the MBean Server is facilitated by JMX remote connectors compliant to the JSR 160 specification. See more information about connectors here.
JonasAdmin application implements the management functions listed above using the different MBeans registered in the MBeanServer of the JOnAS instance currently being managed. This is usually the server on which JonasAdmin is deployed, but it may be another server running in the same management domain.
JonasAdmin also presents, in a structured way, all the registered MBeans, their attributes and operations. In the future, JonasAdmin will probably be extended to allow setting attributes and invoking operations.
In order to invoke a management operation on a MBean, the caller must access to the MBean server.
When the caller is located in the same JVM as the MBean Server, it can use
javax.management.MBeanServerFactory
class to obtain a reference
to the MBean Server:
List mbeanServers = MBeanServerFactory.findMBeanServer(null); if (mbeanServers != null && mbeanServers.size() > 0) { return (MBeanServer) mbeanServers.get(0); }
When the caller is remote, it can use a JMX remote connector to establish
a connection with the MBean Server and obtain a
javax.management.MBeanServerConnection
object.
Suppose that the connector server has the following address:
service:jmx:jrmp://host/jndi/jrmp://host:1099/jrmpconnector_jonas
,
which is the default for a JOnAS server called jonas
.
JMXServiceURL connURL = new JMXServiceURL("service:jmx:jrmp://host/jndi/jrmp://host:1099/jrmpconnector_jonas"); JMXConnector connector = JMXConnectorFactory.newJMXConnector(connURL, null); connector.connect(null); MBeanServerConnection conn = connector.getMBeanServerConnection(); return conn;
A remote caller can also use the MEJB provided by the JOnAS distribution.
A Management EJB implementation, compliant to the JSR 77, is packed in the
mejb.ear
installed in the
JONAS_ROOT/ejbjars/autoload
directory. Thus, the MEJB is
automatically deployed at JOnAS start-up. Its Home
is registered
in JNDI under the name ejb/mgmt/MEJB
. JOnAS distribution also
contains an example using the MEJB in a J2EE application, the
j2eemanagement
sample.
A remote caller can use the Management Web Service endpoint packaged
as a part of the mejb.ear
installed in the
JONAS_ROOT/ejbjars/autoload
directory. Thus, the management
endpoint is automatically deployed at JOnAS start-up. Check
http://<hostname>:<port>/mejb/ManagementEndpoint/ManagementEndpoint?wsdl
for the WSDL file on a running JOnAS instance. The endpoint allows light-weight
clients to query JOnAS MBeans from virtually any platform by leveraging the
platform-independant nature of Web Services.
Application MBeans can be created and registered in the MBean server by
calling registerMBean
method on the MBeanServer
object or createMBean
method on the
MBeanServerConnection
object. Also, MBeans can be loaded using
the m-let service, a dynamic loading mechanism provided by the JMX
implementation. This mechanism allows loading MBeans from a remote URL. The
information on the MBeans to load is provided in a m-let text file. Refer to
JMX implementation documentation for details concerning this file. In addition,
the howto document
JOnAS and JMX, registering and manipulating MBeans
illustrates the use of this m-let mechanism. In order
to make an m-let text file accessible to JOnAS applications, it can be installed
in the JONAS_ROOT/conf
directory.