Java Code Examples for org.springframework.scheduling.config.TaskManagementConfigUtils

The following examples show how to use org.springframework.scheduling.config.TaskManagementConfigUtils. 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: 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 2
@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
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 4
Source Project: spring-analysis-note   Source File: EnableSchedulingTests.java    License: MIT License 5 votes vote down vote up
@Test
public void withExplicitScheduler() throws InterruptedException {
	Assume.group(TestGroup.PERFORMANCE);

	ctx = new AnnotationConfigApplicationContext(ExplicitSchedulerConfig.class);
	assertEquals(1, ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size());

	Thread.sleep(100);
	assertThat(ctx.getBean(AtomicInteger.class).get(), greaterThanOrEqualTo(10));
	assertThat(ctx.getBean(ExplicitSchedulerConfig.class).threadName, startsWith("explicitScheduler-"));
	assertTrue(Arrays.asList(ctx.getDefaultListableBeanFactory().getDependentBeans("myTaskScheduler")).contains(
			TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME));
}
 
Example 5
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 6
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() {
	Object executor = context.getBean("testExecutor");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(executor, ((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor")).get());
}
 
Example 7
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() {
	Object exceptionHandler = context.getBean("testExceptionHandler");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(exceptionHandler, ((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("exceptionHandler")).get());
}
 
Example 8
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 9
Source Project: java-technology-stack   Source File: EnableSchedulingTests.java    License: MIT License 5 votes vote down vote up
@Test
public void withExplicitScheduler() throws InterruptedException {
	Assume.group(TestGroup.PERFORMANCE);

	ctx = new AnnotationConfigApplicationContext(ExplicitSchedulerConfig.class);
	assertEquals(1, ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size());

	Thread.sleep(100);
	assertThat(ctx.getBean(AtomicInteger.class).get(), greaterThanOrEqualTo(10));
	assertThat(ctx.getBean(ExplicitSchedulerConfig.class).threadName, startsWith("explicitScheduler-"));
	assertTrue(Arrays.asList(ctx.getDefaultListableBeanFactory().getDependentBeans("myTaskScheduler")).contains(
			TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME));
}
 
Example 10
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 11
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() {
	Object executor = context.getBean("testExecutor");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(executor, ((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor")).get());
}
 
Example 12
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() {
	Object exceptionHandler = context.getBean("testExceptionHandler");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(exceptionHandler, ((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("exceptionHandler")).get());
}
 
Example 13
@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;
}
 
Example 14
Source Project: spring-analysis-note   Source File: SchedulingConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {
	return new ScheduledAnnotationBeanPostProcessor();
}
 
Example 15
@Test
public void asyncAspectRegistered() {
	assertTrue(context.containsBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
}
 
Example 16
Source Project: java-technology-stack   Source File: SchedulingConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {
	return new ScheduledAnnotationBeanPostProcessor();
}
 
Example 17
@Test
public void asyncAspectRegistered() {
	assertTrue(context.containsBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
}
 
Example 18
Source Project: lams   Source File: SchedulingConfiguration.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {
	return new ScheduledAnnotationBeanPostProcessor();
}
 
Example 19
@Bean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ScheduledAnnotationBeanPostProcessor scheduledAnnotationProcessor() {
	return new ScheduledAnnotationBeanPostProcessor();
}
 
Example 20
@Test
public void asyncAspectRegistered() {
	assertTrue(context.containsBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
}
 
Example 21
@Test
public void asyncPostProcessorExecutorReference() {
	Object executor = context.getBean("testExecutor");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(executor, new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor"));
}
 
Example 22
@Test
public void asyncPostProcessorExceptionHandlerReference() {
	Object exceptionHandler = context.getBean("testExceptionHandler");
	Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
	assertSame(exceptionHandler, new DirectFieldAccessor(aspect).getPropertyValue("exceptionHandler"));
}