1 Reply Latest reply on Feb 18, 2002 11:59 PM by David Jencks

    Getting Ref to MBean

    Greg Turner Apprentice

      I am making my first stab at writing an MBean for JBoss. I want my MBean to not have any JBoss specific code. The example (JNDIMapMBean) in the docs of how to write such an MBean does not meet the requirement that the MBean contain no JBoss specific code because it does reference org.jboss.naming.NonSerializableFactory. If I remove that part of the code, then how does the MBean get registered with the Jndi? Is there any other way to register an MBean with the JBoss Jndi? I suppose I could write another MBean that does contain JBoss specific code that knows how to register my MBean with the Jndi. Alternatively, is there any way to get hold of my MBean without registering it with Jndi? I see in past postings that casting from server.getObjectInstance() does not work. My object that is an MBean will contain methods that are not exposed by the MBean interface, so I do need to get a reference and cast as I see fit. Any help would be appreciated. Thanks so much.

        • 1. Re: Getting Ref to MBean
          David Jencks Master

          Mbeans don't need to have any relationship with jndi whatsoever. However, if you need to avoid exposing some of your methods as managed operations or attributes, you will have to find some way of locating the instance. Jndi is certainly one way, and you are free to write your own ObjectFactory to bind your mbean.

          Another approach is to include a getMySelf managed attribute that returns the mbean instance itself. Then you can fetch the instance through jmx.

          A third approach is to rethink "management" and decide to expose all the methods you want "public" as managed attributes and operations.