Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2011-05-22 21:21:52 -0400
committerGreg Wilkins2011-05-22 21:21:52 -0400
commitb2f5416fcd923457e73a1cad3b94d6e3e7bf24ba (patch)
tree7d9668de093a817fa08249c11cfcb5b279e87aa6
parent8425cf6b5dc433f05f068d8f14d116bb0465d672 (diff)
downloadorg.eclipse.jetty.project-b2f5416fcd923457e73a1cad3b94d6e3e7bf24ba.tar.gz
org.eclipse.jetty.project-b2f5416fcd923457e73a1cad3b94d6e3e7bf24ba.tar.xz
org.eclipse.jetty.project-b2f5416fcd923457e73a1cad3b94d6e3e7bf24ba.zip
made HttpClient dumpable
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3236 7e9141cc-0065-0410-87d8-b60c137991c4
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java35
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java37
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java42
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java8
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java8
5 files changed, 78 insertions, 52 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
index fde9b3ff64..5f6154a123 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java
@@ -33,6 +33,9 @@ import org.eclipse.jetty.http.ssl.SslContextFactory;
import org.eclipse.jetty.io.Buffers.Type;
import org.eclipse.jetty.util.Attributes;
import org.eclipse.jetty.util.AttributesMap;
+import org.eclipse.jetty.util.TypeUtil;
+import org.eclipse.jetty.util.component.AggregateLifeCycle;
+import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
@@ -64,7 +67,7 @@ import org.eclipse.jetty.util.thread.Timeout;
* @see HttpExchange
* @see HttpDestination
*/
-public class HttpClient extends HttpBuffers implements Attributes
+public class HttpClient extends HttpBuffers implements Attributes, Dumpable
{
public static final int CONNECTOR_SOCKET = 0;
public static final int CONNECTOR_SELECT_CHANNEL = 2;
@@ -147,21 +150,23 @@ public class HttpClient extends HttpBuffers implements Attributes
_connectBlocking = connectBlocking;
}
- /* ------------------------------------------------------------------------------- */
- public void dump()
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump()
+ */
+ public String dump()
{
- try
- {
- for (Map.Entry<Address, HttpDestination> entry : _destinations.entrySet())
- {
- Log.info("\n" + entry.getKey() + ":");
- entry.getValue().dump();
- }
- }
- catch(Exception e)
- {
- Log.warn(e);
- }
+ return AggregateLifeCycle.dump(this);
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
+ */
+ public void dump(Appendable out, String indent) throws IOException
+ {
+ out.append(String.valueOf(this)).append("\n");
+ AggregateLifeCycle.dump(out,indent,_destinations.values());
}
/* ------------------------------------------------------------------------------- */
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
index bb076a475a..2728501775 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
@@ -17,6 +17,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
+import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.client.security.Authentication;
@@ -38,6 +39,8 @@ import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.io.nio.SslSelectChannelEndPoint;
+import org.eclipse.jetty.util.component.AggregateLifeCycle;
+import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.thread.Timeout;
@@ -45,7 +48,7 @@ import org.eclipse.jetty.util.thread.Timeout;
*
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
*/
-public class HttpConnection extends AbstractConnection
+public class HttpConnection extends AbstractConnection implements Dumpable
{
private HttpDestination _destination;
private HttpGenerator _generator;
@@ -63,16 +66,6 @@ public class HttpConnection extends AbstractConnection
private final Timeout.Task _idleTimeout = new ConnectionIdleTask();
private AtomicBoolean _idle = new AtomicBoolean(false);
- public void dump() throws IOException
- {
- // TODO update to dumpable
- Log.info("endp=" + _endp + " " + _endp.isBufferingInput() + " " + _endp.isBufferingOutput());
- Log.info("generator=" + _generator);
- Log.info("parser=" + _parser.getState() + " " + _parser.isMoreInBuffer());
- Log.info("exchange=" + _exchange);
- if (_endp instanceof SslSelectChannelEndPoint)
- ((SslSelectChannelEndPoint)_endp).dump();
- }
HttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
{
@@ -706,7 +699,29 @@ public class HttpConnection extends AbstractConnection
}
}
}
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump()
+ */
+ public String dump()
+ {
+ return AggregateLifeCycle.dump(this);
+ }
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
+ */
+ public void dump(Appendable out, String indent) throws IOException
+ {
+ synchronized (this)
+ {
+ out.append(String.valueOf(this)).append("\n");
+ AggregateLifeCycle.dump(out,indent,Collections.singletonList(_endp));
+ }
+ }
+
private class ConnectionIdleTask extends Timeout.Task
{
@Override
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
index ee3280562d..b776728523 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java
@@ -35,12 +35,14 @@ import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.util.component.AggregateLifeCycle;
+import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
/**
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
*/
-public class HttpDestination
+public class HttpDestination implements Dumpable
{
private final List<HttpExchange> _queue = new LinkedList<HttpExchange>();
private final List<HttpConnection> _connections = new LinkedList<HttpConnection>();
@@ -59,22 +61,8 @@ public class HttpDestination
private PathMap _authorizations;
private List<HttpCookie> _cookies;
- public void dump() throws IOException
- {
- synchronized (this)
- {
- Log.info(this.toString());
- Log.info("connections=" + _connections.size());
- Log.info("idle=" + _idle.size());
- Log.info("pending=" + _pendingConnections);
- for (HttpConnection c : _connections)
- {
- if (!c.isIdle())
- c.dump();
- }
- }
- }
+
HttpDestination(HttpClient client, Address address, boolean ssl)
{
_client = client;
@@ -653,6 +641,28 @@ public class HttpDestination
}
}
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump()
+ */
+ public String dump()
+ {
+ return AggregateLifeCycle.dump(this);
+ }
+
+ /* ------------------------------------------------------------ */
+ /**
+ * @see org.eclipse.jetty.util.component.Dumpable#dump(java.lang.Appendable, java.lang.String)
+ */
+ public void dump(Appendable out, String indent) throws IOException
+ {
+ synchronized (this)
+ {
+ out.append(String.valueOf(this)+"idle="+_idle.size()+" pending="+_pendingConnections).append("\n");
+ AggregateLifeCycle.dump(out,indent,_connections);
+ }
+ }
+
private class ConnectExchange extends ContentExchange
{
private final SelectConnector.ProxySelectChannelEndPoint proxyEndPoint;
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java
index e04dc4af45..eab33db960 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java
@@ -165,13 +165,6 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
_allowRenegotiate = allowRenegotiate;
}
- /* ------------------------------------------------------------ */
- // TODO get rid of these dumps
- public void dump()
- {
- Log.info(""+_result);
- }
-
/* ------------------------------------------------------------ */
@Override
@@ -195,6 +188,7 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint
super.shutdownOutput();
}
+ /* ------------------------------------------------------------ */
protected void sslClose() throws IOException
{
if (_closing)
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
index df137d885b..cdfe353cb7 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
@@ -259,7 +259,7 @@ public class ServletHandler extends ScopedHandler
*/
public RequestDispatcher getRequestDispatcher(String uriInContext)
{
- if (uriInContext == null)
+ if (uriInContext == null || _contextHandler==null)
return null;
if (!uriInContext.startsWith("/"))
@@ -1464,13 +1464,15 @@ public class ServletHandler extends ScopedHandler
/* ------------------------------------------------------------ */
void destroyServlet(Servlet servlet)
{
- _contextHandler.destroyServlet(servlet);
+ if (_contextHandler!=null)
+ _contextHandler.destroyServlet(servlet);
}
/* ------------------------------------------------------------ */
void destroyFilter(Filter filter)
{
- _contextHandler.destroyFilter(filter);
+ if (_contextHandler!=null)
+ _contextHandler.destroyFilter(filter);
}
/* ------------------------------------------------------------ */

Back to the top