This content has been marked as final.
Show 3 replies
-
1. Re: Generate MBeanInfo from arbitrary interface
adrian.brock Feb 9, 2005 5:45 PM (in response to kabirkhan)If you don't want to follow StandardMBean semantics
cf. javax.management.StandardMBean rather than StandardMetadata
you have to use a DynamicMBean or ModelMBean (which is what Bill's says
http://jira.jboss.com/jira/browse/EJBTHREE-65)
Something like the StandardMBean implementation could be used as
a starting point for generating MBeanInfo from annotations rather than an interface.
ModelMBean approach:RequiredModelMBean rmm = new RequiredModelMBean(); rmm.setResource(object); rmm.setModelMBeanInfo(generatedFromAnnotations()); mbeanServer.registerMBean(rmm, objectName);
I have my reservations about the approach depending upon what you are
trying to achieve.
1) If this is @Service you are essentially defining an EJB singleton which is ok.
2) It does not make sense to me to define management on normal ejb instances.
EJB instances have a fleeting existance so registering them with the MBeanServer
is ludricous. Also, imagine creating an MBean for every row in the database.
3) Why would you define a management interface that is not implemented
by the management singleton? It seems overly complex to use annotations
when it could just the StandardMBean semantic.
If you weren't allowing access through an interface, the annotations would
make more sense (the usual detyped jmx access through the console).
4) If all you want to do is avoid the XXXMBean rule,
javax.management.StandardMBean allows you to override the interface exposed.
The only requirement is that the object implements the interface. -
2. Re: Generate MBeanInfo from arbitrary interface
adrian.brock Feb 9, 2005 6:11 PM (in response to kabirkhan)I should also note, that it is on the roadmap to be able to define
an MBean using annotations for the JMX2.0 spec. -
3. Re: Generate MBeanInfo from arbitrary interface
kabirkhan Feb 10, 2005 11:50 AM (in response to kabirkhan)1) and 2) It is for a singleton instance, i.e. the @Service bean type
3) The management interface is implemented by the singleton, it just does not need to follow the standard mbean naming convention. So instead ofpublic class SomeClass implements SomeClassMBean { }
we have@Service public class SomeClass implements AnInterface { } @Management public interface AnInterface { }
4) Thanks, I'll give that a go