4 Replies Latest reply on May 7, 2004 5:17 AM by aseembansal

    Mbean dependency resolution

    aseembansal

      Hi,

      I am looking for a way in which my mbean can retieve its dependent objects.

      It seems that in the xml, I can specify my dependencies and container passes
      that objectname (via a setter) in my Mbean. From there how can my mbean
      retrieve the dependent object instance without using dynamic proxy.

      -A

        • 1. Re: Mbean dependency resolution
          raja05

          Have a optional-attribute-name attribute for ur depends clause, something like

          <depends optional-attribute-name="dependBean">objectname</depends>
          


          And create a setter and getter for dependBean
          private ObjectName dependObjName;
          public ObjectName getDependBean() {
           return this.dependBean;
          }
          
          and then use it as
           <Depend>MBean obj = (<depend>MBean) getServer().getAttribute(this.dependBean);
          
          
          


          Check out jboss-service.xml for similar examples



          • 2. Re: Mbean dependency resolution
            aseembansal

            Thanks for the reply.

            Is this the only way to resolve the dependencies? In this case, a service has to expose getter/setter methods just to resolve the dependencies of dependents.

            Is not there any componentRegistry in JBoss which maintains a mapping of objectName Vs objects.

            -Aseem

            • 3. Re: Mbean dependency resolution
              raja05

              Ofcourse there is, the MBeanRegistry implementation in jboss does have this. getServer().getAttribute(this.dependBean); is going to take this value from the Registry and return the MBean associated with the object name,

              • 4. Re: Mbean dependency resolution
                aseembansal

                Thanks. That was what I was looking for.

                -Aseem