Package com.ultikits.ultitools.aop
Class AopProxyBeanPostProcessor
java.lang.Object
com.ultikits.ultitools.aop.AopProxyBeanPostProcessor
- All Implemented Interfaces:
BeanPostProcessor
BeanPostProcessor that creates AOP proxies for beans that need interception.
This processor checks each bean during initialization and creates a CGLIB proxy
if any registered AopAdvisor matches the bean's methods.
Usage example:
AopProxyBeanPostProcessor aopProcessor = new AopProxyBeanPostProcessor();
aopProcessor.addAdvisor(AopAdvisor.forAnnotation(Transactional.class, txInterceptor, 100));
container.addBeanPostProcessor(aopProcessor);
- Since:
- 6.2.0
- Author:
- wisdomme
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInternal interceptor that only applies if the advisor matches the specific method. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdvisor(AopAdvisor advisor) Adds an advisor to be applied during proxy creation.Gets all registered advisors.private List<MethodInterceptor> getApplicableInterceptors(Class<?> targetClass) Gets all interceptors that apply to the given class.postProcessAfterInitialization(Object bean, String beanName) Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks.booleanremoveAdvisor(AopAdvisor advisor) Removes an advisor.private booleanrequiresProxy(Class<?> targetClass) Checks if the given class requires a proxy based on any advisor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.context.BeanPostProcessor
postProcessBeforeInitialization
-
Field Details
-
LOGGER
-
advisors
-
-
Constructor Details
-
AopProxyBeanPostProcessor
public AopProxyBeanPostProcessor()
-
-
Method Details
-
addAdvisor
Adds an advisor to be applied during proxy creation.- Parameters:
advisor- the advisor to add
-
removeAdvisor
Removes an advisor.- Parameters:
advisor- the advisor to remove- Returns:
- true if the advisor was removed
-
getAdvisors
Gets all registered advisors.- Returns:
- an unmodifiable list of advisors
-
postProcessAfterInitialization
Description copied from interface:BeanPostProcessorApply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks.
在任何Bean初始化回调之后,将此BeanPostProcessor应用于给定的新Bean实例。- Specified by:
postProcessAfterInitializationin interfaceBeanPostProcessor- Parameters:
bean- the new bean instance
新的Bean实例beanName- the name of the bean
Bean的名称- Returns:
- the bean instance to use
要使用的Bean实例
-
getApplicableInterceptors
Gets all interceptors that apply to the given class. -
requiresProxy
Checks if the given class requires a proxy based on any advisor.
-