3 Replies Latest reply on Aug 30, 2007 11:37 AM by starksm64

    InstanceClassFactory extension to the ManagedObjectFactory

    starksm64

      In order to deal with wrapping metadata instances like the ServiceMetaData class, I need to add an InstanceClassFactory plugin to the ManagedObjectFactory. This allows for the management annotations to be on the underlying mbean instance:

      public interface InstanceClassFactory
      {
       /**
       * Return the Class that represents the root ManagedObject to scan
       * for management object related annotations.
       *
       * @param instance - the instance a ManagedObject is to be created for.
       * @return the Class that represents the root ManagedObject.
       */
       public Class<? extends Serializable> getManagedObjectClass(Serializable instance);
      }
      


      This allows one to mark up the instance the mbean service wraps. The alternative would be to assume the ServiceMetaData jmx representation is the ManagedObject. I don't think that is generally the case as the interfaces were more a description of the bean service rather than the management interface.


        • 1. Re: InstanceClassFactory extension to the ManagedObjectFacto
          starksm64

          For this to work, InstanceClassFactory also needs a:

           public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable object);
          

          method to be able to populate the ManagedProperty values from the metadata. Since the mbean instance does not exist this needs to be take from ServiceMetaData object.


          • 2. Re: InstanceClassFactory extension to the ManagedObjectFacto

            I understand why you've done this.
            I think this is ok for now.

            But for MBeans I thought we would do something more generic
            with the ManagedObject coming from a mapping of the MBean description (MBeanInfo/descriptors)

            To make this useful, the MBean description would be generated using
            annotations like the ManagedObject stuff (in fact the annotations that
            will appear in JMX2.0/Java7 + our extensions).
            This is related to this:
            http://jira.jboss.com/jira/browse/JBMICROCONT-71

            • 3. Re: InstanceClassFactory extension to the ManagedObjectFacto
              starksm64

              I thought about just adding more annotation support to the service mbean metadata, but that is more error prone for a deployer writer who is programatically creating the mbean metadata. It would not be a big deal for those still using the legacy service.xml.

              In terms of the InstanceClassFactory being part of the spi, maybe this should be pushed to the AbstractManagedObjectFactory as an implementation detail for this release.