Annotation Type InitialValueField


  • @Retention(RUNTIME)
    @Target(METHOD)
    @Documented
    public @interface InitialValueField

    Annotation that names a class field that contains the initial value for a CMP field. The named class field must be public, static, and final, must be visible in the scope of the annotated CMP field accessor method, and must have a type that is assignable to the CMP field.

    This annotation may be used on:

    • an SBB abstract class CMP field getter or setter method.

    • an SBB or SBB part CMP extension interface CMP field getter or setter method.

    • a profile CMP interface CMP field getter or setter method.

    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
    Since:
    Rhino 2.4.0
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String value
      The name of the class field containing the CMP field initial value.
    • Element Detail

      • value

        String value

        The name of the class field containing the CMP field initial value. If not specified, defaults to "_initial" + the CMP field name, with the first letter capitalised.

        Since:
        Rhino 2.4.0
        Default:
        ""