Class ProxyingBeanDefinitionWriter
java.lang.Object
io.micronaut.aop.writer.ProxyingBeanDefinitionWriter
- All Implemented Interfaces:
ProxyBuilder<ClassElement, MethodElement, List<OutputObjectDef>>, Buildable<List<OutputObjectDef>>, ElementProxyBuilder<OutputObjectDef>, OriginatingElements
- Direct Known Subclasses:
AopProxyWriter, RuntimeProxyBeanDefinitionWriter
@NullUnmarked
@Internal
public abstract class ProxyingBeanDefinitionWriter
extends Object
implements ElementProxyBuilder<OutputObjectDef>
An abstract class for writing proxy bean definitions.
- Since:
- 5.0
- Author:
- Denis Stepanov
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MethodElementprotected final ExecutableMethodsDefinitionWriterprotected final booleanprotected final Set<AnnotationValue<?>> protected final Set<ClassElement> protected final booleanprotected final booleanprotected final OriginatingElementsprotected final BeanDefinitionWriterprotected final BeanDefinitionWriterprotected final ClassElementprotected final ClassElementprotected VisitorContext -
Constructor Summary
ConstructorsConstructorDescriptionProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, boolean implementInterface, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a newProxyingBeanDefinitionWriterfor the purposes of writingIntroductionadvise.ProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a newProxyingBeanDefinitionWriterfor the purposes of writingIntroductionadvise.ProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, BeanDefinitionWriter parent, OptionalValues<Boolean> settings, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a newProxyingBeanDefinitionWriterfor the given parentBeanDefinitionWriterand starting interceptors types. -
Method Summary
Modifier and TypeMethodDescriptionaddAroundMethod(MethodElement methodElement) Adds a method that should participate in around advice.addIntroductionMethod(MethodElement methodElement) Adds an introduction method implemented directly by the proxy.voidaddOriginatingElement(Element element) Add another element that should be included in the originating elements.addProxyMethod(MethodElement methodElement) Adds a proxied method that delegates to the target.build()Builds the result.protected final @Nullable MethodElementfindOverriddenBy(MethodElement methodElement) Find overridden by method with a different signature.protected static MethodElementgetConstructor(ClassElement type) protected @Nullable StringAllows subclasses to provide a custom bean definition name for the proxy.Element[]protected booleangetProxyTarget(ClassElement targetType, BeanDefinitionWriter parent, OptionalValues<Boolean> settings) implementInterface(ClassElement interfaceElement) Adds an interface to be implemented by the proxy.voidprotected final voidprotected static Stringprotected voidvisitInterceptorBinding(AnnotationValue<?>... interceptorBinding) visitInterceptorTypes.
-
Field Details
-
proxyType
-
constructor
-
targetType
-
proxyBeanDefinitionWriter
-
interceptorBinding
-
parentWriter
-
isProxyTarget
protected final boolean isProxyTarget -
isIntroduction
protected final boolean isIntroduction -
implementInterface
protected final boolean implementInterface -
interfaceTypes
-
visitorContext
-
originatingElements
-
executableMethodsDefinitionWriter
-
-
Constructor Details
-
ProxyingBeanDefinitionWriter
public ProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, BeanDefinitionWriter parent, OptionalValues<Boolean> settings, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a new
ProxyingBeanDefinitionWriterfor the given parentBeanDefinitionWriterand starting interceptors types.Additional
Interceptortypes can be added downstream withvisitInterceptorBinding(AnnotationValue[]).- Parameters:
constructor- The constructor used to materialize the proxyproxyType- The proxyTypetargetType- The targetTypeparent- The parentBeanDefinitionWritersettings- optional settingvisitorContext- The visitor contextinterceptorBinding- The interceptor binding of theInterceptorinstances to be injected
-
ProxyingBeanDefinitionWriter
public ProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a newProxyingBeanDefinitionWriterfor the purposes of writingIntroductionadvise.- Parameters:
constructor- The constructorproxyType- The proxy typetargetType- The target typevisitorContext- The visitor contextinterceptorBinding- The interceptor types
-
ProxyingBeanDefinitionWriter
public ProxyingBeanDefinitionWriter(MethodElement constructor, ClassElement proxyType, ClassElement targetType, boolean implementInterface, VisitorContext visitorContext, AnnotationValue<?>... interceptorBinding) Constructs a newProxyingBeanDefinitionWriterfor the purposes of writingIntroductionadvise.- Parameters:
constructor- The constructorproxyType- The proxy typetargetType- The target typeimplementInterface- Whether the interface should be implemented. If false theinterfaceTypesargument should contain at least one entryvisitorContext- The visitor contextinterceptorBinding- The interceptor binding
-
-
Method Details
-
getCustomBeanDefinitionName
Allows subclasses to provide a custom bean definition name for the proxy. Implementations must return eithernullto use the default naming strategy or a fully qualified class name unique within the module.- Returns:
- The custom bean definition name or
nullto use the default
-
implementInterface
Description copied from interface:ProxyBuilderAdds an interface to be implemented by the proxy.- Specified by:
implementInterfacein interfaceProxyBuilder<ClassElement, MethodElement, List<OutputObjectDef>>- Parameters:
interfaceElement- The interface element
-
addProxyMethod
Description copied from interface:ProxyBuilderAdds a proxied method that delegates to the target.- Specified by:
addProxyMethodin interfaceProxyBuilder<ClassElement, MethodElement, List<OutputObjectDef>>- Parameters:
methodElement- The method to proxy
-
getConstructor
-
getProxyTarget
protected boolean getProxyTarget(ClassElement targetType, BeanDefinitionWriter parent, OptionalValues<Boolean> settings) - Parameters:
targetType- The target typeparent- The parentsettings- The settings- Returns:
- is proxy target
-
build
Description copied from interface:BuildableBuilds the result.- Specified by:
buildin interfaceBuildable<List<OutputObjectDef>>- Returns:
- The builder result
-
postConstructor
public void postConstructor() -
visitInterceptorBinding
visitInterceptorTypes.- Parameters:
interceptorBinding- the interceptor binding
-
processAlreadyVisitedMethods
-
getOriginatingElements
- Specified by:
getOriginatingElementsin interfaceOriginatingElements- Returns:
- The elements where the bean definition originated from as an array.
-
addOriginatingElement
Description copied from interface:OriginatingElementsAdd another element that should be included in the originating elements.- Specified by:
addOriginatingElementin interfaceOriginatingElements- Parameters:
element- The element to add
-
toTypeString
- Parameters:
p- The class element- Returns:
- The string representation
-
findOverriddenBy
Find overridden by method with a different signature.- Parameters:
methodElement- The method element- Returns:
- the overridden
-
addAroundMethod
Description copied from interface:ProxyBuilderAdds a method that should participate in around advice.- Specified by:
addAroundMethodin interfaceProxyBuilder<ClassElement, MethodElement, List<OutputObjectDef>>- Parameters:
methodElement- The method element
-
addIntroductionMethod
Description copied from interface:ProxyBuilderAdds an introduction method implemented directly by the proxy.- Specified by:
addIntroductionMethodin interfaceProxyBuilder<ClassElement, MethodElement, List<OutputObjectDef>>- Parameters:
methodElement- The method to introduce
-
beanDefinitionBuilder
- Specified by:
beanDefinitionBuilderin interfaceElementProxyBuilder<OutputObjectDef>- Returns:
- The underlying bean definition builder used to materialize the proxy
-