本文整理汇总了Java中org.springframework.aop.framework.ProxyFactoryBean.setTargetClass方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactoryBean.setTargetClass方法的具体用法?Java ProxyFactoryBean.setTargetClass怎么用?Java ProxyFactoryBean.setTargetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.framework.ProxyFactoryBean
的用法示例。
在下文中一共展示了ProxyFactoryBean.setTargetClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: proxyAdvice
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private static <T> T proxyAdvice(T t, Advice methodInterceptor) {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTargetClass(t.getClass());
proxyFactoryBean.setTarget(t);
proxyFactoryBean.addAdvice(methodInterceptor);
return (T) proxyFactoryBean.getObject();
}
示例2: proxyAdvice
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
public static <T> T proxyAdvice(T t, Advice methodInterceptor) {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTargetClass(t.getClass());
proxyFactoryBean.setTarget(t);
proxyFactoryBean.addAdvice(methodInterceptor);
return (T) proxyFactoryBean.getObject();
}
示例3: buildToStringCapableProxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private <T> T buildToStringCapableProxy(Class<? extends T> tClass, T t) throws ClassNotFoundException {
MethodInterceptor toString = methodInvocation ->
(methodInvocation.getMethod().getName().equals("toString")) ?
ToStringBuilder.reflectionToString(t, ToStringStyle.MULTI_LINE_STYLE) :
methodInvocation.getMethod().invoke(t, methodInvocation.getArguments());
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(t);
proxyFactoryBean.setProxyTargetClass(true);
proxyFactoryBean.addAdvice(toString);
proxyFactoryBean.setTargetClass(tClass);
return tClass.cast(proxyFactoryBean.getObject());
}
示例4: proxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private static <T> T proxy(Class<T> tClass,
MethodInterceptor methodInterceptor) {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.addAdvice(methodInterceptor);
proxyFactoryBean.setProxyTargetClass(true);
proxyFactoryBean.setTargetClass(tClass);
return tClass.cast(proxyFactoryBean.getObject());
}
示例5: proxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private <T> T proxy(Class<T> tClass, MethodInterceptor methodInterceptor) {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.addAdvice(methodInterceptor);
proxyFactoryBean.setProxyTargetClass(true);
proxyFactoryBean.setTargetClass(tClass);
return tClass.cast(proxyFactoryBean.getObject());
}