Interface SyntheticBeanDisposer<T>
- Type Parameters:
T- the implementation class of the synthetic bean
SyntheticBeanBuilder.
CDI container will create an instance of the destruction function every time when it needs
to destroy an instance of the synthetic bean. Implementations must be public
classes with a public zero-parameter constructor; they must not be beans.
Starting with CDI 5.0, the dispose(Object, Instance, Parameters) method is deprecated
for removal; suggested replacement is dispose(Object, SyntheticInjections, Parameters).
Exactly one of these methods must be implemented; if not, non-portable behavior results.
The CDI container must check which method exists and call it. The CDI container may assume
that the dispose(Object, SyntheticInjections, Parameters) method is present directly
on the class registered using SyntheticBeanBuilder.disposeWith(Class)
and not inherited from a superclass or a superinterface.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault voiddispose(T instance, SyntheticInjections injections, Parameters params) Destroys an instance of the synthetic bean.default voiddispose(T instance, Instance<Object> lookup, Parameters params) Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Details
-
dispose
Destroys an instance of the synthetic bean.The
SyntheticInjectionsparameter may be used to simulate disposer method parameter injection. All injectable references looked up fromSyntheticInjectionshave to previously be registered usingSyntheticBeanBuilder.withInjectionPoint().All
@Dependentbean instances created bySyntheticInjectionsfor this destruction function are destroyed when thedispose()invocation completes.Trying to look up
InjectionPointfrom theSyntheticInjectionsparameter is invalid.The parameter map contains the same values that were passed to
SyntheticBeanBuilder.withParam().- Parameters:
instance- the synthetic bean instance, nevernullinjections-SyntheticInjectionsthat can be used to obtain injectable references for previously registered injection points, nevernullparams- the parameter map, nevernull- Since:
- 5.0
-
dispose
@Deprecated(forRemoval=true, since="5.0") default void dispose(T instance, Instance<Object> lookup, Parameters params) Deprecated, for removal: This API element is subject to removal in a future version.usedispose(Object, SyntheticInjections, Parameters)and register all potentially looked up beans usingSyntheticBeanBuilder.withInjectionPoint()Destroys an instance of the synthetic bean.The
Instanceparameter may be used to simulate disposer method parameter injection. All@Dependentbean instances obtained from theInstanceduring execution are destroyed when execution completes.Trying to look up
InjectionPointfrom theInstanceparameter is invalid.The parameter map contains the same values that were passed to
SyntheticBeanBuilder.withParam().- Parameters:
instance- the synthetic bean instance, nevernulllookup- anInstancethat can be used to lookup other beans, nevernullparams- the parameter map, nevernull
-
dispose(Object, SyntheticInjections, Parameters)and register all potentially looked up beans usingSyntheticBeanBuilder.withInjectionPoint()