本文整理汇总了Java中org.springframework.aop.framework.ProxyFactory.setTargetClass方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory.setTargetClass方法的具体用法?Java ProxyFactory.setTargetClass怎么用?Java ProxyFactory.setTargetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.framework.ProxyFactory
的用法示例。
在下文中一共展示了ProxyFactory.setTargetClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureFactoryForClass
import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
/**
* Based on the given class, properly instructs the ProxyFactory proxies. For additional sanity checks on the passed
* classes, check the methods below.
*
* @see #containsUnrelatedClasses(Class[])
* @see #removeParents(Class[])
*
* @param factory
* @param classes
*/
public static void configureFactoryForClass(ProxyFactory factory, Class<?>[] classes) {
if (ObjectUtils.isEmpty(classes))
return;
for (int i = 0; i < classes.length; i++) {
Class<?> clazz = classes[i];
if (clazz.isInterface()) {
factory.addInterface(clazz);
} else {
factory.setTargetClass(clazz);
factory.setProxyTargetClass(true);
}
}
}
示例2: createProxy
import org.springframework.aop.framework.ProxyFactory; //导入方法依赖的package包/类
private Object createProxy(final Class<?> clazz, Advice cardinalityInterceptor) {
ProxyFactory factory = new ProxyFactory();
factory.setProxyTargetClass(true);
factory.setOptimize(true);
factory.setTargetClass(clazz);
factory.addAdvice(cardinalityInterceptor);
factory.setFrozen(true);
return factory.getProxy(ProxyFactory.class.getClassLoader());
}