return getServletResponse();
}
- public void start(Runnable run) {
- // TODO SERVLET3 - async
- this.dispatch = run;
- request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+ public void start(final Runnable run) {
+ if (state.compareAndSet(AsyncState.STARTED, AsyncState.DISPATCHING) ||
+ state.compareAndSet(AsyncState.DISPATCHED, AsyncState.DISPATCHING)) {
+ // TODO SERVLET3 - async
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ run.run();
+ }catch (Exception x) {
+ log.error("Unable to run async task.",x);
+ }
+ }
+ };
+ this.dispatch = r;
+ request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+ } else {
+ throw new IllegalStateException("Dispatch not allowed. Invalid state:"+state.get());
+ }
}
public void addAsyncListener(AsyncListener listener) {
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestWrapper;
import javax.servlet.ServletResponse;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
if (!isAsyncSupported()) throw new IllegalStateException("Not supported.");
if (asyncContext==null) asyncContext = new AsyncContextImpl(this);
else if (asyncContext.isStarted()) throw new IllegalStateException("Already started.");
+ asyncContext.setStarted(getContext());
asyncContext.setServletRequest(getRequest());
asyncContext.setServletResponse(response.getResponse());
- asyncContext.setStarted(getContext());
return asyncContext;
}
startAsync();
asyncContext.setServletRequest(request);
asyncContext.setServletResponse(response);
+ //TODO SERVLET3 - async - need to retrieve the ServletContext here
+ //or just the webapp classloader associated with to do
+ //run with start(Runnable)
asyncContext.setHasOriginalRequestAndResponse(request==getRequest() && response==getResponse().getResponse());
return asyncContext;
}