@Retention(value=RUNTIME) @Target(value=METHOD) @Documented public @interface InitialValueField
This annotation may be used on:
It is illegal to use this annotation on both the CMP field getter and setter methods, or to declare an initial value for the same CMP field multiple times. For example, if a given CMP field is declared both in an SBB abstract class and an SBB CMP extension interface, only one CMP field declaration may be annotated with an initial value declaration. It is legal, however, for example, for two separate SBB CMP extension interfaces to both extend from a common interface that declares a CMP field with an initial value, as the initial value has only been declared once by the parent interface.
The SLEE behaviour is undefined if an object referenced by an initial value class field is mutated at any time. A newly created entity containing the CMP field could be initialised with either the original initial value or the modified initial value at the discretion of the SLEE implementation. It is generally advised that initial values be immutable, though in some cases this will not be possible.
If a CMP field is annotated with both this annotation and the @PassByReference
annotation requesting permanent pass-by-reference semantics, then the specified initial value
must be serialisable by some recognised means, eg. FastSerializable
, Encodable
,
a DatatypeCodec
, standard Java serialisation, etc. This is to allow the SLEE implementation
to instantiate a new copy of the initial value for each new SBB entity. Once a new copy of the
initial value is created for a given SBB entity, that value will continue to be returned from
the CMP field getter method for the lifetime of that SBB entity, unless set to a different value
by the application, in accordance with permanent pass-by-reference semantics.
The annotation parameter naming the class field is optional. If a field name is not explicitly
specified, a field with the name "_initial"
+ the CMP field name, with the first letter
capitalised, is assumed. For example, for a CMP field with the name foo
, the default
initial value field name is _initialFoo
.
Examples:
// initial value field name explicitly specified @InitialValueField("aValue") public abstract void setIntValue(int value); public abstract int getIntValue(); public static final int aValue = 42; // initial value field name not specified, default name is assumed @InitialValueField public abstract void setListValue(List<String> value); public abstract List<String> getListValue(); public static final List<String> _initialListValue = new ArrayList<String>(5);
public abstract String value
"_initial"
+ the CMP field name, with the first
letter capitalised.