Interface Intercepted
- All Superinterfaces:
InterceptedBean
- All Known Subinterfaces:
HotSwappableInterceptedProxy<T>, InterceptedProxy<T>, Introduced
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<BeanRegistration<Interceptor<?, ?>>> The interceptor registrations that were resolved for this proxy.Methods inherited from interface InterceptedBean
interceptedMethods
-
Method Details
-
$interceptorRegistrations
The interceptor registrations that were resolved for this proxy.Every generated proxy retains the registrations its constructor was given, so a proxy can always report the interceptors bound to it. For an around- or introduction-only proxy that is the set matching its around bindings; a proxy whose target also declares lifecycle advice is given a wider set, described below.
The scenario the retention was introduced for is an advised bean that also declares lifecycle advice:
@Retention(RUNTIME) @Around @InterceptorBinding(kind = InterceptorKind.POST_CONSTRUCT) @InterceptorBinding(kind = InterceptorKind.PRE_DESTROY) @interface Tracked {} @Singleton @Tracked class MyBean { @PostConstruct void init() {} @PreDestroy void close() {} }The proxy constructor is given the registrations that match the target's bindings and keeps them, so post-construct and pre-destroy interception select from the same set the proxy already uses for its methods, and a
@Prototypeinterceptor is one instance for the whole life of one target. Destruction in particular has no other route to them: it runs with a fresh resolution context, and the proxy instance is the only thing that survives from creation to destruction.Proxies generated before this existed keep the empty default; the runtime then resolves interceptors by binding as it always did.
The context reads the same list through
InterceptedBean.$interceptorRegistrations()whendestroyBean(Object)is handed a proxy it tracks no registration for, so the non-singleton interceptors are destroyed with their target there too.- Specified by:
$interceptorRegistrationsin interfaceInterceptedBean- Returns:
- The retained interceptor registrations, never
null - Since:
- 5.2.0
-