[jboss-dev-forums] [Design of POJO Server] - Re: @ManagementRuntimeRef/@ManagementObjectRef/@ManagementOb
alesj
do-not-reply at jboss.com
Thu Dec 20 06:56:47 EST 2007
"scott.stark at 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).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114600#4114600
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114600
More information about the jboss-dev-forums
mailing list