@Bean(name=AnnotationConfigUtils.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 = enableAsync.getClass("annotation"); if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) { bpp.setAsyncAnnotationType(customAsyncAnnotation); } if (this.executor != null) { bpp.setExecutor(this.executor); } bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass")); bpp.setOrder(this.enableAsync.<Integer>getNumber("order")); return bpp; }
@Bean(name = CacheAdvisor.CACHE_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheAdvisor jetcacheAdvisor() { ConcurrentHashMap configMap = new ConcurrentHashMap(); JetCacheInterceptor jetCacheInterceptor = new JetCacheInterceptor(); jetCacheInterceptor.setCacheConfigMap(configMap); jetCacheInterceptor.setApplicationContext(applicationContext); CacheAdvisor advisor = new CacheAdvisor(); advisor.setAdviceBeanName(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME); advisor.setAdvice(jetCacheInterceptor); advisor.setBasePackages(this.enableMethodCache.getStringArray("basePackages")); advisor.setCacheConfigMap(configMap); advisor.setOrder(this.enableMethodCache.<Integer>getNumber("order")); return advisor; }
@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; }
@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; }
@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; }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public Advisor packageTraceAdvisor() { ComposablePointcut resultPointcut = new ComposablePointcut(); { List<String> basePackages = findBasePackages(); String pointcutExpression = makeExpression(basePackages); AspectJExpressionPointcut packagePointcut = new AspectJExpressionPointcut(); log.info("Include package Pointcut expression : {}", pointcutExpression); packagePointcut.setExpression(pointcutExpression); resultPointcut.intersection((Pointcut) packagePointcut); } String excludeAnnotation = buildExcludeAnnotation(); log.info("Exclude Annotation Pointcut expression : {}", excludeAnnotation); AspectJExpressionPointcut basePointcut = new AspectJExpressionPointcut(); basePointcut.setExpression(excludeAnnotation); resultPointcut.intersection((Pointcut) basePointcut); DefaultPointcutAdvisor pointcutAdvisor = new DefaultPointcutAdvisor(resultPointcut, new TraceAopInterceptor(traceLogManager)); pointcutAdvisor.setOrder(Integer.MAX_VALUE); return pointcutAdvisor; }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public LockInterceptor lockInterceptor() { LockInterceptor interceptor = new LockInterceptor(); interceptor.setLockAttributeSource(lockAttributeSource()); AbstractLockSynchronizationManager synchronizationManager; if (enableLock.getBoolean("sessionTransacted")) { synchronizationManager = new SessionTransactedLockSynchronizationManager(); } else { synchronizationManager = new DefaultLockSynchronizationManager(); } synchronizationManager.setLockService(lockService); synchronizationManager.setLockEventPublisher(lockEventPublisher()); interceptor.setSynchronizationManager(synchronizationManager); return interceptor; }
@ConditionalOnProperty(prefix = "async.executor", name = "enabled", matchIfMissing = true) @Bean(name = DEFAULT_TASK_EXECUTOR_BEAN_NAME, destroyMethod = "shutdown") @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public ThreadPoolTaskExecutor threadPoolTaskExecutor(AsyncExecutorProperties properties) { log.info("Creating ThreadPoolTaskExecutor 'taskExecutor' with core-size={} max-size={} queue-capacity={}", properties.getCorePoolSize(), properties.getMaxPoolSize(), properties.getQueueCapacity()); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(properties.getCorePoolSize()); executor.setMaxPoolSize(properties.getMaxPoolSize()); executor.setQueueCapacity(properties.getQueueCapacity()); executor.setThreadNamePrefix(properties.getThreadNamePrefix()); executor.setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds()); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy()); executor.afterPropertiesSet(); return executor; }
@Bean(name=TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() { BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor(); advisor.setTransactionAttributeSource(transactionAttributeSource()); advisor.setAdvice(transactionInterceptor()); advisor.setOrder(this.enableTx.<Integer>getNumber("order")); return advisor; }
@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; }
@Bean(name=AnnotationConfigUtils.CACHE_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() { BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor(); advisor.setCacheOperationSource(cacheOperationSource()); advisor.setAdvice(cacheInterceptor()); advisor.setOrder(this.enableCaching.<Integer>getNumber("order")); return advisor; }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheInterceptor cacheInterceptor() { CacheInterceptor interceptor = new CacheInterceptor(); interceptor.setCacheOperationSources(cacheOperationSource()); if (this.cacheManager != null) { interceptor.setCacheManager(this.cacheManager); } if (this.keyGenerator != null) { interceptor.setKeyGenerator(this.keyGenerator); } return interceptor; }
@Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor() { BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor(); advisor.setCacheOperationSource(cacheOperationSource()); advisor.setAdvice(cacheInterceptor()); advisor.setOrder(this.enableCaching.<Integer>getNumber("order")); return advisor; }
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() { BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor(); advisor.setTransactionAttributeSource(transactionAttributeSource()); advisor.setAdvice(transactionInterceptor()); advisor.setOrder(this.enableTx.<Integer>getNumber("order")); return advisor; }
@Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor() { BeanFactoryJCacheOperationSourceAdvisor advisor = new BeanFactoryJCacheOperationSourceAdvisor(); advisor.setCacheOperationSource(cacheOperationSource()); advisor.setAdvice(cacheInterceptor()); advisor.setOrder(this.enableCaching.<Integer>getNumber("order")); return advisor; }
@Bean(name = "jCacheInterceptor") @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public JCacheInterceptor cacheInterceptor() { JCacheInterceptor interceptor = new JCacheInterceptor(); interceptor.setCacheOperationSource(cacheOperationSource()); if (this.errorHandler != null) { interceptor.setErrorHandler(this.errorHandler); } return interceptor; }
@Bean(name = TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public AnnotationAsyncExecutionAspect asyncAdvisor() { AnnotationAsyncExecutionAspect asyncAspect = AnnotationAsyncExecutionAspect.aspectOf(); if (this.executor != null) { asyncAspect.setExecutor(this.executor); } if (this.exceptionHandler != null) { asyncAspect.setExceptionHandler(this.exceptionHandler); } return asyncAspect; }
@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; }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public BeanFactoryLockAttributeSourceAdvisor lockAdvisor() { Assert.notNull(enableLock, "@EnableLock annotation metadata was not injected"); BeanFactoryLockAttributeSourceAdvisor advisor = new BeanFactoryLockAttributeSourceAdvisor(); advisor.setOrder(enableLock.<Integer> getNumber("order")); advisor.setLockAttributeSource(lockAttributeSource()); advisor.setAdvice(lockInterceptor()); return advisor; }
@Bean(destroyMethod = "shutdown") @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public ScheduledExecutorService scheduledExecutorService() { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(properties.getCorePoolSize()); executor.setMaximumPoolSize(properties.getMaxPoolSize()); executor.setThreadFactory(new CustomizableThreadFactory(properties.getThreadNamePrefix())); executor.setRejectedExecutionHandler(getConfiguredRejectedExecutionHandler()); return executor; }
@Bean(name = DEFAULT_TASK_SCHEDULER_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public TaskScheduler taskScheduler() { if (taskExecutor != null) { log.debug("create task-scheduler with pre-configured executor ..."); return new ConcurrentTaskScheduler(taskExecutor, scheduledExecutorService()); } else { log.debug("create task-scheduler without pre-configured executor ..."); return new ConcurrentTaskScheduler(scheduledExecutorService()); } }
@Bean(name=AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public AnnotationAsyncExecutionAspect asyncAdvisor() { AnnotationAsyncExecutionAspect asyncAspect = AnnotationAsyncExecutionAspect.aspectOf(); if (this.executor != null) { asyncAspect.setExecutor(this.executor); } return asyncAspect; }
@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; }
@SuppressWarnings("rawtypes") @Bean(name = TankMessageServiceConfigUtils.TOPIC_HANDLER_ANNOTATION_PROCESSOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public TopicMessageHandlerBeanPostProcessor topicHandlerAnnotationProcessor() { return new TopicMessageHandlerBeanPostProcessor(); }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) @Order(Ordered.HIGHEST_PRECEDENCE) public StringValueResolver durationCapableStringValueResolver() { return SchedulingUtils.prepScheduledAnnotationBeanPostProcessor(applicationContext); }
@Bean(name=AnnotationConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME) @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() { return new ScheduledAnnotationBeanPostProcessor(); }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public TransactionAttributeSource transactionAttributeSource() { return new AnnotationTransactionAttributeSource(); }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheOperationSource cacheOperationSource() { return new AnnotationCacheOperationSource(); }