org.springframework.web.context.request.async.DeferredResultProcessingInterceptor Java Examples

The following examples show how to use org.springframework.web.context.request.async.DeferredResultProcessingInterceptor. 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: spring-analysis-note   Author: Vip-Augus   File: MvcNamespaceTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testAsyncSupportOptions() throws Exception {
	loadBeanDefinitions("mvc-config-async-support.xml");

	RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);
}
 
Example #2
Source Project: java-technology-stack   Author: codeEngraver   File: MvcNamespaceTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testAsyncSupportOptions() throws Exception {
	loadBeanDefinitions("mvc-config-async-support.xml");

	RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);
}
 
Example #3
Source Project: spring4-understanding   Author: langtianya   File: MvcNamespaceTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAsyncSupportOptions() throws Exception {
	loadBeanDefinitions("mvc-config-async-support.xml", 15);

	RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class);
	assertNotNull(adapter);

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);
}
 
Example #4
Source Project: spring-analysis-note   Author: Vip-Augus   File: AsyncSupportConfigurer.java    License: MIT License 5 votes vote down vote up
/**
 * Configure lifecycle interceptors with callbacks around concurrent request
 * execution that starts when a controller returns a {@link DeferredResult}.
 * @param interceptors the interceptors to register
 */
public AsyncSupportConfigurer registerDeferredResultInterceptors(
		DeferredResultProcessingInterceptor... interceptors) {

	this.deferredResultInterceptors.addAll(Arrays.asList(interceptors));
	return this;
}
 
Example #5
Source Project: spring-analysis-note   Author: Vip-Augus   File: WebMvcConfigurationSupportExtensionTests.java    License: MIT License 5 votes vote down vote up
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
	configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor())
			.registerCallableInterceptors(new CallableProcessingInterceptor() {
			})
			.registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() {
			});
}
 
Example #6
Source Project: java-technology-stack   Author: codeEngraver   File: AsyncSupportConfigurer.java    License: MIT License 5 votes vote down vote up
/**
 * Configure lifecycle interceptors with callbacks around concurrent request
 * execution that starts when a controller returns a {@link DeferredResult}.
 * @param interceptors the interceptors to register
 */
public AsyncSupportConfigurer registerDeferredResultInterceptors(
		DeferredResultProcessingInterceptor... interceptors) {

	this.deferredResultInterceptors.addAll(Arrays.asList(interceptors));
	return this;
}
 
Example #7
Source Project: spring-analysis-note   Author: Vip-Augus   File: AsyncSupportConfigurer.java    License: MIT License 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #8
Source Project: spring-analysis-note   Author: Vip-Augus   File: WebMvcConfigurationSupportExtensionTests.java    License: MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void requestMappingHandlerAdapter() throws Exception {
	RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter(
			this.config.mvcContentNegotiationManager(), this.config.mvcConversionService(),
			this.config.mvcValidator());

	// ConversionService
	String actual = this.config.mvcConversionService().convert(new TestBean(), String.class);
	assertEquals("converted", actual);

	// Message converters
	List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
	assertEquals(2, converters.size());
	assertEquals(StringHttpMessageConverter.class, converters.get(0).getClass());
	assertEquals(MappingJackson2HttpMessageConverter.class, converters.get(1).getClass());
	ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converters.get(1)).getObjectMapper();
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getSerializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(FAIL_ON_UNKNOWN_PROPERTIES));

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);

	// Custom argument resolvers and return value handlers
	List<HandlerMethodArgumentResolver> argResolvers =
			(List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers");
	assertEquals(1, argResolvers.size());

	List<HandlerMethodReturnValueHandler> handlers =
			(List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers");
	assertEquals(1, handlers.size());

	// Async support options
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);

	assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example #9
Source Project: java-technology-stack   Author: codeEngraver   File: AsyncSupportConfigurer.java    License: MIT License 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #10
Source Project: java-technology-stack   Author: codeEngraver   File: WebMvcConfigurationSupportExtensionTests.java    License: MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void requestMappingHandlerAdapter() throws Exception {
	RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter();

	// ConversionService
	String actual = this.config.mvcConversionService().convert(new TestBean(), String.class);
	assertEquals("converted", actual);

	// Message converters
	List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
	assertEquals(2, converters.size());
	assertEquals(StringHttpMessageConverter.class, converters.get(0).getClass());
	assertEquals(MappingJackson2HttpMessageConverter.class, converters.get(1).getClass());
	ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converters.get(1)).getObjectMapper();
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getSerializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(FAIL_ON_UNKNOWN_PROPERTIES));

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);

	// Custom argument resolvers and return value handlers
	List<HandlerMethodArgumentResolver> argResolvers =
		(List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers");
	assertEquals(1, argResolvers.size());

	List<HandlerMethodReturnValueHandler> handlers =
		(List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers");
	assertEquals(1, handlers.size());

	// Async support options
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);

	assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example #11
Source Project: java-technology-stack   Author: codeEngraver   File: WebMvcConfigurationSupportExtensionTests.java    License: MIT License 4 votes vote down vote up
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
	configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor())
		.registerCallableInterceptors(new CallableProcessingInterceptor() { })
		.registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() {});
}
 
Example #12
Source Project: lams   Author: lamsfoundation   File: RequestMappingHandlerAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Configure {@code DeferredResultProcessingInterceptor}'s to register on async requests.
 * @param interceptors the interceptors to register
 */
public void setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor> interceptors) {
	Assert.notNull(interceptors, "DeferredResultProcessingInterceptor List must not be null");
	this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[interceptors.size()]);
}
 
Example #13
Source Project: lams   Author: lamsfoundation   File: AsyncSupportConfigurer.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #14
Source Project: spring4-understanding   Author: langtianya   File: RequestMappingHandlerAdapter.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Configure {@code DeferredResultProcessingInterceptor}'s to register on async requests.
 * @param interceptors the interceptors to register
 */
public void setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor> interceptors) {
	Assert.notNull(interceptors);
	this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[interceptors.size()]);
}
 
Example #15
Source Project: spring4-understanding   Author: langtianya   File: AsyncSupportConfigurer.java    License: Apache License 2.0 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #16
Source Project: spring4-understanding   Author: langtianya   File: WebMvcConfigurationSupportExtensionTests.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void requestMappingHandlerAdapter() throws Exception {
	RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter();

	// ConversionService
	String actual = this.config.mvcConversionService().convert(new TestBean(), String.class);
	assertEquals("converted", actual);

	// Message converters
	assertEquals(2, adapter.getMessageConverters().size());
	assertEquals(StringHttpMessageConverter.class, adapter.getMessageConverters().get(0).getClass());
	assertEquals(MappingJackson2HttpMessageConverter.class, adapter.getMessageConverters().get(1).getClass());
	ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)adapter.getMessageConverters().get(1)).getObjectMapper();
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
	assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));

	DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter);

	// Custom argument resolvers and return value handlers
	List<HandlerMethodArgumentResolver> argResolvers =
		(List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers");
	assertEquals(1, argResolvers.size());

	List<HandlerMethodReturnValueHandler> handlers =
		(List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers");
	assertEquals(1, handlers.size());

	// Async support options
	assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass());
	assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout"));

	CallableProcessingInterceptor[] callableInterceptors =
			(CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors");
	assertEquals(1, callableInterceptors.length);

	DeferredResultProcessingInterceptor[] deferredResultInterceptors =
			(DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors");
	assertEquals(1, deferredResultInterceptors.length);

	assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect"));
}
 
Example #17
Source Project: spring-analysis-note   Author: Vip-Augus   File: RequestMappingHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * Configure {@code DeferredResultProcessingInterceptor}'s to register on async requests.
 * @param interceptors the interceptors to register
 */
public void setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor> interceptors) {
	this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[0]);
}
 
Example #18
Source Project: java-technology-stack   Author: codeEngraver   File: RequestMappingHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * Configure {@code DeferredResultProcessingInterceptor}'s to register on async requests.
 * @param interceptors the interceptors to register
 */
public void setDeferredResultInterceptors(List<DeferredResultProcessingInterceptor> interceptors) {
	this.deferredResultInterceptors = interceptors.toArray(new DeferredResultProcessingInterceptor[0]);
}
 
Example #19
Source Project: lams   Author: lamsfoundation   File: AsyncSupportConfigurer.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Configure lifecycle interceptors with callbacks around concurrent request
 * execution that starts when a controller returns a {@link DeferredResult}.
 * @param interceptors the interceptors to register
 */
public AsyncSupportConfigurer registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors) {
	this.deferredResultInterceptors.addAll(Arrays.asList(interceptors));
	return this;
}
 
Example #20
Source Project: spring4-understanding   Author: langtianya   File: AsyncSupportConfigurer.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Configure lifecycle interceptors with callbacks around concurrent request
 * execution that starts when a controller returns a {@link DeferredResult}.
 *
 * @param interceptors the interceptors to register
 */
public AsyncSupportConfigurer registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors) {
	Assert.notNull(interceptors, "Interceptors are required");
	this.deferredResultInterceptors.addAll(Arrays.asList(interceptors));
	return this;
}