Class SharedInterceptorRegistrations
The scenario this exists for is a bean whose advice is declared with @AroundConstruct and lifecycle
interceptor bindings but no @Around, so no proxy is generated and there is no instance field in which to
retain anything:
@Retention(RUNTIME)
@AroundConstruct
@InterceptorBinding(kind = InterceptorKind.POST_CONSTRUCT)
@interface Managed {}
@Singleton @Managed
class Product { @PostConstruct void init() {} }
Without sharing, construction and post-construct each resolve their own interceptor, so a @Prototype
interceptor cannot carry state from one phase to the next.
A bean definition is a stateless singleton shared by every instance, so the resolved registrations cannot be kept
on it. They are kept on the BeanResolutionContext instead, which is one instance for the whole of a bean's
creation. The window is narrower than it looks: for a bean with constructor advice the generated
doInstantiate runs post-construct interception from inside the constructor interceptor chain, so
the registrations are pushed before construction and popped after it, and entries are keyed by definition so that a
bean created while another is being constructed reads its own.
Destruction happens later with a fresh resolution context, so nothing is shared with it here; see
MethodInterceptorChain for how pre-destroy reaches the interceptors a bean owns.
Everything here is package-private except store(BeanResolutionContext, BeanDefinition, List), which the runtime proxy path in
io.micronaut.aop.runtime calls from another package.
- Since:
- 5.2.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidstore(BeanResolutionContext resolutionContext, BeanDefinition<?> definition, @Nullable List<?> registrations) Stores registrations resolved outside the constructor-sharing stack, such as runtime proxy definitions.
-
Method Details
-
store
public static void store(BeanResolutionContext resolutionContext, BeanDefinition<?> definition, @Nullable List<?> registrations) Stores registrations resolved outside the constructor-sharing stack, such as runtime proxy definitions.- Parameters:
resolutionContext- The resolution contextdefinition- The definition being instantiatedregistrations- The registrations- Since:
- 5.2.0
-