Created
July 30, 2011 12:57
-
-
Save nschlimm/1115496 to your computer and use it in GitHub Desktop.
DecoratorPostProcessor main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { | |
if (metaData.isDecoratedBean(beanName)) { | |
return buildDelegateProxy(bean, beanName); | |
} else { | |
return bean; | |
} | |
} | |
@SuppressWarnings("serial") | |
public Object buildDelegateProxy(final Object bean, final String beanName) { | |
final SimpleBeanTargetSource targetSource = new SimpleBeanTargetSource() {{setTargetBeanName(beanName); setTargetClass(bean.getClass()); setBeanFactory(beanFactory);}}; | |
ProxyFactory pf = new ProxyFactory() {{setTargetSource(targetSource); setProxyTargetClass(true);}}; | |
DelegateMethodInterceptor interceptor = new DelegateMethodInterceptor(chainingStrategy.getChainedDecorators(beanFactory, metaData.getQualifiedDecoratorChain(beanName), bean)); | |
pf.addAdvice(interceptor); pf.addInterface(DelegateProxyInspector.class); | |
Object proxy = pf.getProxy(); | |
return proxy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment