changeset 936:237ace6e8bc2

simplify AsyncContinuation
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 21:35:26 -0600
parents aa7dc1802d29
children 0541b6034003
files src/org/eclipse/jetty/continuation/Continuation.java src/org/eclipse/jetty/server/AsyncContinuation.java
diffstat 2 files changed, 15 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
diff -r aa7dc1802d29 -r 237ace6e8bc2 src/org/eclipse/jetty/continuation/Continuation.java
--- a/src/org/eclipse/jetty/continuation/Continuation.java	Sun Oct 09 21:15:24 2016 -0600
+++ b/src/org/eclipse/jetty/continuation/Continuation.java	Sun Oct 09 21:35:26 2016 -0600
@@ -360,7 +360,7 @@
 	 * Get the suspended response.
 	 * @return the {@link ServletResponse} passed to {@link #suspend(ServletResponse)}.
 	 */
-	ServletResponse getServletResponse();
+//	ServletResponse getServletResponse();
 	
 	/* ------------------------------------------------------------ */
 	/** 
@@ -378,7 +378,7 @@
 	 * @param name the attribute name
 	 * @param attribute the attribute value
 	 */
-	public void setAttribute(String name, Object attribute);
+//	public void setAttribute(String name, Object attribute);
 	
 	/* ------------------------------------------------------------ */
 	/** Get a request attribute.
@@ -388,7 +388,7 @@
 	 * @param name the attribute name
 	 * @return the attribute value
 	 */
-	public Object getAttribute(String name);
+//	public Object getAttribute(String name);
 	
 	/* ------------------------------------------------------------ */
 	/** Remove a request attribute.
@@ -397,7 +397,7 @@
 	 * This is a thread safe call and may be called by any thread.
 	 * @param name the attribute name
 	 */
-	public void removeAttribute(String name);
+//	public void removeAttribute(String name);
 	
 	/* ------------------------------------------------------------ */
 	/**
diff -r aa7dc1802d29 -r 237ace6e8bc2 src/org/eclipse/jetty/server/AsyncContinuation.java
--- a/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 21:15:24 2016 -0600
+++ b/src/org/eclipse/jetty/server/AsyncContinuation.java	Sun Oct 09 21:35:26 2016 -0600
@@ -18,26 +18,12 @@
 
 package org.eclipse.jetty.server;
 
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
 import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.io.AsyncEndPoint;
 import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.server.handler.ContextHandler.Context;
-import org.eclipse.jetty.util.URIUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /* ------------------------------------------------------------ */
 /** Implementation of Continuation interfaces
  * 
@@ -71,7 +57,6 @@
 
 	/* ------------------------------------------------------------ */
 	private int _state;
-	private volatile long _expireAt;    
 	
 	AsyncContinuation()
 	{
@@ -85,25 +70,19 @@
 
 	
 	@Override
-	public String toString()
+	public synchronized String toString()
 	{
-		synchronized (this)
-		{
-			return super.toString()+"@"+getStatusString();
-		}
+		return super.toString()+"@"+getStatusString();
 	}
 
-	public String getStatusString()
+	private synchronized String getStatusString()
 	{
-		synchronized (this)
-		{
-			return
-			((_state==__IDLE)?"IDLE":
-				(_state==__DISPATCHED)?"DISPATCHED":
-											(_state==__UNCOMPLETED)?"UNCOMPLETED":
-												(_state==__COMPLETED)?"COMPLETE":
-													("UNKNOWN?"+_state));
-		}
+		return
+		((_state==__IDLE)?"IDLE":
+			(_state==__DISPATCHED)?"DISPATCHED":
+										(_state==__UNCOMPLETED)?"UNCOMPLETED":
+											(_state==__COMPLETED)?"COMPLETE":
+												("UNKNOWN?"+_state));
 	}
 
 	protected synchronized void handling()
@@ -166,86 +145,20 @@
 		cancelTimeout();
 	}    
 	
-	/* ------------------------------------------------------------ */
-	protected void cancelTimeout()
+	private void cancelTimeout()
 	{
 		EndPoint endp=_connection.getEndPoint();
 		if (endp.isBlocking())
 		{
 			synchronized(this)
 			{
-				_expireAt=0;
 				this.notifyAll();
 			}
 		}
-		else 
-		{
-		}
 	}
 
 	synchronized boolean isUncompleted()
 	{
 		return _state==__UNCOMPLETED;
 	} 
-	
-	public synchronized boolean isComplete()
-	{
-		return _state==__COMPLETED;
-	}
-
-	/* ------------------------------------------------------------ */
-	public Request getBaseRequest()
-	{
-		return _connection.getRequest();
-	}
-	
-	/* ------------------------------------------------------------ */
-	public ServletRequest getRequest()
-	{
-		return _connection.getRequest();
-	}
-
-	/* ------------------------------------------------------------ */
-	public ServletResponse getResponse()
-	{
-		return _connection.getResponse();
-	}
-
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#getServletResponse()
-	 */
-	public ServletResponse getServletResponse()
-	{
-		return _connection.getResponse();
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String)
-	 */
-	public Object getAttribute(String name)
-	{
-		return _connection.getRequest().getAttribute(name);
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String)
-	 */
-	public void removeAttribute(String name)
-	{
-		_connection.getRequest().removeAttribute(name);
-	}
-
-	/* ------------------------------------------------------------ */
-	/**
-	 * @see org.eclipse.jetty.continuation.Continuation#setAttribute(java.lang.String, java.lang.Object)
-	 */
-	public void setAttribute(String name, Object attribute)
-	{
-		_connection.getRequest().setAttribute(name,attribute);
-	}
-
 }