Mercurial Hosting > luan
diff src/org/eclipse/jetty/server/AsyncContinuation.java @ 935:aa7dc1802d29
remove ContinuationListener
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 21:15:24 -0600 |
parents | fe461f7cfc8e |
children | 237ace6e8bc2 |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java Sun Oct 09 21:03:00 2016 -0600 +++ b/src/org/eclipse/jetty/server/AsyncContinuation.java Sun Oct 09 21:15:24 2016 -0600 @@ -18,7 +18,6 @@ package org.eclipse.jetty.server; -import javax.servlet.AsyncListener; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; @@ -31,7 +30,6 @@ import javax.servlet.http.HttpServletRequest; import org.eclipse.jetty.continuation.Continuation; -import org.eclipse.jetty.continuation.ContinuationListener; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.handler.ContextHandler; @@ -44,7 +42,7 @@ /** Implementation of Continuation interfaces * */ -public class AsyncContinuation implements Continuation +public final class AsyncContinuation implements Continuation { private static final Logger LOG = LoggerFactory.getLogger(AsyncContinuation.class); @@ -70,14 +68,12 @@ /* ------------------------------------------------------------ */ protected AbstractHttpConnection _connection; - private List<AsyncListener> _asyncListeners; - private List<ContinuationListener> _continuationListeners; /* ------------------------------------------------------------ */ private int _state; private volatile long _expireAt; - protected AsyncContinuation() + AsyncContinuation() { _state=__IDLE; } @@ -87,41 +83,6 @@ _connection=connection; } - /* ------------------------------------------------------------ */ - public void addListener(AsyncListener listener) - { - synchronized(this) - { - if (_asyncListeners==null) - _asyncListeners=new ArrayList<AsyncListener>(); - _asyncListeners.add(listener); - } - } - - /* ------------------------------------------------------------ */ - public void addListener(AsyncListener listener,ServletRequest request, ServletResponse response) - { - synchronized(this) - { - // TODO handle the request/response ??? - if (_asyncListeners==null) - _asyncListeners=new ArrayList<AsyncListener>(); - _asyncListeners.add(listener); - } - } - - /* ------------------------------------------------------------ */ - public void addContinuationListener(ContinuationListener listener) - { - synchronized(this) - { - if (_continuationListeners==null) - _continuationListeners=new ArrayList<ContinuationListener>(); - _continuationListeners.add(listener); - } - } - - @Override public String toString() @@ -151,8 +112,6 @@ { case __IDLE: _state=__DISPATCHED; - if (_asyncListeners!=null) - _asyncListeners.clear(); return; default: @@ -182,81 +141,29 @@ } - /* ------------------------------------------------------------ */ - /* (non-Javadoc) - * @see javax.servlet.ServletRequest#complete() - */ - protected void doComplete(Throwable ex) + protected synchronized void doComplete(Throwable ex) { - final List<ContinuationListener> cListeners; - final List<AsyncListener> aListeners; - synchronized (this) - { - switch(_state) - { - case __UNCOMPLETED: - _state = __COMPLETED; - cListeners=_continuationListeners; - aListeners=_asyncListeners; - break; - - default: - cListeners=null; - aListeners=null; - throw new IllegalStateException(this.getStatusString()); - } - } - - if (aListeners!=null) + switch(_state) { - for (AsyncListener listener : aListeners) - { - try - { - if (ex!=null) - { - throw new UnsupportedOperationException(); - } - else - listener.onComplete(null); - } - catch(Exception e) - { - LOG.warn("",e); - } - } - } - if (cListeners!=null) - { - for (ContinuationListener listener : cListeners) - { - try - { - listener.onComplete(this); - } - catch(Exception e) - { - LOG.warn("",e); - } - } + case __UNCOMPLETED: + _state = __COMPLETED; + break; + + default: + throw new IllegalStateException(this.getStatusString()); } } - /* ------------------------------------------------------------ */ - protected void recycle() + protected synchronized void recycle() { - synchronized (this) + switch(_state) { - switch(_state) - { - case __DISPATCHED: - throw new IllegalStateException(getStatusString()); - default: - _state=__IDLE; - } - cancelTimeout(); - _continuationListeners=null; + case __DISPATCHED: + throw new IllegalStateException(getStatusString()); + default: + _state=__IDLE; } + cancelTimeout(); } /* ------------------------------------------------------------ */