Chapter 12. Agent Implementation

An Agent is the Local JMX Application that instantiates and manages the MBeanServer.

There are several things that an Agent should do, and lots of stuff that it may do.

Essential Agent responsibilities

Instantiate an MBeanserver
    mBeanServer = MBeanServerFactory.createMBeanServer();
Instantiate some MBeans and load them into the MBeanServer like
    mBeanServer.registerMBean(this, new ObjectName(
    "Jamama:type=JamamaJMXAgent"));

AND/OR

    mBeanServerConnection.createMBean("tst.SampleStd", new ObjectName("a:b=c"));

Some of these MBeans may be Protocol Adaptors. You could also use an MLet file to load MBeans (or implementation-specific load-by-config-file methods). See the API for MLet.

Load and initialize Connector(s)
    (JMXConnectorServerFactory.newJMXConnectorServer(url,
            new JMXServiceURL("service:jmx:jmxmp://localhost:2004"),
            mBeanServer)).start();

(As noted in the Distributed Services and Connectors chapter, if you use an rmi service instead of jmxmp, you will need to run an rmiregistry server in order for clients to be able to access your ConnectorServer).

See the Distributed Services and Connectors chapter for an example of a flexible Agent which you can use as the basis for your own Agent.