Nature (enum)

The different sorts of domain objects recognized by Causeway.

API

Nature.java
enum Nature {
  NOT_SPECIFIED     (1)
  ENTITY     (2)
  VIEW_MODEL     (3)
  MIXIN     (4)
  BEAN     (5)
  boolean isNotSpecified()
  boolean isEntity()
  boolean isMixin()
  boolean isViewModel()
  boolean isBean()
}
1 NOT_SPECIFIED

The default; allows the programmer to combine @DomainObject annotation with the ViewModel annotation, or the XmlRootElement annotation, or by implementing the ViewModel interface.

2 ENTITY

A domain entity whose persistence is managed internally by Causeway, using JPA or JDO as the persistence implementation.

3 VIEW_MODEL

An object that is conceptually part of the application layer, and which surfaces behavior and/or state that is aggregate of one or more domain entity.

4 MIXIN

An object that acts as a mix-in to some other object, contributing behavior and/or derived state based on the domain object.

5 BEAN

An object that is entirely managed by the underlying IoC container.

Members

NOT_SPECIFIED

The default; allows the programmer to combine @DomainObject annotation with the ViewModel annotation, or the XmlRootElement annotation, or by implementing the ViewModel interface.

ENTITY

A domain entity whose persistence is managed internally by Causeway, using JPA or JDO as the persistence implementation.

Domain entities are considered to be part of the domain model layer.

Currently implies no additional semantics other than documentation.

VIEW_MODEL

An object that is conceptually part of the application layer, and which surfaces behavior and/or state that is aggregate of one or more domain entity.

The identity of a view model is determined solely by the state of object’s properties. Using this nature should be considered exactly equivalent to annotating with ViewModel .

Note that collections are ignored; if their state is required to fully identify the view model, define the view model using the JAXB XmlRootElement annotation instead (where the object’s state is serialized to an arbitrarily deep graph of data, with references to persistent entities transparently resolved to <oid-dto> elements).

MIXIN

An object that acts as a mix-in to some other object, contributing behavior and/or derived state based on the domain object.

BEAN

An object that is entirely managed by the underlying IoC container.

Some possible use cases for this are:

  • As a helper service that is used to emit messages through Action#executionPublishing() .

    The service itself isn’t rendered anywhere, but its actions can be invoked through the org.apache.causeway.applib.services.wrapper.WrapperFactory . (Or as a variant, it might expose a Programmatic API and then delegate to its own action via the org.apache.causeway.applib.services.wrapper.WrapperFactory .

  • As a service representing a facade to a module, so that code in another (untrusted) module can only execute through Action s

    Again, either the calling module is expected to use the org.apache.causeway.applib.services.wrapper.WrapperFactory when invoking the facade service, or - since the calling code is treated untrusted - then the same self-delegation approach as for the previous example could be used, whereby the facade service exposes a Programmatic API and then delegates to its own action via the org.apache.causeway.applib.services.wrapper.WrapperFactory .

    *IMPORTANT* the class must _also_ be annotated with an appropriate _org.springframework.context.annotation.Scope_ , eg `@Scope("singleton")` or `@Scope("prototype")`