[jboss-dev-forums] [Design of POJO Server] - Re: JBAS-5578 ServiceMBeanSupport as MC bean
adrian@jboss.org
do-not-reply at jboss.com
Wed Jun 4 08:44:53 EDT 2008
Never mind, I think I figured out what the problem is.
The issue occurs when you register a ServiceMBeanSupport MBean using registerDirect=true on the JMX annotation.
The callstack then goes something like:
MC - > ServiceMBeanSupport.create() -> ServiceController.create()
ServiceController.create() then ignores the request because it thinks it is a call
on the JMX lifecycle, i.e. a duplicate
I fixed this problem by introducing POJO lifecycle events in ServiceMBeanSupport
so we can differentiate the two.
| @Create
| public void pojoCreate() throws Exception
| {
| jbossInternalCreate();
| }
|
This brings up to other issues. The first of which I fixed which is related
to the confusion when JMX and POJO lifecycles.
If you invoke a lifecycle operation on the JMX console (or any MBeanServer operation)
then it should be redirected to the MC for a POJO not the ServiceController.
The JMX part is just a wrapper.
Since we now have the seperate pojoXXX methods, this is easy to spot,
so ServiceMBeanSupport now does the redirection, e.g.
| public class ServiceMBeanSupport
| extends JBossNotificationBroadcasterSupport
| implements ServiceMBean, MBeanRegistration,
|
| // Implement this interface so we know the true name not the JMX wrapper
| // when we are registered as a POJO
| KernelControllerContextAware
|
| public void setKernelControllerContext(KernelControllerContext controllerContext) throws Exception
| {
| this.controllerContext = controllerContext;
| }
|
| public void unsetKernelControllerContext(KernelControllerContext controllerContext) throws Exception
| {
| this.controllerContext = null;
| }
|
| // Redirect JMX invocations to the real MC context, e.g.
|
| public void create() throws Exception
| {
| if (controllerContext != null)
| pojoChange(ControllerState.CREATE);
| else if (serviceName != null && isJBossInternalLifecycleExposed)
| server.invoke(ServiceController.OBJECT_NAME, "create", new Object[] { serviceName }, SERVICE_CONTROLLER_SIG);
| else
| jbossInternalCreate();
| }
|
The second issue is the use of StandardMBean in the @JMX handling.
The problem is that this masks any implemention of MBeanRegistration
or NotificationEmitter.
This is probably not a real issue since you can always use
registerDirectly=true on the @JMX annotation
to expose those contracts.
You're pretty certain its going to be a real mbean if you implements them.
A more general fix would to use of an extension of StandardMBean
that delegates those interface implementations to underlying pojo
if it implements them.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4155661#4155661
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4155661
More information about the jboss-dev-forums
mailing list