MBean in JBoss AS 3.2.7
aflopes Dec 28, 2010 11:50 AMHi all,
I'm working on an application that is deployed in a JBoss AS 3.2.7 for almost 4 years in a production environment. This application have a MBean that is configured in the deploy/user-service.xml file:
<mbean code="com.company.mbean.AppInit" name=":service=AppInit"></mbean>
The classes of this MBean are in a jar file located in the lib folder and are the following:
Interface AppInitMBean:
package com.company.mbean;
public interface AppInitMBean {
public abstract void init() throws Exception;
public abstract void start() throws Exception;
public abstract void stop() throws Exception;
public abstract void destroy() throws Exception;
public abstract void printSessions();
}
Class AppInit:
package com.company.mbean;
import javax.management.MBeanRegistration;
public class AppInit implements MBeanRegistration, AppInitMBean{
/* @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer, javax.management.ObjectName) */
public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception {
return new ObjectName(":service=AppInit");
}
/* @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)*/
public void postRegister(java.lang.Boolean registrationDone) {}
/* @see javax.management.MBeanRegistration#preDeregister()*/
public void preDeregister() throws java.lang.Exception { }
/* @see javax.management.MBeanRegistration#postDeregister()*/
public void postDeregister() {}
public void init() throws Exception {...}
public void start() throws Exception {...}
public void stop() throws Exception {...}
public void destroy() throws Exception {/*do nothing*/}
public void printSessions(){...}
}
With this settings the method start() is invoked when the JBoss starts, but now i want to make a new MBean that depends on a class that is initialized in the described MBean. I've tried to make it similar to the AppInit MBean, but the start method is never invoked.
Why JBoss invoke the start method for one MBean and not for the other? The differences between them is their name and the jar file that contains the respective classes. The configuration of the new one is:
<mbean code="com.company.control.Control" name=":service=Control"></mbean>
Did i miss some configuration?
I know the structure and configuration of this MBeans is probably not the best one (didn't find any thing on the net saying to do things this way) but is the one i have, and i will have to live with it (unfortunately).