All runtime instances associated with a component are maintained under reference objects. The reference object that is selected by the runtime is determined by the component collection policy. The following table lists available collection policies and related semantics.
Policy | Description |
---|---|
HARD | The HARD ensures that an instance reference will be maintained for the life of the runtime unless explicitly destroyed as a result of container shutdown or management request. The HARD collection policy should not be used in conjunction with TRANSIENT lifestyle. |
SOFT | If no objects have a reference to the runtime instance and memory contention occurs, component instances held under the SOFT collection will be garbage collected. |
WEAK | If no objects have a reference to the runtime instance the instance will be garbage collected at the discretion of the JVM. |
A special collection policy named SYSTEM is used to delegate the selection of a collection policy to the container. If no explicit collection policy is nominated by a component the SYSTEM policy will be asserted. The default behaviour of the runtime is to assign the HARD collection policy to top-level components and the SOFT policy to subsidiary instances.