@Retention(value=RUNTIME) @Target(value={FIELD,METHOD}) @Inherited public @interface MAttribute
Use this annotation to manage a value of a field or a value that is provided by bean accessor method as attribute of a MBean
.
Example:
@MBean
public class MyBean {@MAttribute
private String myAttribute; private int count;@MAttribute(name="counter", description="My first counter", writable=true)
private int getCount() { return count; } private void setCount(int count) { this.count=count; } }
The bean provides a read only attribute myAttribute
and a writable attribute counter
with the description "My first counter".
You can use EL expressions to dynamically resolve the name and description of the managed attribute.
E.g. #{name} will be replaced by the value of the field name if it exists or the value returned by method getName().
Also complex expressions like #{pmv.application.name}
works.
Example:
@MBean
(value="Test:type=TestType") public class TestBean {@MInclude
private Counter errors = new Counter("errors"); } public static class Counter {@MAttribute
(name="#{name}", description="All #{name} that were occured") private int cnt=0; private String name; public Counter(String name) { this.name = name; } }
Modifier and Type | Optional Element and Description |
---|---|
String |
description |
boolean |
isWritable |
String |
name |
Class<?> |
type
If no type is declared on a
MAttribute annotation the type of the field or the return type of the method the annotation is declared on
will be used to search for more annotations such as MComposite that defines the open type of the attribute. |
public abstract String description
public abstract String name
public abstract Class<?> type
MAttribute
annotation the type of the field or the return type of the method the annotation is declared on
will be used to search for more annotations such as MComposite
that defines the open type of the attribute.
However, if the real type of the field or return type of the method is not the declared type but a sub type and the annotations are declared
on the sub type instead of the declared type then use this annotation attribute to specify the real type.
If the declared type is a List
or a sub class of it with one generic parameter then you can use the type attribute to specify the real content type of the list.Copyright © 2016 AXON IVY AG. All rights reserved.