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 File: MvcNamespaceTests.java    From spring4-understanding with 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 #2
Source File: MvcNamespaceTests.java    From spring-analysis-note with 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 File: MvcNamespaceTests.java    From java-technology-stack with 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 #4
Source File: AsyncSupportConfigurer.java    From spring-analysis-note with 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 File: WebMvcConfigurationSupportExtensionTests.java    From spring-analysis-note with 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 File: AsyncSupportConfigurer.java    From java-technology-stack with 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 File: WebMvcConfigurationSupportExtensionTests.java    From spring4-understanding with 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 #8
Source File: AsyncSupportConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #9
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with 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 #10
Source File: AsyncSupportConfigurer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #11
Source File: RequestMappingHandlerAdapter.java    From lams with 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 #12
Source File: WebMvcConfigurationSupportExtensionTests.java    From java-technology-stack with 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 #13
Source File: WebMvcConfigurationSupportExtensionTests.java    From java-technology-stack with 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 #14
Source File: AsyncSupportConfigurer.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #15
Source File: WebMvcConfigurationSupportExtensionTests.java    From spring-analysis-note with 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 #16
Source File: AsyncSupportConfigurer.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
	return this.deferredResultInterceptors;
}
 
Example #17
Source File: AsyncSupportConfigurer.java    From lams with 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 #18
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with 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 File: AsyncSupportConfigurer.java    From spring4-understanding with 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;
}
 
Example #20
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with 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]);
}