Hello!
Axon with it’s Spring integration uses AbstractAnnotationHandlerBeanPostProcessor to process @EventHandler annotation.
But could someone explain why it is implemented as creating and especially replacing my bean with CGLIB-based proxy?
`
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) throws BeansException {
Class<?> targetClass = bean.getClass();
final ClassLoader classLoader = targetClass.getClassLoader();
if (parameterResolverFactory == null) {
parameterResolverFactory = ClasspathParameterResolverFactory.forClassLoader(classLoader);
}
if (isPostProcessingCandidate(targetClass)) {
T adapter = initializeAdapterFor(bean, parameterResolverFactory);
final I proxy = createAdapterProxy(bean, adapter, getAdapterInterface(), true, classLoader);
managedAdapters.put(beanName, adapter);
managedProxies.put(beanName, proxy);
if (running) {
subscribe(proxy, adapter);
}
return proxy;
//...
`
Wouldn’t it better just to create a separate Adapter Instance and subscribe it to EventBus not replacing bean itself?
And at least maybe it will be better just to return bean itself instead of proxy?
Thanks in advance.