Interface Intercepted

All Superinterfaces:
InterceptedBean
All Known Subinterfaces:
HotSwappableInterceptedProxy<T>, InterceptedProxy<T>, Introduced

public interface Intercepted extends InterceptedBean
An interface implemented by generated proxy classes.
Since:
1.0
Author:
Graeme Rocher
  • Method Details

    • $interceptorRegistrations

      @Internal default List<BeanRegistration<Interceptor<?,?>>> $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 @Prototype interceptor 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() when destroyBean(Object) is handed a proxy it tracks no registration for, so the non-singleton interceptors are destroyed with their target there too.

      Specified by:
      $interceptorRegistrations in interface InterceptedBean
      Returns:
      The retained interceptor registrations, never null
      Since:
      5.2.0