1 Reply Latest reply on Dec 20, 2007 6:56 AM by alesj

    @ManagementRuntimeRef/@ManagementObjectRef/@ManagementObject

    starksm64

      We need to clarify the usage of the names in the ManagedObject graphs for the purposes of references between related ManagedObjects and references to the underlying runtime component. The current mechanism for naming a ManagedObject is based on the

      @ManagementObjectID - annotation that identifies a ManagedObject key/type qualifier source. Generally this is on a property without a name value so that the actual name comes from the property value, as this JBossManagedConnectionPool example shows:

       @ManagementObjectID(type="DataSource")
       @ManagementProperty(use={ViewUse.RUNTIME})
       public String getPoolJndiName()
       {
       return this.poolJndiName;
       }
      

      @ManagementObjectRef - indicates a property that references another ManagedObject. This ManagedConnectionFactoryDeploymentMetaData example shows a property refencing the jmx invoker ManagedObject:
       @ManagementProperty(name="jmx-invoker-name")
       @ManagementObjectRef(type="JMXInvoker")
       public String getJmxInvokerName()
       {
       return jmxInvokerName;
       }
      

      @ManagementRuntimeRef - annotation that can be used to identify which property defines the runtime component name. This annotation takes a transformer:
      public interface RuntimeComponentNameTransformer
      {
       /**
       * Transform the name from string.
       *
       * @param value current name value
       * @return transformed name
       */
       Object transform(Object value);
      }
      

      this is used to identify what the name of the runtime kernel component is. For an mcf deployment, this should be doing the same mapping logic the ManagedConnectionFactoryBuilder.buildObjectName method does in transforming the jndiName property into an ObjectName:
       public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
       {
       return ObjectNameFactory.create(MCF_JMX + md.getJndiName());
       }
      



        • 1. Re: @ManagementRuntimeRef/@ManagementObjectRef/@ManagementOb
          alesj

           

          "scott.stark@jboss.org" wrote:

          @ManagementRuntimeRef - annotation that can be used to identify which property defines the runtime component name. This annotation takes a transformer:
          public interface RuntimeComponentNameTransformer
          {
           /**
           * Transform the name from string.
           *
           * @param value current name value
           * @return transformed name
           */
           Object transform(Object value);
          }
          

          this is used to identify what the name of the runtime kernel component is.


          We are checking each object for this annotation - see AbstractManagedObjectFactory:
           ManagementRuntimeRef runtimeRef = (ManagementRuntimeRef) annotations.get(ManagementRuntimeRef.class.getName());
           if (runtimeRef != null)
           {
           componentName = icf.getComponentName(beanInfo, property, object, value);
           // let's try this as well
           if (componentName == null && icf != this)
           componentName = getComponentName(beanInfo, property, object, value);
           }
           }
           }
           if (componentName == null)
           componentName = icf.getComponentName(null, null, object, null);
          

          We check each property, first with object's specific InstanceClassFactor, then with AMOF.
          AMOF is transformer aware:
           public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
           {
           if (beanInfo != null && property != null && value != null)
           {
           String name = getPropertyName(property);
           PropertyInfo propertyInfo = beanInfo.getProperty(name);
          
           ManagementRuntimeRef componentRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class);
           if (componentRef != null)
           {
           Object original = metaValueFactory.unwrap(value, propertyInfo.getType());
           try
           {
           Class<? extends RuntimeComponentNameTransformer> tClass = componentRef.transformer();
           RuntimeComponentNameTransformer transformer;
           if (tClass != ManagementRuntimeRef.DEFAULT_NAME_TRANSFORMER.class)
           transformer = getComponentNameTransformer(configuration.getTypeInfo(tClass));
           else
           transformer = getComponentNameTransformer(propertyInfo.getType());
          
           return (transformer != null) ? transformer.transform(original) : original;
           }
           catch (Throwable t)
           {
           throw new UndeclaredThrowableException(t);
           }
           }
           }
           return null;
           }
          

          The idea here is to provide KernelBus with the real runtime component name. e.g. in the case of MBeans, it's ObjectName.canonicalForm.

          Currently we know how to get the runtime component name from BeanMetaData (getName) and ServiceMetaData (getCanonicalForm).