changeset 935:aa7dc1802d29

remove ContinuationListener
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 21:15:24 -0600
parents fe461f7cfc8e
children 237ace6e8bc2
files src/org/eclipse/jetty/continuation/Continuation.java src/org/eclipse/jetty/continuation/ContinuationListener.java src/org/eclipse/jetty/server/AsyncContinuation.java src/org/eclipse/jetty/server/Request.java src/org/eclipse/jetty/server/handler/GzipHandler.java
diffstat 5 files changed, 18 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
diff -r fe461f7cfc8e -r aa7dc1802d29 src/org/eclipse/jetty/continuation/Continuation.java
--- a/src/org/eclipse/jetty/continuation/Continuation.java	Sun Oct 09 21:03:00 2016 -0600
+++ b/src/org/eclipse/jetty/continuation/Continuation.java	Sun Oct 09 21:15:24 2016 -0600
@@ -368,7 +368,7 @@
 	 * 
 	 * @param listener
 	 */
-	void addContinuationListener(ContinuationListener listener);
+//	void addContinuationListener(ContinuationListener listener);
 	
 	/* ------------------------------------------------------------ */
 	/** Set a request attribute.
diff -r fe461f7cfc8e -r aa7dc1802d29 src/org/eclipse/jetty/continuation/ContinuationListener.java
--- a/src/org/eclipse/jetty/continuation/ContinuationListener.java	Sun Oct 09 21:03:00 2016 -0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-//
-//  ========================================================================
-//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-//  ------------------------------------------------------------------------
-//  All rights reserved. This program and the accompanying materials
-//  are made available under the terms of the Eclipse Public License v1.0
-//  and Apache License v2.0 which accompanies this distribution.
-//
-//      The Eclipse Public License is available at
-//      http://www.eclipse.org/legal/epl-v10.html
-//
-//      The Apache License v2.0 is available at
-//      http://www.opensource.org/licenses/apache2.0.php
-//
-//  You may elect to redistribute this code under either of these licenses.
-//  ========================================================================
-//
-
-package org.eclipse.jetty.continuation;
-
-import java.util.EventListener;
-
-import javax.servlet.ServletRequestListener;
-
-
-/* ------------------------------------------------------------ */
-/** A Continuation Listener
- * <p>
- * A ContinuationListener may be registered with a call to
- * {@link Continuation#addContinuationListener(ContinuationListener)}.
- * 
- */
-public interface ContinuationListener extends EventListener 
-{    
-    /* ------------------------------------------------------------ */
-    /**
-     * Called when a continuation life cycle is complete and after
-     * any calls to {@link ServletRequestListener#requestDestroyed(javax.servlet.ServletRequestEvent)}
-     * The response may still be written to during the call.
-     * 
-     * @param continuation
-     */
-    public void onComplete(Continuation continuation);
-    
-    /* ------------------------------------------------------------ */
-    /**
-     * Called when a suspended continuation has timed out.
-     * The response may be written to and the methods 
-     * {@link Continuation#resume()} or {@link Continuation#complete()} 
-     * may be called by a onTimeout implementation,
-     * @param continuation
-     */
-    public void onTimeout(Continuation continuation);
-
-}
diff -r fe461f7cfc8e -r aa7dc1802d29 src/org/eclipse/jetty/server/AsyncContinuation.java
--- 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();
 	}    
 	
 	/* ------------------------------------------------------------ */
diff -r fe461f7cfc8e -r aa7dc1802d29 src/org/eclipse/jetty/server/Request.java
--- a/src/org/eclipse/jetty/server/Request.java	Sun Oct 09 21:03:00 2016 -0600
+++ b/src/org/eclipse/jetty/server/Request.java	Sun Oct 09 21:15:24 2016 -0600
@@ -63,7 +63,6 @@
 import javax.servlet.http.Part;
 
 import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
 import org.eclipse.jetty.http.HttpCookie;
 import org.eclipse.jetty.http.HttpFields;
 import org.eclipse.jetty.http.HttpHeaders;
@@ -197,8 +196,6 @@
 	{
 		if (listener instanceof ServletRequestAttributeListener)
 			_requestAttributeListeners = LazyList.add(_requestAttributeListeners,listener);
-		if (listener instanceof ContinuationListener)
-			throw new IllegalArgumentException(listener.getClass().toString());
 		if (listener instanceof AsyncListener)
 			throw new IllegalArgumentException(listener.getClass().toString());
 	}
diff -r fe461f7cfc8e -r aa7dc1802d29 src/org/eclipse/jetty/server/handler/GzipHandler.java
--- a/src/org/eclipse/jetty/server/handler/GzipHandler.java	Sun Oct 09 21:03:00 2016 -0600
+++ b/src/org/eclipse/jetty/server/handler/GzipHandler.java	Sun Oct 09 21:15:24 2016 -0600
@@ -34,7 +34,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationListener;
 import org.eclipse.jetty.http.HttpMethods;
 import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
 import org.eclipse.jetty.http.gzip.AbstractCompressedStream;