rolled back the API changes for 7.3.1, will redo for 7.4.0

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2846 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-03-02 12:21:12 +00:00
parent d77069a8ea
commit d0b4ddcb28
9 changed files with 88 additions and 16 deletions

View File

@ -45,7 +45,7 @@ import org.eclipse.jetty.util.thread.Timeout;
* *
* @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $ * @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
*/ */
public class HttpConnection extends AbstractConnection implements Connection public class HttpConnection /* extends AbstractConnection */ implements Connection
{ {
private HttpDestination _destination; private HttpDestination _destination;
private HttpGenerator _generator; private HttpGenerator _generator;
@ -76,7 +76,9 @@ public class HttpConnection extends AbstractConnection implements Connection
HttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp) HttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
{ {
super(endp); _endp=endp;
_timeStamp = System.currentTimeMillis();
_generator = new HttpGenerator(requestBuffers,endp); _generator = new HttpGenerator(requestBuffers,endp);
_parser = new HttpParser(responseBuffers,endp,new Handler()); _parser = new HttpParser(responseBuffers,endp,new Handler());
} }
@ -709,4 +711,18 @@ public class HttpConnection extends AbstractConnection implements Connection
} }
} }
} }
// 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;
}
} }

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
@ -313,7 +314,7 @@ public class HttpDestination
public void onNewConnection(final HttpConnection connection) throws IOException public void onNewConnection(final HttpConnection connection) throws IOException
{ {
AbstractConnection q_connection = null; Connection q_connection = null;
synchronized (this) synchronized (this)
{ {

View File

@ -691,9 +691,9 @@ public class HttpExchange
return this._connection != null; return this._connection != null;
} }
AbstractConnection disassociate() Connection disassociate()
{ {
AbstractConnection result = _connection; Connection result = _connection;
this._connection = null; this._connection = null;
if (getStatus() == STATUS_CANCELLING) if (getStatus() == STATUS_CANCELLING)
setStatus(STATUS_CANCELLED); setStatus(STATUS_CANCELLED);

View File

@ -33,6 +33,7 @@ import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.nio.DirectNIOBuffer; import org.eclipse.jetty.io.nio.DirectNIOBuffer;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
@ -474,7 +475,7 @@ public class HttpExchangeTest extends TestCase
//try to get a connection, and only wait 500ms, as we have //try to get a connection, and only wait 500ms, as we have
//already reserved the max, should return null //already reserved the max, should return null
AbstractConnection c = destination.reserveConnection(500); Connection c = destination.reserveConnection(500);
assertNull(c); assertNull(c);
//unreserve first connection //unreserve first connection

View File

@ -5,7 +5,7 @@ import java.io.IOException;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
public abstract class AbstractConnection implements Connection public abstract class AbstractConnection implements Connection, Idleable
{ {
private final long _timeStamp; private final long _timeStamp;
protected final EndPoint _endp; protected final EndPoint _endp;

View File

@ -44,12 +44,8 @@ public interface Connection
long getTimeStamp(); long getTimeStamp();
boolean isIdle(); boolean isIdle();
boolean isSuspended(); boolean isSuspended();
/**
* Called when the connection idle timeout expires
*/
void idleExpired();
/** /**
* Called when the connection is closed * Called when the connection is closed

View File

@ -0,0 +1,28 @@
// ========================================================================
// Copyright (c) 2006-2009 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.io;
import java.io.IOException;
/* ------------------------------------------------------------ */
/** Idleable.
* @deprecated Merge this into Connection at the next point release
*/
public interface Idleable
{
/**
* Called when the connection idle timeout expires
*/
void idleExpired();
}

View File

@ -24,6 +24,7 @@ import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ConnectedEndPoint; import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.Idleable;
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet; import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
@ -248,7 +249,19 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
protected void idleExpired() protected void idleExpired()
{ {
_connection.idleExpired(); if (_connection instanceof Idleable)
((Idleable)_connection).idleExpired();
else
{
try
{
close();
}
catch(IOException e)
{
Log.ignore(e);
}
}
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */

View File

@ -87,7 +87,7 @@ import org.eclipse.jetty.util.thread.Timeout;
* </p> * </p>
* *
*/ */
public class HttpConnection extends AbstractConnection implements Connection public class HttpConnection /* TODO extends AbstractConnection*/ implements Connection
{ {
private static final int UNKNOWN = -2; private static final int UNKNOWN = -2;
private static final ThreadLocal<HttpConnection> __currentConnection = new ThreadLocal<HttpConnection>(); private static final ThreadLocal<HttpConnection> __currentConnection = new ThreadLocal<HttpConnection>();
@ -142,7 +142,9 @@ public class HttpConnection extends AbstractConnection implements Connection
*/ */
public HttpConnection(Connector connector, EndPoint endpoint, Server server) public HttpConnection(Connector connector, EndPoint endpoint, Server server)
{ {
super(endpoint); _endp=endpoint;
_timeStamp = System.currentTimeMillis();
_uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); _uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
_connector = connector; _connector = connector;
HttpBuffers ab = (HttpBuffers)_connector; HttpBuffers ab = (HttpBuffers)_connector;
@ -160,7 +162,9 @@ public class HttpConnection extends AbstractConnection implements Connection
protected HttpConnection(Connector connector, EndPoint endpoint, Server server, protected HttpConnection(Connector connector, EndPoint endpoint, Server server,
Parser parser, Generator generator, Request request) Parser parser, Generator generator, Request request)
{ {
super(endpoint); _endp=endpoint;
_timeStamp = System.currentTimeMillis();
_uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); _uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
_connector = connector; _connector = connector;
_parser = parser; _parser = parser;
@ -1267,4 +1271,17 @@ public class HttpConnection extends AbstractConnection implements Connection
} }
} }
// 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;
}
} }