From 7ebc5c380bd2158ae533fe40d56e4972086d3446 Mon Sep 17 00:00:00 2001
From: Greg Wilkins
Date: Wed, 30 Mar 2011 03:43:33 +0000
Subject: [PATCH] 337685 use abstract connector. more debugging output
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2927 7e9141cc-0065-0410-87d8-b60c137991c4
---
.../org/eclipse/jetty/ajp/Ajp13Generator.java | 2 +-
.../jetty/server/AbstractConnector.java | 3 ++-
.../org/eclipse/jetty/server/Dispatcher.java | 2 +-
.../eclipse/jetty/server/HttpConnection.java | 22 ++++---------------
.../util/component/AbstractLifeCycle.java | 9 ++++++++
5 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java
index ce2efa1bc8e..da3299414f8 100644
--- a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java
+++ b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java
@@ -92,7 +92,7 @@ public class Ajp13Generator extends AbstractGenerator
private static final byte[] AJP13_MORE_CONTENT =
{ 'A', 'B', 0, 3, 6, 31, -7 };
- private static String SERVER = "Server: Jetty(6.0.x)";
+ private static String SERVER = "Server: Jetty(7.x.x)";
public static void setServerVersion(String version)
{
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
index 88abda75f0f..11476e528d2 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
@@ -28,6 +28,7 @@ import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.LifeCycle;
@@ -746,7 +747,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
if (dot > 0)
name = name.substring(dot + 1);
- return name + "@" + (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
+ return name + "@" + (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort()) + " "+AbstractLifeCycle.getState(this);
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
index 355b39af8ce..355fc46adaa 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
@@ -283,7 +283,7 @@ public class Dispatcher implements RequestDispatcher
_contextHandler.handle(_path,baseRequest, (HttpServletRequest)request, (HttpServletResponse)response);
- if (baseRequest.getConnection().getResponse().isWriting())
+ if (baseRequest.getResponse().isWriting())
{
try {response.getWriter().close();}
catch(IllegalStateException e)
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
index 77a6fe55851..468e9b521d0 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
@@ -39,6 +39,7 @@ import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersions;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.Parser;
+import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
@@ -87,7 +88,7 @@ import org.eclipse.jetty.util.thread.Timeout;
*
*
*/
-public class HttpConnection /* TODO extends AbstractConnection*/ implements Connection
+public class HttpConnection extends AbstractConnection implements Connection
{
private static final int UNKNOWN = -2;
private static final ThreadLocal __currentConnection = new ThreadLocal();
@@ -142,9 +143,7 @@ public class HttpConnection /* TODO extends AbstractConnection*/ implements Conn
*/
public HttpConnection(Connector connector, EndPoint endpoint, Server server)
{
- _endp=endpoint;
- _timeStamp = System.currentTimeMillis();
-
+ super(endpoint);
_uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
_connector = connector;
HttpBuffers ab = (HttpBuffers)_connector;
@@ -162,8 +161,7 @@ public class HttpConnection /* TODO extends AbstractConnection*/ implements Conn
protected HttpConnection(Connector connector, EndPoint endpoint, Server server,
Parser parser, Generator generator, Request request)
{
- _endp=endpoint;
- _timeStamp = System.currentTimeMillis();
+ super(endpoint);
_uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
_connector = connector;
@@ -1282,16 +1280,4 @@ public class HttpConnection /* TODO extends AbstractConnection*/ implements Conn
}
-
- // TODO remove and use AbstractConnection for 7.4
- private final long _timeStamp;
- protected final EndPoint _endp;
- public long getTimeStamp()
- {
- return _timeStamp;
- }
- public EndPoint getEndPoint()
- {
- return _endp;
- }
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java
index e973fcd7908..60196273292 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/AbstractLifeCycle.java
@@ -145,6 +145,15 @@ public abstract class AbstractLifeCycle implements LifeCycle
}
return null;
}
+
+ public static String getState(LifeCycle lc)
+ {
+ if (lc.isStarting()) return STARTING;
+ if (lc.isStarted()) return STARTED;
+ if (lc.isStopping()) return STOPPING;
+ if (lc.isStopped()) return STOPPED;
+ return FAILED;
+ }
private void setStarted()
{