users@glassfish.java.net

Re: Support for JMX?

From: <glassfish_at_javadesktop.org>
Date: Mon, 02 Aug 2010 12:17:24 PDT

Bad Form to respond to self - but I finally managed to use one of the new singleton annotaions to register a pojo annotated with @MxBean. In this case a trivial class for managing log 4j levels. Better suggestions are welcome ;)

It shows up along with all the standard GF items in JConsolee.


@Singleton
@Startup
public class InitBean {
        final static Logger logger = Logger.getLogger(InitBean.class);

        @PostConstruct
        public void initializeSomeStuff() {
                logger.info("\n*** Singleton EJB ***\n");

                try {
                        Log4jJmx myLogConfig = new Log4jJmx();
                        ManagementFactory.getPlatformMBeanServer().registerMBean(myLogConfig, new ObjectName("com.peter:name=hey")) ;
// ManagementFactory.getPlatformMBeanServer().createMBean(
// Log4jJmx.class.getName(),
// new ObjectName("com.peter:name=hey"));
                } catch (Exception e) {
                        logger.error("Factory Already created? ", e);
                }

        }
[Message sent by forum member 'peterdnight']

http://forums.java.net/jive/thread.jspa?messageID=479150