diff src/org/eclipse/jetty/server/AsyncContinuation.java @ 934:fe461f7cfc8e

simplify AsyncContinuation
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 21:03:00 -0600
parents c9513d80f305
children aa7dc1802d29
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 20:25:02 2016 -0600
+++ b/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 21:03:00 2016 -0600
@@ -39,7 +39,6 @@
 import org.eclipse.jetty.util.URIUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.eclipse.jetty.util.thread.Timeout;
 
 /* ------------------------------------------------------------ */
 /** Implementation of Continuation interfaces
@@ -76,23 +75,16 @@
 
 	/* ------------------------------------------------------------ */
 	private int _state;
-	private volatile boolean _responseWrapped;
-	private long _timeoutMs=DEFAULT_TIMEOUT;
 	private volatile long _expireAt;    
 	
-	/* ------------------------------------------------------------ */
 	protected AsyncContinuation()
 	{
 		_state=__IDLE;
 	}
 
-	/* ------------------------------------------------------------ */
-	protected void setConnection(final AbstractHttpConnection connection)
+	protected synchronized void setConnection(final AbstractHttpConnection connection)
 	{
-		synchronized(this)
-		{
-			_connection=connection;
-		}
+		_connection=connection;
 	}
 
 	/* ------------------------------------------------------------ */
@@ -129,81 +121,8 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	public void setTimeout(long ms)
-	{
-		synchronized(this)
-		{
-			_timeoutMs=ms;
-		}
-	} 
 
-	/* ------------------------------------------------------------ */
-	public long getTimeout()
-	{
-		synchronized(this)
-		{
-			return _timeoutMs;
-		}
-	} 
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#keepWrappers()
-	 */
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#isResponseWrapped()
-	 */
-	public boolean isResponseWrapped()
-	{
-		return _responseWrapped;
-	}
-
-	/* ------------------------------------------------------------ */
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletRequest#isSuspended()
-	 */
-	public boolean isSuspended()
-	{
-		synchronized(this)
-		{
-			switch(_state)
-			{
-				default:
-					return false;   
-			}
-		}
-	}
 	
-	/* ------------------------------------------------------------ */
-	public boolean isSuspending()
-	{
-		synchronized(this)
-		{
-			switch(_state)
-			{
-				default:
-					return false;   
-			}
-		}
-	}
-	
-	/* ------------------------------------------------------------ */
-	public boolean isDispatchable()
-	{
-		synchronized(this)
-		{
-			switch(_state)
-			{
-				default:
-					return false;   
-			}
-		}
-	}
-
-	/* ------------------------------------------------------------ */
 	@Override
 	public String toString()
 	{
@@ -213,7 +132,6 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
 	public String getStatusString()
 	{
 		synchronized (this)
@@ -263,54 +181,7 @@
 		}
 	}
 
-	public void dispatch()
-	{
-		throw new UnsupportedOperationException();
-	}
-
-	/* ------------------------------------------------------------ */
-	protected void expired()
-	{
-	}
-	
-	/* ------------------------------------------------------------ */
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletRequest#complete()
-	 */
-	public void complete()
-	{
-		// just like resume, except don't set _resumed=true;
-		boolean dispatch=false;
-		synchronized (this)
-		{
-			switch(_state)
-			{
-				case __DISPATCHED:
-					throw new IllegalStateException(this.getStatusString());
-
-				default:
-					throw new IllegalStateException(this.getStatusString());
-			}
-		}
-	}
-	
-	/* ------------------------------------------------------------ */
-	/* (non-Javadoc)
-	 * @see javax.servlet.ServletRequest#complete()
-	 */
-	public void errorComplete()
-	{
-		// just like complete except can overrule a prior dispatch call;
-		synchronized (this)
-		{
-			switch(_state)
-			{
-				default:
-					throw new IllegalStateException(this.getStatusString());
-			}
-		}
-	}
-
+		
 	/* ------------------------------------------------------------ */
 	/* (non-Javadoc)
 	 * @see javax.servlet.ServletRequest#complete()
@@ -383,9 +254,7 @@
 				default:
 					_state=__IDLE;
 			}
-			_responseWrapped=false;
 			cancelTimeout();
-			_timeoutMs=DEFAULT_TIMEOUT;
 			_continuationListeners=null;
 		}
 	}    
@@ -407,30 +276,14 @@
 		}
 	}
 
-	boolean isUncompleted()
+	synchronized boolean isUncompleted()
 	{
-		synchronized (this)
-		{
-			return _state==__UNCOMPLETED;
-		}
+		return _state==__UNCOMPLETED;
 	} 
 	
-	public boolean isComplete()
+	public synchronized boolean isComplete()
 	{
-		synchronized (this)
-		{
-			return _state==__COMPLETED;
-		}
-	}
-
-	public void dispatch(ServletContext context, String path)
-	{
-		throw new UnsupportedOperationException();
-	}
-
-	public void dispatch(String path)
-	{
-		throw new UnsupportedOperationException();
+		return _state==__COMPLETED;
 	}
 
 	/* ------------------------------------------------------------ */
@@ -451,26 +304,6 @@
 		return _connection.getResponse();
 	}
 
-	/* ------------------------------------------------------------ */
-	public void start(final Runnable run)
-	{
-	}
-
-	/* ------------------------------------------------------------ */
-	public boolean hasOriginalRequestAndResponse()
-	{
-		synchronized (this)
-		{
-			return false;
-		}
-	}
-
-	/* ------------------------------------------------------------ */
-	public ContextHandler getContextHandler()
-	{
-		return null;
-	}
-
 
 	/* ------------------------------------------------------------ */
 	/**