Polish async request processing
This change fixes a cyclical package dependency. The change also improves the implementation of WebAsyncManager.hasConcurrentResult() following the resolution of Apache issue id=53632 and the release of Apache Tomcat 7.0.30 that contains the fix.
This commit is contained in:
@@ -24,8 +24,8 @@ import org.springframework.orm.hibernate3.SessionFactoryUtils;
|
||||
import org.springframework.orm.hibernate3.SessionHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager.WebAsyncThreadInitializer;
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.springframework.orm.hibernate4.SessionFactoryUtils;
|
||||
import org.springframework.orm.hibernate4.SessionHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager.WebAsyncThreadInitializer;
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.orm.jpa.EntityManagerFactoryUtils;
|
||||
import org.springframework.orm.jpa.EntityManagerHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager.WebAsyncThreadInitializer;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.orm.hibernate3.support;
|
||||
|
||||
import static org.easymock.EasyMock.anyObject;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createStrictMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.reset;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
@@ -196,6 +196,10 @@ public class OpenSessionInViewTests {
|
||||
|
||||
// Async dispatch thread
|
||||
|
||||
reset(asyncWebRequest);
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(true);
|
||||
replay(asyncWebRequest);
|
||||
|
||||
interceptor.preHandle(this.webRequest);
|
||||
assertTrue("Session not bound to async thread", TransactionSynchronizationManager.hasResource(sf));
|
||||
|
||||
@@ -488,11 +492,11 @@ public class OpenSessionInViewTests {
|
||||
}
|
||||
};
|
||||
|
||||
AsyncWebRequest asyncWebRequest = createStrictMock(AsyncWebRequest.class);
|
||||
AsyncWebRequest asyncWebRequest = createMock(AsyncWebRequest.class);
|
||||
asyncWebRequest.addCompletionHandler((Runnable) anyObject());
|
||||
asyncWebRequest.startAsync();
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(true);
|
||||
expectLastCall().anyTimes();
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(true).anyTimes();
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(false).anyTimes();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(this.request);
|
||||
@@ -520,6 +524,7 @@ public class OpenSessionInViewTests {
|
||||
|
||||
expect(session.close()).andReturn(null);
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(false).anyTimes();
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(true).anyTimes();
|
||||
|
||||
replay(sf);
|
||||
replay(session);
|
||||
|
||||
@@ -24,8 +24,6 @@ import static org.easymock.EasyMock.expectLastCall;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.reset;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -161,7 +159,6 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(webRequest);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return "anything";
|
||||
@@ -169,14 +166,16 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
});
|
||||
|
||||
verify(asyncWebRequest);
|
||||
reset(asyncWebRequest);
|
||||
replay(asyncWebRequest);
|
||||
|
||||
interceptor.afterConcurrentHandlingStarted(webRequest);
|
||||
assertFalse(TransactionSynchronizationManager.hasResource(factory));
|
||||
|
||||
// Async dispatch thread
|
||||
|
||||
reset(asyncWebRequest);
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(true);
|
||||
replay(asyncWebRequest);
|
||||
|
||||
reset(manager, factory);
|
||||
replay(manager, factory);
|
||||
|
||||
@@ -345,11 +344,11 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
|
||||
FilterChain filterChain3 = new PassThroughFilterChain(filter2, filterChain2);
|
||||
|
||||
AsyncWebRequest asyncWebRequest = createStrictMock(AsyncWebRequest.class);
|
||||
AsyncWebRequest asyncWebRequest = createMock(AsyncWebRequest.class);
|
||||
asyncWebRequest.addCompletionHandler((Runnable) anyObject());
|
||||
asyncWebRequest.startAsync();
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(true);
|
||||
expectLastCall().anyTimes();
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(true).anyTimes();
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(false).anyTimes();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
@@ -373,6 +372,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
||||
|
||||
reset(asyncWebRequest);
|
||||
expect(asyncWebRequest.isAsyncStarted()).andReturn(false).anyTimes();
|
||||
expect(asyncWebRequest.isDispatched()).andReturn(true).anyTimes();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
assertFalse(TransactionSynchronizationManager.hasResource(factory));
|
||||
|
||||
Reference in New Issue
Block a user