Java 类org.springframework.web.context.request.async.DeferredResultProcessingInterceptor 实例源码

项目:spring4-understanding    文件:MvcNamespaceTests.java   
@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);
}
项目:class-guard    文件:MvcNamespaceTests.java   
@Test
public void testAsyncSupportOptions() throws Exception {
    loadBeanDefinitions("mvc-config-async-support.xml", 13);

    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);
}
项目:class-guard    文件:WebMvcConfigurationSupportExtensionTests.java   
@SuppressWarnings("unchecked")
@Test
public void requestMappingHandlerAdapter() throws Exception {
    RequestMappingHandlerAdapter adapter = webConfig.requestMappingHandlerAdapter();

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

    // Message converters
    assertEquals(1, adapter.getMessageConverters().size());

    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"));
}
项目:spring4-understanding    文件:RequestMappingHandlerAdapter.java   
/**
 * 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()]);
}
项目:spring4-understanding    文件:AsyncSupportConfigurer.java   
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
    return this.deferredResultInterceptors;
}
项目:spring4-understanding    文件:WebMvcConfigurationSupportExtensionTests.java   
@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"));
}
项目:class-guard    文件:RequestMappingHandlerAdapter.java   
/**
 * 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()]);
}
项目:class-guard    文件:AsyncSupportConfigurer.java   
protected List<DeferredResultProcessingInterceptor> getDeferredResultInterceptors() {
    return this.deferredResultInterceptors;
}
项目:spring4-understanding    文件:AsyncSupportConfigurer.java   
/**
 * 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;
}
项目:class-guard    文件:AsyncSupportConfigurer.java   
/**
 * 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;
}