From: <sco...@jb...> - 2006-05-25 18:42:34
|
And now I'm down to not seeing any benefit to the ManagedObject being an annotation at all. The reason being that aggregate/structured annotations are just difficult to deal with unless they are well known. Instead I now just have it as a pojo with a mapping of the bean properties that make up the managment interface. One version is a direct mapping: | public class ManagedObject | { | private ArrayList<PropertyInfo> properties = new ArrayList<PropertyInfo>(); | | public List<PropertyInfo> getProperties() | { | return properties; | } | | public boolean addPropertyRef(PropertyInfo ref) | { | return properties.add(ref); | } | public boolean removePropertyRef(PropertyInfo ref) | { | return properties.remove(ref); | } | public int getSize() | { | return properties.size(); | } | public void clear() | { | properties.clear(); | } | } | | Another version maintains a layer of indirection that allows for the management view via ManagedPropertyRef pojos: | public class ManagedObject | { | private ArrayList<ManagedPropertyRef> properties = new ArrayList<ManagedPropertyRef>(); | | public List<ManagedPropertyRef> getProperties() | { | return properties; | } | | public boolean addPropertyRef(ManagedPropertyRef ref) | { | return properties.add(ref); | } | public boolean removePropertyRef(ManagedPropertyRef ref) | { | return properties.remove(ref); | } | public int getSize() | { | return properties.size(); | } | public void clear() | { | properties.clear(); | } | } | | public class ManagedPropertyRef | { | /** | * A namespace context that maps the managed property onto a managed view | * context (e.g., /, /DataSource, /DataSource/Pool). | */ | private String context; | /** | * The DeploymentBean name which sources the property | * @return | */ | private String beanName; | /** | * The DeploymentBean property name | */ | private String propertyName; | /** | * An option management view description of the property | */ | private String description; | | /** | * Create a managed property ref for the indicated bean property. | * @param context | * @param beanName | * @param propertyName | * @param description | */ | public ManagedPropertyRef(String context, String beanName, | String propertyName, String description) | { | this.context = context; | this.beanName = beanName; | this.propertyName = propertyName; | this.description = description; | } | | /** | * @return Returns the beanName. | */ | public String getBeanName() | { | return this.beanName; | } | | /** | * @return Returns the context. | */ | public String getContext() | { | return this.context; | } | | /** | * @return Returns the description. | */ | public String getDescription() | { | return this.description; | } | | /** | * @return Returns the propertyName. | */ | public String getPropertyName() | { | return this.propertyName; | } | | /** | * Equality based on beanName + propertyName | */ | public boolean equals(Object obj) | { | ManagedPropertyRef ref = (ManagedPropertyRef) obj; | boolean equals = beanName.equals(ref.beanName); | if( equals ) | { | equals = propertyName.equals(ref.propertyName); | } | return equals; | } | | /** | * Hash based on beanName + propertyName | */ | public int hashCode() | { | return beanName.hashCode() + propertyName.hashCode(); | } | } | | Both of these could be built from the DeploymentBean PropertyInfo objects if they were marked up with a ManagedProperty annotation that provided the additional management view context. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3946612#3946612 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3946612 |