Java Code Examples for org.springframework.context.annotation.Role

The following examples show how to use org.springframework.context.annotation.Role. These examples are extracted from open source projects. 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 Project: Limiter   Source File: ProxyLimiterConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public LimitedResourceSource limitedResourceSource() {
    String[] parsersClassNames = this.enableLimiter.getStringArray("annotationParser");
    List<String> defaultParsers = findDefaultParsers();
    if (!CollectionUtils.isEmpty(defaultParsers)) {
        int len = parsersClassNames.length;
        parsersClassNames = Arrays.copyOf(parsersClassNames, parsersClassNames.length + defaultParsers.size());
        for (int i = 0; i < defaultParsers.size(); i++) {
            parsersClassNames[i + len] = defaultParsers.get(i);
        }
    }
    LimiterAnnotationParser[] parsers = new LimiterAnnotationParser[parsersClassNames.length];
    for (int i = 0; i < parsersClassNames.length; i++) {
        try {
            Class<LimiterAnnotationParser> parserClass = (Class<LimiterAnnotationParser>) Class.forName(parsersClassNames[i]);
            parsers[i] = parserClass.newInstance();
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
            throw new RuntimeException("Class Not Found!");
        }
    }
    return new DefaultLimitedResourceSource(parsers);
}
 
Example 2
Source Project: lams   Source File: ProxyAsyncConfiguration.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
	Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
	AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
	Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");
	if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
		bpp.setAsyncAnnotationType(customAsyncAnnotation);
	}
	if (this.executor != null) {
		bpp.setExecutor(this.executor);
	}
	if (this.exceptionHandler != null) {
		bpp.setExceptionHandler(this.exceptionHandler);
	}
	bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));
	bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));
	return bpp;
}
 
Example 3
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor() {
	CacheInterceptor interceptor = new CacheInterceptor();
	interceptor.setCacheOperationSources(cacheOperationSource());
	if (this.cacheResolver != null) {
		interceptor.setCacheResolver(this.cacheResolver);
	}
	else if (this.cacheManager != null) {
		interceptor.setCacheManager(this.cacheManager);
	}
	if (this.keyGenerator != null) {
		interceptor.setKeyGenerator(this.keyGenerator);
	}
	if (this.errorHandler != null) {
		interceptor.setErrorHandler(this.errorHandler);
	}
	return interceptor;
}
 
Example 4
@Bean(name = "jCacheOperationSource")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheOperationSource cacheOperationSource() {
	DefaultJCacheOperationSource source = new DefaultJCacheOperationSource();
	if (this.cacheManager != null) {
		source.setCacheManager(this.cacheManager);
	}
	if (this.keyGenerator != null) {
		source.setKeyGenerator(this.keyGenerator);
	}
	if (this.cacheResolver != null) {
		source.setCacheResolver(this.cacheResolver);
	}
	if (this.exceptionCacheResolver != null) {
		source.setExceptionCacheResolver(this.exceptionCacheResolver);
	}
	return source;
}
 
Example 5
@Bean(name = TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
	Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
	AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
	Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");
	if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
		bpp.setAsyncAnnotationType(customAsyncAnnotation);
	}
	if (this.executor != null) {
		bpp.setExecutor(this.executor);
	}
	if (this.exceptionHandler != null) {
		bpp.setExceptionHandler(this.exceptionHandler);
	}
	bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));
	bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));
	return bpp;
}
 
Example 6
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor() {
	CacheInterceptor interceptor = new CacheInterceptor();
	interceptor.setCacheOperationSources(cacheOperationSource());
	if (this.cacheResolver != null) {
		interceptor.setCacheResolver(this.cacheResolver);
	}
	else if (this.cacheManager != null) {
		interceptor.setCacheManager(this.cacheManager);
	}
	if (this.keyGenerator != null) {
		interceptor.setKeyGenerator(this.keyGenerator);
	}
	if (this.errorHandler != null) {
		interceptor.setErrorHandler(this.errorHandler);
	}
	return interceptor;
}
 
Example 7
@Bean(name = "jCacheOperationSource")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheOperationSource cacheOperationSource() {
	DefaultJCacheOperationSource source = new DefaultJCacheOperationSource();
	if (this.cacheManager != null) {
		source.setCacheManager(this.cacheManager);
	}
	if (this.keyGenerator != null) {
		source.setKeyGenerator(this.keyGenerator);
	}
	if (this.cacheResolver != null) {
		source.setCacheResolver(this.cacheResolver);
	}
	if (this.exceptionCacheResolver != null) {
		source.setExceptionCacheResolver(this.exceptionCacheResolver);
	}
	return source;
}
 
Example 8
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor() {
	TransactionInterceptor interceptor = new TransactionInterceptor();
	interceptor.setTransactionAttributeSource(transactionAttributeSource());
	if (this.txManager != null) {
		interceptor.setTransactionManager(this.txManager);
	}
	return interceptor;
}
 
Example 9
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor(
		TransactionAttributeSource transactionAttributeSource, TransactionInterceptor transactionInterceptor) {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource);
	advisor.setAdvice(transactionInterceptor);
	if (this.enableTx != null) {
		advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 10
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor() {
	TransactionInterceptor interceptor = new TransactionInterceptor();
	interceptor.setTransactionAttributeSource(transactionAttributeSource());
	if (this.txManager != null) {
		interceptor.setTransactionManager(this.txManager);
	}
	return interceptor;
}
 
Example 11
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor(
		TransactionAttributeSource transactionAttributeSource,
		TransactionInterceptor transactionInterceptor) {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource);
	advisor.setAdvice(transactionInterceptor);
	if (this.enableTx != null) {
		advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 12
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor() {
	TransactionInterceptor interceptor = new TransactionInterceptor();
	interceptor.setTransactionAttributeSource(transactionAttributeSource());
	if (this.txManager != null) {
		interceptor.setTransactionManager(this.txManager);
	}
	return interceptor;
}
 
Example 13
Source Project: spring-analysis-note   Source File: ProxyAsyncConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
	Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
	AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
	bpp.configure(this.executor, this.exceptionHandler);
	Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");
	if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
		bpp.setAsyncAnnotationType(customAsyncAnnotation);
	}
	bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));
	bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));
	return bpp;
}
 
Example 14
Source Project: spring-analysis-note   Source File: ProxyCachingConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor() {
	CacheInterceptor interceptor = new CacheInterceptor();
	interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager);
	interceptor.setCacheOperationSource(cacheOperationSource());
	return interceptor;
}
 
Example 15
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource());
	advisor.setAdvice(transactionInterceptor());
	if (this.enableTx != null) {
		advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 16
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor() {
	TransactionInterceptor interceptor = new TransactionInterceptor();
	interceptor.setTransactionAttributeSource(transactionAttributeSource());
	if (this.txManager != null) {
		interceptor.setTransactionManager(this.txManager);
	}
	return interceptor;
}
 
Example 17
Source Project: spring-analysis-note   Source File: ProxyJCacheConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor() {
	BeanFactoryJCacheOperationSourceAdvisor advisor =
			new BeanFactoryJCacheOperationSourceAdvisor();
	advisor.setCacheOperationSource(cacheOperationSource());
	advisor.setAdvice(cacheInterceptor());
	if (this.enableCaching != null) {
		advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 18
Source Project: spring-analysis-note   Source File: ProxyJCacheConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor() {
	JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler);
	interceptor.setCacheOperationSource(cacheOperationSource());
	return interceptor;
}
 
Example 19
Source Project: spring-analysis-note   Source File: AspectJAsyncConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationAsyncExecutionAspect asyncAdvisor() {
	AnnotationAsyncExecutionAspect asyncAspect = AnnotationAsyncExecutionAspect.aspectOf();
	asyncAspect.configure(this.executor, this.exceptionHandler);
	return asyncAspect;
}
 
Example 20
@Bean(name = TransactionManagementConfigUtils.JTA_TRANSACTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JtaAnnotationTransactionAspect jtaTransactionAspect() {
	JtaAnnotationTransactionAspect txAspect = JtaAnnotationTransactionAspect.aspectOf();
	if (this.txManager != null) {
		txAspect.setTransactionManager(this.txManager);
	}
	return txAspect;
}
 
Example 21
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationTransactionAspect transactionAspect() {
	AnnotationTransactionAspect txAspect = AnnotationTransactionAspect.aspectOf();
	if (this.txManager != null) {
		txAspect.setTransactionManager(this.txManager);
	}
	return txAspect;
}
 
Example 22
Source Project: java-technology-stack   Source File: ProxyAsyncConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
	Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
	AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
	bpp.configure(this.executor, this.exceptionHandler);
	Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");
	if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
		bpp.setAsyncAnnotationType(customAsyncAnnotation);
	}
	bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));
	bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));
	return bpp;
}
 
Example 23
Source Project: java-technology-stack   Source File: ProxyCachingConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() {
	BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor();
	advisor.setCacheOperationSource(cacheOperationSource());
	advisor.setAdvice(cacheInterceptor());
	if (this.enableCaching != null) {
		advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 24
Source Project: java-technology-stack   Source File: ProxyCachingConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor() {
	CacheInterceptor interceptor = new CacheInterceptor();
	interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager);
	interceptor.setCacheOperationSource(cacheOperationSource());
	return interceptor;
}
 
Example 25
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource());
	advisor.setAdvice(transactionInterceptor());
	if (this.enableTx != null) {
		advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 26
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionInterceptor transactionInterceptor() {
	TransactionInterceptor interceptor = new TransactionInterceptor();
	interceptor.setTransactionAttributeSource(transactionAttributeSource());
	if (this.txManager != null) {
		interceptor.setTransactionManager(this.txManager);
	}
	return interceptor;
}
 
Example 27
Source Project: java-technology-stack   Source File: ProxyJCacheConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor() {
	BeanFactoryJCacheOperationSourceAdvisor advisor =
			new BeanFactoryJCacheOperationSourceAdvisor();
	advisor.setCacheOperationSource(cacheOperationSource());
	advisor.setAdvice(cacheInterceptor());
	if (this.enableCaching != null) {
		advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
	}
	return advisor;
}
 
Example 28
Source Project: java-technology-stack   Source File: AspectJAsyncConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationAsyncExecutionAspect asyncAdvisor() {
	AnnotationAsyncExecutionAspect asyncAspect = AnnotationAsyncExecutionAspect.aspectOf();
	asyncAspect.configure(this.executor, this.exceptionHandler);
	return asyncAspect;
}
 
Example 29
@Bean(name = TransactionManagementConfigUtils.JTA_TRANSACTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JtaAnnotationTransactionAspect jtaTransactionAspect() {
	JtaAnnotationTransactionAspect txAspect = JtaAnnotationTransactionAspect.aspectOf();
	if (this.txManager != null) {
		txAspect.setTransactionManager(this.txManager);
	}
	return txAspect;
}
 
Example 30
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationTransactionAspect transactionAspect() {
	AnnotationTransactionAspect txAspect = AnnotationTransactionAspect.aspectOf();
	if (this.txManager != null) {
		txAspect.setTransactionManager(this.txManager);
	}
	return txAspect;
}