本文整理汇总了Java中org.springframework.aop.framework.ProxyFactoryBean.setTarget方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactoryBean.setTarget方法的具体用法?Java ProxyFactoryBean.setTarget怎么用?Java ProxyFactoryBean.setTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.framework.ProxyFactoryBean
的用法示例。
在下文中一共展示了ProxyFactoryBean.setTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upgradeAllOrNothing
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Test
@DirtiesContext
public void upgradeAllOrNothing() throws Exception {
TestUserService testUserService = new TestUserService(users.get(3).getId());
testUserService.setUserDao(this.userDao);
testUserService.setMailSender(mailSender);
ProxyFactoryBean txProxyFactoryBean = context.getBean("&userService", ProxyFactoryBean.class);
txProxyFactoryBean.setTarget(testUserService);
UserService txUserService = (UserService) txProxyFactoryBean.getObject();
userDao.deleteAll();
for (User user : users)
userDao.add(user);
try {
txUserService.upgradeLevels();
fail("TestUserServiceException expected");
} catch (TestUserServiceException e) {
}
checkLevel(users.get(1), false); // 오류 이전에 Update 한 사용자의 Level이 바뀌었나 확인
}
示例2: proxyFactoryBean
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Test
public void proxyFactoryBean() {
ProxyFactoryBean pfBean = new ProxyFactoryBean();
pfBean.setTarget(new HelloTarget());
pfBean.addAdvice(new UppercaseAdvice());
pfBean.setInterfaces(new Class[] { Hello.class }); // 생략해도 됨.
Hello proxiedHandler = (Hello) pfBean.getObject();
assertThat(proxiedHandler.sayHello("JUNG"), is("HELLO JUNG"));
assertThat(proxiedHandler.sayHi("JUNG"), is("HI JUNG"));
assertThat(proxiedHandler.sayThankYou("JUNG"), is("THANK YOU JUNG"));
}
示例3: pointcutAdvisor
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Test
public void pointcutAdvisor() {
ProxyFactoryBean pfBean = new ProxyFactoryBean();
pfBean.setTarget(new HelloTarget());
NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
pointcut.setMappedName("sayH*");
pfBean.addAdvisor(new DefaultPointcutAdvisor(pointcut,
new UppercaseAdvice()));
Hello proxiedHello = (Hello) pfBean.getObject();
assertThat(proxiedHello.sayHello("Jung"), is("HELLO JUNG"));
assertThat(proxiedHello.sayHi("Jung"), is("HI JUNG"));
assertThat(proxiedHello.sayThankYou("Jung"), is("Thank you Jung"));
}
示例4: checkAdvice
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private void checkAdvice(Object target,
Pointcut pointcut, boolean adviced) {
ProxyFactoryBean pfBean = new ProxyFactoryBean();
pfBean.setTarget(target);
pfBean.addAdvisor(new DefaultPointcutAdvisor(pointcut, new UppercaseAdvice()));
Hello proxiedHello = (Hello)pfBean.getObject();
if (adviced) {
assertThat(proxiedHello.sayHello("Jung"), is("HELLO JUNG"));
assertThat(proxiedHello.sayHi("Jung"), is("HI JUNG"));
assertThat(proxiedHello.sayThankYou("Jung"), is("Thank you Jung"));
}
else {
assertThat(proxiedHello.sayHello("Jung"), is("Hello Jung"));
assertThat(proxiedHello.sayHi("Jung"), is("Hi Jung"));
assertThat(proxiedHello.sayThankYou("Jung"), is("Thank you Jung"));
}
}
示例5: createProxyFactoryBean
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
private ProxyFactoryBean createProxyFactoryBean(IService rawService, boolean proxyTargetClass) throws ClassNotFoundException {
final ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setProxyInterfaces(new Class<?>[]{IService.class});
proxyFactoryBean.setTarget(rawService);
proxyFactoryBean.setProxyTargetClass(proxyTargetClass);
return proxyFactoryBean;
}
示例6: 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();
}
示例7: 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();
}
示例8: amazonDynamoDbProxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean(name = "amazonDynamoDB")
public ProxyFactoryBean amazonDynamoDbProxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(amazonDynamoDB());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例9: amazonEC2Proxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonEC2Proxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(amazonEC2());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例10: amazonS3Proxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonS3Proxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(amazonS3());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例11: amazonDynamoDbMapperProxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean (name = "amazonDynamoDbMapper")
public ProxyFactoryBean amazonDynamoDbMapperProxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(dynamoDBMapper());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例12: amazonAutoScalingProxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonAutoScalingProxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(autoScalingClient());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例13: amazonELBProxy
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonELBProxy() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(elasticLoadBalancingClient());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例14: amazonCloudWatch
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonCloudWatch() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(cloudWatchClient());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}
示例15: amazonSNS
import org.springframework.aop.framework.ProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public ProxyFactoryBean amazonSNS() {
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(amazonSNSClient());
proxyFactoryBean.setInterceptorNames("retryInterceptor");
return proxyFactoryBean;
}