Java Code Examples for org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator#setProxyTargetClass()

The following examples show how to use org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator#setProxyTargetClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionalConfig.java    From spring-boot-start-current with Apache License 2.0 6 votes vote down vote up
/**
 * 配置事务拦截
 * <p>
 * {@link #customizeTransactionInterceptor(PlatformTransactionManager)}
 */
@Bean
public BeanNameAutoProxyCreator customizeTransactionBeanNameAutoProxyCreator () {
	BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator();
	// 设置定制的事务拦截器
	beanNameAutoProxyCreator.setInterceptorNames( CUSTOMIZE_TRANSACTION_INTERCEPTOR_NAME );
	List< String > transactionBeanNames = new ArrayList<>( DEFAULT_TRANSACTION_BEAN_NAMES.length + customizeTransactionBeanNames.length );
	// 默认
	transactionBeanNames.addAll( Arrays.asList( DEFAULT_TRANSACTION_BEAN_NAMES ) );
	// 定制
	transactionBeanNames.addAll( Arrays.asList( customizeTransactionBeanNames ) );
	// 归集
	for ( String transactionBeanName : transactionBeanNames ) {
		beanNameAutoProxyCreator.setBeanNames( transactionBeanName );
	}
	beanNameAutoProxyCreator.setProxyTargetClass( true );
	return beanNameAutoProxyCreator;
}
 
Example 2
Source File: DruidConfig.java    From SpringBoot-Base-System with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 必须使用Qualifier 否则注入失败
 * 
 * @time 2018年4月10日 下午5:00:31.
 * @version V1.0
 * @return BeanNameAutoProxyCreator
 */
@Bean
@Qualifier("druid-stat-interceptor") // 注入上面的bean
public BeanNameAutoProxyCreator getBeanNameAutoProxyCreator() {
	BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator();
	beanNameAutoProxyCreator.setInterceptorNames("druid-stat-interceptor"); // 关联
	beanNameAutoProxyCreator.setBeanNames("*Service", "*Dao");
	beanNameAutoProxyCreator.setProxyTargetClass(true);
	return beanNameAutoProxyCreator;
}
 
Example 3
Source File: InterceptorConfig.java    From micro-service with MIT License 5 votes vote down vote up
@Bean
public BeanNameAutoProxyCreator beanNameAutoProxyCreator() {
	
	BeanNameAutoProxyCreator creator = new BeanNameAutoProxyCreator();
	creator.setProxyTargetClass(true);
	creator.setBeanNames("classesController");
	creator.setInterceptorNames("druidStatInterceptor");
	
	System.out.println("load druid stat interceptor...");
	
	return creator;
}
 
Example 4
Source File: InterceptorConfig.java    From micro-service with MIT License 5 votes vote down vote up
@Bean
public BeanNameAutoProxyCreator beanNameAutoProxyCreator() {
	
	BeanNameAutoProxyCreator creator = new BeanNameAutoProxyCreator();
	creator.setProxyTargetClass(true);
	creator.setBeanNames("companyController", "organizationController", "personController", "qRCodeController");
	creator.setInterceptorNames("druidStatInterceptor");
	
	System.out.println("load druid stat interceptor...");
	
	return creator;
}