Annotation Type ReferenceCounted
-
@Documented @NormalScope(passivating=false) @Retention(RUNTIME) @Target({TYPE,METHOD,FIELD}) public @interface ReferenceCounted
An annotation indicating the bean that is annotated belongs to theReferenceCountedContext
.Use Cases
Annotate a class with
@ReferenceCounted
when all of the following apply:- You need an instance of your class to be associated with exactly one thread.
- You need the single thread-specific instance of your class to be destroyed eagerly, but not too eagerly. Specifically, you need the instance to be destroyed when it is no longer in use by any other object that is not itself destroyed.
- If an instance of your class is destroyed, and some other object asks for an instance of your class, a new instance should be provided.
Another way of thinking of
@ReferenceCounted
-annotated classes is that they behave as though they were members of a slightly shorter-lived application scope.Still another way of thinking of
@ReferenceCounted
-annotated classes is that they behave as though they were members of request scope, but with the notional request starting upon first instantiation.- See Also:
ReferenceCountedContext