This content has been marked as final.
Show 1 reply
-
1. Re: @ManagementRuntimeRef/@ManagementObjectRef/@ManagementOb
alesj Dec 20, 2007 6:56 AM (in response to starksm64)"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).