tonva / pojo-mbean

Automatically exported from code.google.com/p/pojo-mbean
0 stars 0 forks source link

Change the annotation structure (multiple @Attribute annotations and separate @Description) #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, one and only one of...
- Field
- Getter method
- Setter method
... should be annotated with @ManagedAttribute, and the access level may be 
defined using @ManagedAttribute(access=Access.READ_WRITE)

So you could see a setter method annotated with @ManagedAttribute which would 
in fact make the related field available for READ only, since Access.READ is 
the default access.

A couple of suggestions:

If a method is annotated with @ManagedAttribute, that method is made available 
(e.g. if only the setter method has the annotation the attribute would be WRITE 
only. This would require default access to be "IMPLIED" or "CONTEXT". And it 
would be considered an error, if a @ManagedAttribute annotated method would 
have any explicit READ/WRITE/READ_WRITE access. These would be reserved for 
@ManagedAttribute anotations on fields.

Having two @ManagedAttribute annotation for a single attribute (getter and 
setter method) would cause another problem: Which description to use, if both 
annotations define a description attribute.

Possibly, it would be better to remove the description attribute from the 
@ManagedAttribute annotation, and move it into a separate @Description 
annotation which would also replace the description attribute for 
@ManagedOperation and @Parameter. It would be considered an error, if more than 
one @Description attribute was added 

This last change would also solve the issue of using the "value" annotation 
attribute for adding description. This is not ideal, since ...
@ManagedAttribute(value="This is the description", access=Access.READ_WRITE)
... just doesn't seem fluent. I'd rather see ...
@ManagedAttribute(Access.READ_WRITE) @Description("This is the description")

An added bonus is that the above change gets us a little closer to the 
(defunct) JMX 2.0/JSR 255 proposal.

Original issue reported on code.google.com by morten.h...@gmail.com on 9 Jul 2011 at 11:37

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r45.

Original comment by morten.h...@gmail.com on 10 Jul 2011 at 2:36