Last updated April 17, 2009 17:36, by Peter Mount
Feedicon  

JMX

The kernel provides a means of deploying beans into the JMX MBeanServer instance running within the JVM. This is usually used to allow a bean to be managed via some JMX Console or with the optional WebManager plugin.

Deploying a JMX Management Bean

Any bean thats deployed by the kernel will be deployed in the MBeanServer if it's a valid management bean. That is if it:

  • implements a valid MBean interface
  • implements a valid MXBean interface
  • is annotated with the javax.management.MXBean annotation

If a bean matches one of the above criteria, the kernel will automatically deploy the object into the MBeanServer.

JMX ObjectName

When deploying a JMX Management Bean, the bean needs an ObjectName. This can be provided by the @ObjectName annotation or if that annotation is not present based on it's bean name.

Here we have a simple management bean thats deployed withing the MBeanServer with the ObjectName my.app:id=main

import uk.org.retep.kernel.annotations.Bean;
import uk.org.retep.kernel.annotations.ObjectName;

@ObjectName( "my.app:id=main" )
@Bean( name = "myApp", lazyInit = false )
public class App
        implements AppMBean
{

    private String myAppName;

    public String getMyAppName()
    {
        return myAppName;
    }
}

public interface AppMBean
{
    String getMyAppName();
}

If the @ObjectName annotation is not present the kernel will try to form an ObjectName based on the name in the @Bean definition. If that name has a : in it then the name is treated as a full ObjectName otherwise the name used will have retep.kernel.beans:id= prefixed to the beans name.

In either case if the ObjectName is invalid then a FatalBeanException is thrown, logged and the application will stop.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close