if (target == null) {
throw new IllegalStateException("Property 'target' is required");
}
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(new CachingModelSourceAdvisor(cachingInterceptor));
if (hasFlushingModels) {
proxyFactory.addAdvisor(new FlushingModelSourceAdvisor(
flushingInterceptor));
}
proxyFactory.copyFrom(this);
TargetSource targetSource = createTargetSource(target);
proxyFactory.setTargetSource(targetSource);
if (proxyInterfaces != null) {
proxyFactory.setInterfaces(proxyInterfaces);
} else if (!isProxyTargetClass()) {
if (target instanceof TargetSource) {
throw new AopConfigException(
"Either 'proxyInterfaces' or 'proxyTargetClass' is required "
+ "when using a TargetSource as 'target'");
}
// rely on AOP infrastructure to tell us what interfaces to proxy
proxyFactory.setInterfaces(ClassUtils.getAllInterfaces(target));
}
proxy = proxyFactory.getProxy();
}