Examples of AsyncWebRequest


Examples of org.springframework.web.context.request.async.AsyncWebRequest

    ModelAndViewContainer mavContainer = new ModelAndViewContainer();
    mavContainer.addAllAttributes(RequestContextUtils.getInputFlashMap(request));
    modelFactory.initModel(webRequest, mavContainer, requestMappingMethod);
    mavContainer.setIgnoreDefaultModelOnRedirect(this.ignoreDefaultModelOnRedirect);

    AsyncWebRequest asyncWebRequest = WebAsyncUtils.createAsyncWebRequest(request, response);
    asyncWebRequest.setTimeout(this.asyncRequestTimeout);

    final WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
    asyncManager.setTaskExecutor(this.taskExecutor);
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.registerCallableInterceptors(this.callableInterceptors);
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    ModelAndViewContainer mavContainer = new ModelAndViewContainer();
    mavContainer.addAllAttributes(RequestContextUtils.getInputFlashMap(request));
    modelFactory.initModel(webRequest, mavContainer, requestMappingMethod);
    mavContainer.setIgnoreDefaultModelOnRedirect(this.ignoreDefaultModelOnRedirect);

    AsyncWebRequest asyncWebRequest = WebAsyncUtils.createAsyncWebRequest(request, response);
    asyncWebRequest.setTimeout(this.asyncRequestTimeout);

    final WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
    asyncManager.setTaskExecutor(this.taskExecutor);
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.registerCallableInterceptors(this.callableInterceptors);
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    given(factory.createEntityManager()).willReturn(this.manager);

    interceptor.preHandle(this.webRequest);
    assertTrue(TransactionSynchronizationManager.hasResource(factory));

    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.webRequest);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    given(this.factory.createEntityManager()).willReturn(this.manager);

    interceptor.preHandle(this.webRequest);
    assertTrue(TransactionSynchronizationManager.hasResource(this.factory));

    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

      }
    };

    FilterChain filterChain3 = new PassThroughFilterChain(filter2, filterChain2);

    AsyncWebRequest asyncWebRequest = mock(AsyncWebRequest.class);
    given(asyncWebRequest.isAsyncStarted()).willReturn(true);

    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
      public String call() throws Exception {
        return "anything";
      }
    });

    assertFalse(TransactionSynchronizationManager.hasResource(factory));
    assertFalse(TransactionSynchronizationManager.hasResource(factory2));
    filter2.doFilter(this.request, this.response, filterChain3);
    assertFalse(TransactionSynchronizationManager.hasResource(factory));
    assertFalse(TransactionSynchronizationManager.hasResource(factory2));
    assertEquals(1, count.get());
    assertEquals(1, count2.get());
    assertNotNull(request.getAttribute("invoked"));
    verify(asyncWebRequest, times(2)).addCompletionHandler(any(Runnable.class));
    verify(asyncWebRequest).addTimeoutHandler(any(Runnable.class));
    verify(asyncWebRequest, times(2)).addCompletionHandler(any(Runnable.class));
    verify(asyncWebRequest).startAsync();

    // Async dispatch after concurrent handling produces result ...

    reset(asyncWebRequest);
    given(asyncWebRequest.isAsyncStarted()).willReturn(false);

    assertFalse(TransactionSynchronizationManager.hasResource(factory));
    assertFalse(TransactionSynchronizationManager.hasResource(factory2));
    filter.doFilter(this.request, this.response, filterChain3);
    assertFalse(TransactionSynchronizationManager.hasResource(factory));
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    given(session.getSessionFactory()).willReturn(sf);

    interceptor.preHandle(this.webRequest);
    assertTrue(TransactionSynchronizationManager.hasResource(sf));

    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    given(session.getSessionFactory()).willReturn(sf);

    interceptor.preHandle(this.webRequest);
    assertTrue(TransactionSynchronizationManager.hasResource(sf));

    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

        assertTrue(TransactionSynchronizationManager.hasResource(sf));
        count.incrementAndGet();
      }
    };

    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
    asyncManager.setTaskExecutor(new SyncTaskExecutor());
    asyncManager.setAsyncWebRequest(asyncWebRequest);
    asyncManager.startCallableProcessing(new Callable<String>() {
      @Override
View Full Code Here

Examples of org.springframework.web.context.request.async.AsyncWebRequest

    MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter");
    final OpenSessionInViewFilter filter = new OpenSessionInViewFilter();
    filter.init(filterConfig);

    final AtomicInteger count = new AtomicInteger(0);
    final AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    final MockHttpServletRequest request = this.request;

    final FilterChain filterChain = new FilterChain() {
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.