mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-02 20:09:21 +00:00
307589 updated servlet 3.0 continuations for final API
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1427 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
956c5ea73c
commit
6985c24948
@ -6,6 +6,7 @@ jetty-7.0.2.SNAPSHOT
|
|||||||
+ 306880 Support for UPGRADE in HttpClient
|
+ 306880 Support for UPGRADE in HttpClient
|
||||||
+ 306884 Suspend with timeout <=0 never expires
|
+ 306884 Suspend with timeout <=0 never expires
|
||||||
+ 306782 httpbis interpretation of 100 continues. Body never skipped
|
+ 306782 httpbis interpretation of 100 continues. Body never skipped
|
||||||
|
+ 307589 updated servlet 3.0 continuations for final API
|
||||||
+ Take excess logging statements out of startup
|
+ Take excess logging statements out of startup
|
||||||
+ Ensure webapps with no WEB-INF don't scan WEB-INF/lib
|
+ Ensure webapps with no WEB-INF don't scan WEB-INF/lib
|
||||||
+ Allow Configuration array to be set on Server instance for all web apps
|
+ Allow Configuration array to be set on Server instance for all web apps
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package org.eclipse.jetty.continuation;
|
package org.eclipse.jetty.continuation;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.AsyncEvent;
|
import javax.servlet.AsyncEvent;
|
||||||
@ -27,7 +29,20 @@ public class Servlet3Continuation implements Continuation
|
|||||||
private final ServletRequest _request;
|
private final ServletRequest _request;
|
||||||
private ServletResponse _response;
|
private ServletResponse _response;
|
||||||
private AsyncContext _context;
|
private AsyncContext _context;
|
||||||
private final AsyncListener _listener = new AsyncListener()
|
private List<AsyncListener> _listeners=new ArrayList<AsyncListener>();
|
||||||
|
private volatile boolean _initial=true;
|
||||||
|
private volatile boolean _resumed=false;
|
||||||
|
private volatile boolean _expired=false;
|
||||||
|
private volatile boolean _responseWrapped=false;
|
||||||
|
|
||||||
|
private long _timeoutMs=-1;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public Servlet3Continuation(ServletRequest request)
|
||||||
|
{
|
||||||
|
_request=request;
|
||||||
|
|
||||||
|
_listeners.add(new AsyncListener()
|
||||||
{
|
{
|
||||||
public void onComplete(AsyncEvent event) throws IOException
|
public void onComplete(AsyncEvent event) throws IOException
|
||||||
{
|
{
|
||||||
@ -47,21 +62,13 @@ public class Servlet3Continuation implements Continuation
|
|||||||
_initial=false;
|
_initial=false;
|
||||||
event.getAsyncContext().dispatch();
|
event.getAsyncContext().dispatch();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
private volatile boolean _initial=true;
|
|
||||||
private volatile boolean _resumed=false;
|
|
||||||
private volatile boolean _expired=false;
|
|
||||||
private volatile boolean _responseWrapped=false;
|
|
||||||
|
|
||||||
public Servlet3Continuation(ServletRequest request)
|
|
||||||
{
|
|
||||||
_request=request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void addContinuationListener(final ContinuationListener listener)
|
public void addContinuationListener(final ContinuationListener listener)
|
||||||
{
|
{
|
||||||
_context.addListener(new AsyncListener()
|
AsyncListener wrapped = new AsyncListener()
|
||||||
{
|
{
|
||||||
public void onComplete(final AsyncEvent event) throws IOException
|
public void onComplete(final AsyncEvent event) throws IOException
|
||||||
{
|
{
|
||||||
@ -83,9 +90,15 @@ public class Servlet3Continuation implements Continuation
|
|||||||
_expired=true;
|
_expired=true;
|
||||||
listener.onTimeout(Servlet3Continuation.this);
|
listener.onTimeout(Servlet3Continuation.this);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (_context==null)
|
||||||
|
_context.addListener(wrapped);
|
||||||
|
else
|
||||||
|
_listeners.add(wrapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void complete()
|
public void complete()
|
||||||
{
|
{
|
||||||
AsyncContext context=_context;
|
AsyncContext context=_context;
|
||||||
@ -94,37 +107,44 @@ public class Servlet3Continuation implements Continuation
|
|||||||
_context.complete();
|
_context.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public ServletResponse getServletResponse()
|
public ServletResponse getServletResponse()
|
||||||
{
|
{
|
||||||
return _response;
|
return _response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isExpired()
|
public boolean isExpired()
|
||||||
{
|
{
|
||||||
return _expired;
|
return _expired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isInitial()
|
public boolean isInitial()
|
||||||
{
|
{
|
||||||
// TODO - this is not perfect if non continuation API is used directly
|
// TODO - this is not perfect if non continuation API is used directly
|
||||||
return _initial&&_request.getDispatcherType()!=DispatcherType.ASYNC;
|
return _initial&&_request.getDispatcherType()!=DispatcherType.ASYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isResumed()
|
public boolean isResumed()
|
||||||
{
|
{
|
||||||
return _resumed;
|
return _resumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isSuspended()
|
public boolean isSuspended()
|
||||||
{
|
{
|
||||||
return _request.isAsyncStarted();
|
return _request.isAsyncStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void keepWrappers()
|
public void keepWrappers()
|
||||||
{
|
{
|
||||||
_responseWrapped=true;
|
_responseWrapped=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void resume()
|
public void resume()
|
||||||
{
|
{
|
||||||
AsyncContext context=_context;
|
AsyncContext context=_context;
|
||||||
@ -134,11 +154,15 @@ public class Servlet3Continuation implements Continuation
|
|||||||
_context.dispatch();
|
_context.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void setTimeout(long timeoutMs)
|
public void setTimeout(long timeoutMs)
|
||||||
{
|
{
|
||||||
|
_timeoutMs=timeoutMs;
|
||||||
|
if (_context!=null)
|
||||||
_context.setTimeout(timeoutMs);
|
_context.setTimeout(timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void suspend(ServletResponse response)
|
public void suspend(ServletResponse response)
|
||||||
{
|
{
|
||||||
_response=response;
|
_response=response;
|
||||||
@ -146,17 +170,25 @@ public class Servlet3Continuation implements Continuation
|
|||||||
_resumed=false;
|
_resumed=false;
|
||||||
_expired=false;
|
_expired=false;
|
||||||
_context=_request.startAsync();
|
_context=_request.startAsync();
|
||||||
_context.addListener(_listener);
|
_context.setTimeout(_timeoutMs);
|
||||||
|
for (AsyncListener listener:_listeners)
|
||||||
|
_context.addListener(listener);
|
||||||
|
_listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public void suspend()
|
public void suspend()
|
||||||
{
|
{
|
||||||
_resumed=false;
|
_resumed=false;
|
||||||
_expired=false;
|
_expired=false;
|
||||||
_context=_request.startAsync();
|
_context=_request.startAsync();
|
||||||
_context.addListener(_listener);
|
_context.setTimeout(_timeoutMs);
|
||||||
|
for (AsyncListener listener:_listeners)
|
||||||
|
_context.addListener(listener);
|
||||||
|
_listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isResponseWrapped()
|
public boolean isResponseWrapped()
|
||||||
{
|
{
|
||||||
return _responseWrapped;
|
return _responseWrapped;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user