diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java similarity index 87% rename from jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java rename to jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index 3fc4981137e..2479e7cb5c7 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractAsyncConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -23,26 +23,26 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; /** - *
A convenience base implementation of {@link AsyncConnection}.
- *This class uses the capabilities of the {@link AsyncEndPoint} API to provide a + *
A convenience base implementation of {@link Connection}.
+ *This class uses the capabilities of the {@link EndPoint} API to provide a * more traditional style of async reading. A call to {@link #fillInterested()} * will schedule a callback to {@link #onFillable()} or {@link #onFillInterestedFailed(Throwable)} * as appropriate.
*/ -public abstract class AbstractAsyncConnection implements AsyncConnection +public abstract class AbstractConnection implements Connection { - private static final Logger LOG = Log.getLogger(AbstractAsyncConnection.class); + private static final Logger LOG = Log.getLogger(AbstractConnection.class); private final AtomicBoolean _readInterested = new AtomicBoolean(); - private final AsyncEndPoint _endp; + private final EndPoint _endp; private final Callback{@link AsyncEndPoint} add asynchronous scheduling methods to {@link EndPoint}.
- *The design of these has been influenced by NIO.2 Futures and Completion - * handlers, but does not use those actual interfaces because they have - * some inefficiencies.
- *This class will frequently be used in conjunction with some of the utility - * implementations of {@link Callback}, such as {@link FutureCallback} and - * {@link ExecutorCallback}. Examples are:
- * - *A FutureCallback can be used to block until an endpoint is ready to be filled - * from: - *
- * - *- * FutureCallback<String> future = new FutureCallback<>(); - * endpoint.fillInterested("ContextObj",future); - * ... - * String context = future.get(); // This blocks - * int filled=endpoint.fill(mybuffer); - *
By using a different callback, the read can be done asynchronously in its own dispatched thread: - *
- *- * endpoint.fillInterested("ContextObj",new ExecutorCallback<String>(executor) - * { - * public void onCompleted(String context) - * { - * int filled=endpoint.fill(mybuffer); - * ... - * } - * public void onFailed(String context,Throwable cause) {...} - * }); - *
The executor callback can also be customized to not dispatch in some circumstances when - * it knows it can use the callback thread and does not need to dispatch.
- * - *The write contract is that the callback complete is not called until all data has been - * written or there is a failure. For blocking this looks like: - *
- * - *- * FutureCallback<String> future = new FutureCallback<>(); - * endpoint.write("ContextObj",future,headerBuffer,contentBuffer); - * String context = future.get(); // This blocks - *
Note also that multiple buffers may be passed in write so that gather writes - * can be done: - *
- */ -public interface AsyncEndPoint extends EndPoint -{ - /** - *- * endpoint.write("ContextObj",new ExecutorCallback<String>(executor) - * { - * public void onCompleted(String context) - * { - * int filled=endpoint.fill(mybuffer); - * ... - * } - * public void onFailed(String context,Throwable cause) {...} - * },headerBuffer,contentBuffer); - *
Requests callback methods to be invoked when a call to {@link #fill(ByteBuffer)} would return data or EOF.
- * - * @param context the context to return via the callback - * @param callback the callback to call when an error occurs or we are readable. - * @throws ReadPendingException if another read operation is concurrent. - */ -Writes the given buffers via {@link #flush(ByteBuffer...)} and invokes callback methods when either - * all the data has been flushed or an error occurs.
- * - * @param context the context to return via the callback - * @param callback the callback to call when an error occurs or the write completed. - * @param buffers one or more {@link ByteBuffer}s that will be flushed. - * @throws WritePendingException if another write operation is concurrent. - */ -Callback method invoked when this {@link AsyncEndPoint} is opened.
- * @see #onClose() - */ - void onOpen(); - - /** - *Callback method invoked when this {@link AsyncEndPoint} is close.
- * @see #onOpen() - */ - void onClose(); -} diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java index b942f9e7b41..09584d8d583 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ByteArrayEndPoint.java @@ -16,9 +16,16 @@ package org.eclipse.jetty.io; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.nio.charset.Charset; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jetty.util.BufferUtil; +import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.StringUtil; @@ -30,12 +37,35 @@ public class ByteArrayEndPoint extends AbstractEndPoint { public final static InetSocketAddress NOIP=new InetSocketAddress(0); + private final AtomicReferenceAn {@link AsyncConnection} is associated to an {@link AsyncEndPoint} so that I/O events - * happening on the {@link AsyncEndPoint} can be processed by the {@link AsyncConnection}.
- *A typical implementation of {@link AsyncConnection} overrides {@link #onOpen()} to - * {@link AsyncEndPoint#fillInterested(Object, Callback) set read interest} on the {@link AsyncEndPoint}, - * and when the {@link AsyncEndPoint} signals read readyness, this {@link AsyncConnection} can + *
An {@link Connection} is associated to an {@link EndPoint} so that I/O events + * happening on the {@link EndPoint} can be processed by the {@link Connection}.
+ *A typical implementation of {@link Connection} overrides {@link #onOpen()} to + * {@link EndPoint#fillInterested(Object, Callback) set read interest} on the {@link EndPoint}, + * and when the {@link EndPoint} signals read readyness, this {@link Connection} can * read bytes from the network and interpret them.
*/ -public interface AsyncConnection +public interface Connection { /** - *Callback method invoked when this {@link AsyncConnection} is opened.
+ *Callback method invoked when this {@link Connection} is opened.
*/ void onOpen(); /** - *Callback method invoked when this {@link AsyncConnection} is closed.
+ *Callback method invoked when this {@link Connection} is closed.
*/ void onClose(); /** - * @return the {@link AsyncEndPoint} associated with this {@link AsyncConnection} + * @return the {@link EndPoint} associated with this {@link Connection} */ - AsyncEndPoint getEndPoint(); + EndPoint getEndPoint(); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java index 80713e07e28..8f28d260263 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java @@ -17,12 +17,78 @@ import java.io.Closeable; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.nio.channels.ReadPendingException; +import java.nio.channels.WritePendingException; + +import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.ExecutorCallback; +import org.eclipse.jetty.util.FutureCallback; /** * * A transport EndPoint + * + *The asynchronous scheduling methods of {@link EndPoint} + * has been influenced by NIO.2 Futures and Completion + * handlers, but does not use those actual interfaces because they have + * some inefficiencies.
+ *This class will frequently be used in conjunction with some of the utility + * implementations of {@link Callback}, such as {@link FutureCallback} and + * {@link ExecutorCallback}. Examples are:
+ * + *A FutureCallback can be used to block until an endpoint is ready to be filled + * from: + *
+ * + *+ * FutureCallback<String> future = new FutureCallback<>(); + * endpoint.fillInterested("ContextObj",future); + * ... + * String context = future.get(); // This blocks + * int filled=endpoint.fill(mybuffer); + *
By using a different callback, the read can be done asynchronously in its own dispatched thread: + *
+ *+ * endpoint.fillInterested("ContextObj",new ExecutorCallback<String>(executor) + * { + * public void onCompleted(String context) + * { + * int filled=endpoint.fill(mybuffer); + * ... + * } + * public void onFailed(String context,Throwable cause) {...} + * }); + *
The executor callback can also be customized to not dispatch in some circumstances when + * it knows it can use the callback thread and does not need to dispatch.
+ * + *The write contract is that the callback complete is not called until all data has been + * written or there is a failure. For blocking this looks like: + *
+ * + *+ * FutureCallback<String> future = new FutureCallback<>(); + * endpoint.write("ContextObj",future,headerBuffer,contentBuffer); + * String context = future.get(); // This blocks + *
Note also that multiple buffers may be passed in write so that gather writes + * can be done: + *
*/ public interface EndPoint extends Closeable { @@ -126,5 +192,48 @@ public interface EndPoint extends Closeable void setIdleTimeout(long idleTimeout); + /** + *+ * endpoint.write("ContextObj",new ExecutorCallback<String>(executor) + * { + * public void onCompleted(String context) + * { + * int filled=endpoint.fill(mybuffer); + * ... + * } + * public void onFailed(String context,Throwable cause) {...} + * },headerBuffer,contentBuffer); + *
Requests callback methods to be invoked when a call to {@link #fill(ByteBuffer)} would return data or EOF.
+ * + * @param context the context to return via the callback + * @param callback the callback to call when an error occurs or we are readable. + * @throws ReadPendingException if another read operation is concurrent. + */ +Writes the given buffers via {@link #flush(ByteBuffer...)} and invokes callback methods when either + * all the data has been flushed or an error occurs.
+ * + * @param context the context to return via the callback + * @param callback the callback to call when an error occurs or the write completed. + * @param buffers one or more {@link ByteBuffer}s that will be flushed. + * @throws WritePendingException if another write operation is concurrent. + */ +Callback method invoked when this {@link EndPoint} is opened.
+ * @see #onClose() + */ + void onOpen(); + + /** + *Callback method invoked when this {@link EndPoint} is close.
+ * @see #onOpen() + */ + void onClose(); } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ReadInterest.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ReadInterest.java index d2897543b4b..c7edac3181e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ReadInterest.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ReadInterest.java @@ -10,7 +10,7 @@ import org.eclipse.jetty.util.Callback; /* ------------------------------------------------------------ */ /** - * A Utility class to help implement {@link AsyncEndPoint#fillInterested(Object, Callback)} + * A Utility class to help implement {@link EndPoint#fillInterested(Object, Callback)} * by keeping state and calling the context and callback objects. * */ diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java index f3731633d95..96944afa9d8 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java @@ -32,7 +32,7 @@ import org.eclipse.jetty.util.log.Logger; /** * An ChannelEndpoint that can be scheduled by {@link SelectorManager}. */ -public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, SelectorManager.SelectableAsyncEndPoint +public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorManager.SelectableEndPoint { public static final Logger LOG = Log.getLogger(SelectChannelEndPoint.class); @@ -45,8 +45,38 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, checkIdleTimeout(); } }; + + + private final Runnable _updateTask = new Runnable() + { + @Override + public void run() + { + try + { + if (getChannel().isOpen()) + { + int oldInterestOps = _key.interestOps(); + int newInterestOps = _interestOps; + if (newInterestOps != oldInterestOps) + setKeyInterests(oldInterestOps, newInterestOps); + } + } + catch (CancelledKeyException x) + { + LOG.debug("Ignoring key update for concurrently closed channel {}", this); + close(); + } + catch (Exception x) + { + LOG.warn("Ignoring key update for " + this, x); + close(); + } + } + }; + /** - * true if {@link ManagedSelector#destroyEndPoint(AsyncEndPoint)} has not been called + * true if {@link ManagedSelector#destroyEndPoint(EndPoint)} has not been called */ private final AtomicBoolean _open = new AtomicBoolean(); private final ReadInterest _readInterest = new ReadInterest() @@ -68,7 +98,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, private final SelectorManager.ManagedSelector _selector; private final SelectionKey _key; private final ScheduledExecutorService _scheduler; - private volatile AsyncConnection _connection; /** * The desired value for {@link SelectionKey#interestOps()} */ @@ -131,16 +160,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, } @Override - public AsyncConnection getAsyncConnection() + public void setConnection(Connection connection) { - return _connection; - } - - @Override - public void setAsyncConnection(AsyncConnection connection) - { - AsyncConnection old = getAsyncConnection(); - _connection = connection; + // TODO should this be on AbstractEndPoint? + Connection old = getConnection(); + super.setConnection(connection); if (old != null && old != connection) _selector.getSelectorManager().connectionUpgraded(this, old); } @@ -210,7 +234,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, { _interestOps = newInterestOps; LOG.debug("Local interests updated {} -> {} for {}", oldInterestOps, newInterestOps, this); - _selector.submit(this); + _selector.submit(_updateTask); } else { @@ -218,30 +242,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, } } - @Override - public void run() - { - try - { - if (getChannel().isOpen()) - { - int oldInterestOps = _key.interestOps(); - int newInterestOps = _interestOps; - if (newInterestOps != oldInterestOps) - setKeyInterests(oldInterestOps, newInterestOps); - } - } - catch (CancelledKeyException x) - { - LOG.debug("Ignoring key update for concurrently closed channel {}", this); - close(); - } - catch (Exception x) - { - LOG.warn("Ignoring key update for " + this, x); - close(); - } - } private void setKeyInterests(int oldInterestOps, int newInterestOps) { @@ -260,12 +260,14 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, @Override public void onOpen() { + super.onOpen(); _open.compareAndSet(false, true); } @Override public void onClose() { + super.onClose(); _writeFlusher.close(); _readInterest.close(); } @@ -290,6 +292,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, } return String.format("SCEP@%x{l(%s)<->r(%s),open=%b,ishut=%b,oshut=%b,i=%d%s,r=%s,w=%s}-{%s}", hashCode(), getRemoteAddress(), getLocalAddress(), isOpen(), isInputShutdown(), - isOutputShutdown(), _interestOps, keyString, _readInterest, _writeFlusher, getAsyncConnection()); + isOutputShutdown(), _interestOps, keyString, _readInterest, _writeFlusher, getConnection()); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java index ead6868333a..9287bfab176 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectorManager.java @@ -44,7 +44,7 @@ import org.eclipse.jetty.util.log.Logger; *{@link SelectorManager} manages a number of {@link ManagedSelector}s that * simplify the non-blocking primitives provided by the JVM via the {@code java.nio} package.
*{@link SelectorManager} subclasses implement methods to return protocol-specific - * {@link AsyncEndPoint}s and {@link AsyncConnection}s.
+ * {@link EndPoint}s and {@link Connection}s. */ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable { @@ -152,7 +152,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * * @param endpoint the endpoint being opened */ - protected void endPointOpened(AsyncEndPoint endpoint) + protected void endPointOpened(EndPoint endpoint) { endpoint.onOpen(); } @@ -162,7 +162,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * * @param endpoint the endpoint being closed */ - protected void endPointClosed(AsyncEndPoint endpoint) + protected void endPointClosed(EndPoint endpoint) { endpoint.onClose(); } @@ -172,7 +172,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * * @param connection the connection just opened */ - public void connectionOpened(AsyncConnection connection) + public void connectionOpened(Connection connection) { connection.onOpen(); } @@ -182,7 +182,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * * @param connection the connection just closed */ - public void connectionClosed(AsyncConnection connection) + public void connectionClosed(Connection connection) { connection.onClose(); } @@ -193,10 +193,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * @param endpoint the endpoint holding the new connection * @param oldConnection the previous connection */ - public void connectionUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection) + public void connectionUpgraded(EndPoint endpoint, Connection oldConnection) { connectionClosed(oldConnection); - connectionOpened(endpoint.getAsyncConnection()); + connectionOpened(endpoint.getConnection()); } /** @@ -213,7 +213,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } /** - *Factory method to create {@link AsyncEndPoint}.
+ *Factory method to create {@link EndPoint}.
*This method is invoked as a result of the registration of a channel via {@link #connect(SocketChannel, Object)} * or {@link #accept(SocketChannel)}.
* @@ -222,12 +222,12 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * @param selectionKey the selection key * @return a new endpoint * @throws IOException if the endPoint cannot be created - * @see #newConnection(SocketChannel, AsyncEndPoint, Object) + * @see #newConnection(SocketChannel, EndPoint, Object) */ - protected abstract AsyncEndPoint newEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selector, SelectionKey selectionKey) throws IOException; + protected abstract EndPoint newEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selector, SelectionKey selectionKey) throws IOException; /** - *Factory method to create {@link AsyncConnection}.
+ *Factory method to create {@link Connection}.
* * @param channel the channel associated to the connection * @param endpoint the endpoint @@ -236,7 +236,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa * @throws IOException * @see #newEndPoint(SocketChannel, ManagedSelector, SelectionKey) */ - public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) throws IOException; + public abstract Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException; @Override public String dump() @@ -254,7 +254,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa /** *{@link ManagedSelector} wraps a {@link Selector} simplifying non-blocking operations on channels.
*{@link ManagedSelector} runs the select loop, which waits on {@link Selector#select()} until events - * happen for registered channels. When events happen, it notifies the {@link AsyncEndPoint} associated + * happen for registered channels. When events happen, it notifies the {@link EndPoint} associated * with the channel.
*/ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dumpable @@ -413,9 +413,9 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa Object attachment = key.attachment(); try { - if (attachment instanceof SelectableAsyncEndPoint) + if (attachment instanceof SelectableEndPoint) { - ((SelectableAsyncEndPoint)attachment).onSelected(); + ((SelectableEndPoint)attachment).onSelected(); } else if (key.isConnectable()) { @@ -427,7 +427,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa if (connected) { key.interestOps(0); - AsyncEndPoint endpoint = createEndPoint(channel, key); + EndPoint endpoint = createEndPoint(channel, key); key.attach(endpoint); } else @@ -482,21 +482,21 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa _selector.wakeup(); } - private AsyncEndPoint createEndPoint(SocketChannel channel, SelectionKey selectionKey) throws IOException + private EndPoint createEndPoint(SocketChannel channel, SelectionKey selectionKey) throws IOException { - AsyncEndPoint endPoint = newEndPoint(channel, this, selectionKey); + EndPoint endPoint = newEndPoint(channel, this, selectionKey); endPointOpened(endPoint); - AsyncConnection asyncConnection = newConnection(channel, endPoint, selectionKey.attachment()); - endPoint.setAsyncConnection(asyncConnection); + Connection asyncConnection = newConnection(channel, endPoint, selectionKey.attachment()); + endPoint.setConnection(asyncConnection); connectionOpened(asyncConnection); LOG.debug("Created {}", endPoint); return endPoint; } - public void destroyEndPoint(AsyncEndPoint endPoint) + public void destroyEndPoint(EndPoint endPoint) { LOG.debug("Destroyed {}", endPoint); - connectionClosed(endPoint.getAsyncConnection()); + connectionClosed(endPoint.getConnection()); endPointClosed(endPoint); } @@ -608,7 +608,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa try { SelectionKey key = _channel.register(_selector, 0, null); - AsyncEndPoint endpoint = createEndPoint(_channel, key); + EndPoint endpoint = createEndPoint(_channel, key); key.attach(endpoint); } catch (IOException x) @@ -685,10 +685,10 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa } /** - * A {@link SelectableAsyncEndPoint} is an {@link AsyncEndPoint} that wish to be notified of + * A {@link SelectableEndPoint} is an {@link EndPoint} that wish to be notified of * non-blocking events by the {@link ManagedSelector}. */ - public interface SelectableAsyncEndPoint extends AsyncEndPoint + public interface SelectableEndPoint extends EndPoint { /** *Callback method invoked when a read or write events has been detected by the {@link ManagedSelector} diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java index 30f7275f1d6..35871736c3a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java @@ -13,7 +13,7 @@ import org.eclipse.jetty.util.Callback; /* ------------------------------------------------------------ */ /** - * A Utility class to help implement {@link AsyncEndPoint#write(Object, Callback, ByteBuffer...)} + * A Utility class to help implement {@link EndPoint#write(Object, Callback, ByteBuffer...)} * by calling {@link EndPoint#flush(ByteBuffer...)} until all content is written. * The abstract method {@link #onIncompleteFlushed()} is called when not all content has been * written after a call to flush and should organise for the {@link #completeWrite()} diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index 9edc472aa8f..a2505a56a9d 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -24,10 +24,10 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus; import javax.net.ssl.SSLEngineResult.Status; import javax.net.ssl.SSLException; -import org.eclipse.jetty.io.AbstractAsyncConnection; +import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractEndPoint; -import org.eclipse.jetty.io.AsyncConnection; -import org.eclipse.jetty.io.AsyncEndPoint; +import org.eclipse.jetty.io.Connection; +import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.ReadInterest; @@ -40,11 +40,11 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; /** - * An AsyncConnection that acts as an intercepter between an AsyncEndPoint providing SSL encrypted data - * and another consumer of an AsyncEndPoint (typically an {@link AsyncConnection} like HttpConnection) that + * An AsyncConnection that acts as an intercepter between an EndPoint providing SSL encrypted data + * and another consumer of an EndPoint (typically an {@link Connection} like HttpConnection) that * wants unencrypted data. *
- * The connector uses an {@link AsyncEndPoint} (typically {@link SelectChannelEndPoint}) as + * The connector uses an {@link EndPoint} (typically {@link SelectChannelEndPoint}) as * it's source/sink of encrypted data. It then provides an endpoint via {@link #getDecryptedEndPoint()} to * expose a source/sink of unencrypted data to another connection (eg HttpConnection). *
@@ -52,15 +52,15 @@ import org.eclipse.jetty.util.log.Logger; * asynchronous callbacks, and active methods that do schedule asynchronous callbacks. *
* The passive methods are {@link DecryptedEndPoint#fill(ByteBuffer)} and {@link DecryptedEndPoint#flush(ByteBuffer...)}. They make best - * effort attempts to progress the connection using only calls to the encrypted {@link AsyncEndPoint#fill(ByteBuffer)} and {@link AsyncEndPoint#flush(ByteBuffer...)} + * effort attempts to progress the connection using only calls to the encrypted {@link EndPoint#fill(ByteBuffer)} and {@link EndPoint#flush(ByteBuffer...)} * methods. They will never block nor schedule any readInterest or write callbacks. If a fill/flush cannot progress either because * of network congestion or waiting for an SSL handshake message, then the fill/flush will simply return with zero bytes filled/flushed. * Specifically, if a flush cannot proceed because it needs to receive a handshake message, then the flush will attempt to fill bytes from the - * encrypted endpoint, but if insufficient bytes are read it will NOT call {@link AsyncEndPoint#fillInterested(Object, Callback)}. + * encrypted endpoint, but if insufficient bytes are read it will NOT call {@link EndPoint#fillInterested(Object, Callback)}. *
* It is only the active methods : {@link DecryptedEndPoint#fillInterested(Object, Callback)} and
* {@link DecryptedEndPoint#write(Object, Callback, ByteBuffer...)} that may schedule callbacks by calling the encrypted
- * {@link AsyncEndPoint#fillInterested(Object, Callback)} and {@link AsyncEndPoint#write(Object, Callback, ByteBuffer...)}
+ * {@link EndPoint#fillInterested(Object, Callback)} and {@link EndPoint#write(Object, Callback, ByteBuffer...)}
* methods. For normal data handling, the decrypted fillInterest method will result in an encrypted fillInterest and a decrypted
* write will result in an encrypted write. However, due to SSL handshaking requirements, it is also possible for a decrypted fill
* to call the encrypted write and for the decrypted flush to call the encrypted fillInterested methods.
@@ -70,7 +70,7 @@ import org.eclipse.jetty.util.log.Logger;
* be called again and make another best effort attempt to progress the connection.
*
*/
-public class SslConnection extends AbstractAsyncConnection
+public class SslConnection extends AbstractConnection
{
private static final Logger LOG = Log.getLogger(SslConnection.class);
private final ByteBufferPool _bufferPool;
@@ -82,7 +82,7 @@ public class SslConnection extends AbstractAsyncConnection
private final boolean _encryptedDirectBuffers = false;
private final boolean _decryptedDirectBuffers = false;
- public SslConnection(ByteBufferPool byteBufferPool, Executor executor, AsyncEndPoint endPoint, SSLEngine sslEngine)
+ public SslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine sslEngine)
{
super(endPoint, executor, true);
this._bufferPool = byteBufferPool;
@@ -95,7 +95,7 @@ public class SslConnection extends AbstractAsyncConnection
return _sslEngine;
}
- public AsyncEndPoint getDecryptedEndPoint()
+ public EndPoint getDecryptedEndPoint()
{
return _decryptedEndPoint;
}
@@ -113,7 +113,7 @@ public class SslConnection extends AbstractAsyncConnection
if (_sslEngine.getUseClientMode())
_decryptedEndPoint.write(null, new Callback.Empty<>(), BufferUtil.EMPTY_BUFFER);
- getDecryptedEndPoint().getAsyncConnection().onOpen();
+ getDecryptedEndPoint().getConnection().onOpen();
}
catch (SSLException x)
{
@@ -187,25 +187,14 @@ public class SslConnection extends AbstractAsyncConnection
}
/* ------------------------------------------------------------ */
- public class DecryptedEndPoint extends AbstractEndPoint implements AsyncEndPoint
+ public class DecryptedEndPoint extends AbstractEndPoint implements EndPoint
{
- private AsyncConnection _connection;
private boolean _fillRequiresFlushToProgress;
private boolean _flushRequiresFillToProgress;
private boolean _cannotAcceptMoreAppDataToFlush;
private boolean _needToFillMoreDataToProgress;
private boolean _ishut = false;
- @Override
- public void onOpen()
- {
- }
-
- @Override
- public void onClose()
- {
- }
-
private final Callback
- * This method is normally called as the {@link AbstractAsyncConnection} onReadable callback.
+ * This method is normally called as the {@link AbstractConnection} onReadable callback.
* However, it can also be called {@link HttpChannelOverHttp#completed()} if there is unconsumed
* data in the _requestBuffer, as a result of resuming a suspended request when there is a pipelined
* request already read into the buffer.
@@ -279,7 +279,7 @@ public class HttpConnection extends AbstractAsyncConnection
}
// return if the connection has been changed
- if (getEndPoint().getAsyncConnection()!=this)
+ if (getEndPoint().getConnection()!=this)
return;
}
else if (_headerBytes>= _httpConfig.getRequestHeaderSize())
@@ -437,11 +437,11 @@ public class HttpConnection extends AbstractAsyncConnection
// Handle connection upgrades
if (getResponse().getStatus()==HttpStatus.SWITCHING_PROTOCOLS_101)
{
- AsyncConnection connection=(AsyncConnection)getRequest().getAttribute(UPGRADE_CONNECTION_ATTR);
+ Connection connection=(Connection)getRequest().getAttribute(UPGRADE_CONNECTION_ATTR);
if (connection!=null)
{
LOG.debug("Upgrade from {} to {}",this,connection);
- getEndPoint().setAsyncConnection(connection);
+ getEndPoint().setConnection(connection);
HttpConnection.this.reset();
return;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
index 00134d664ed..fff6c558ef9 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
@@ -22,8 +22,8 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.eclipse.jetty.io.AsyncByteArrayEndPoint;
-import org.eclipse.jetty.io.AsyncConnection;
+import org.eclipse.jetty.io.ByteArrayEndPoint;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
@@ -158,15 +158,15 @@ public class LocalConnector extends AbstractConnector
{
LOG.debug("accepting {}",acceptorID);
LocalEndPoint endp = _connects.take();
- AsyncConnection connection=newConnection(endp);
- endp.setAsyncConnection(connection);
+ Connection connection=newConnection(endp);
+ endp.setConnection(connection);
endp.onOpen();
connection.onOpen();
connectionOpened(connection);
}
- public class LocalEndPoint extends AsyncByteArrayEndPoint
+ public class LocalEndPoint extends ByteArrayEndPoint
{
private CountDownLatch _closed = new CountDownLatch(1);
@@ -191,8 +191,8 @@ public class LocalConnector extends AbstractConnector
super.close();
if (was_open)
{
- connectionClosed(getAsyncConnection());
- getAsyncConnection().onClose();
+ connectionClosed(getConnection());
+ getConnection().onClose();
onClose();
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java
index c5f42b6fef5..65664afde44 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SelectChannelConnector.java
@@ -24,8 +24,8 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
@@ -237,9 +237,9 @@ public class SelectChannelConnector extends AbstractNetConnector
return new SelectChannelEndPoint(channel,selectSet,key, getScheduler(), getIdleTimeout());
}
- protected void endPointClosed(AsyncEndPoint endpoint)
+ protected void endPointClosed(EndPoint endpoint)
{
- connectionClosed(endpoint.getAsyncConnection());
+ connectionClosed(endpoint.getConnection());
}
/* ------------------------------------------------------------ */
@@ -257,25 +257,25 @@ public class SelectChannelConnector extends AbstractNetConnector
}
@Override
- protected void endPointClosed(AsyncEndPoint endpoint)
+ protected void endPointClosed(EndPoint endpoint)
{
- SelectChannelConnector.this.connectionClosed(endpoint.getAsyncConnection());
+ SelectChannelConnector.this.connectionClosed(endpoint.getConnection());
super.endPointClosed(endpoint);
}
@Override
- protected void endPointOpened(AsyncEndPoint endpoint)
+ protected void endPointOpened(EndPoint endpoint)
{
// TODO handle max connections and low resources
super.endPointOpened(endpoint);
- SelectChannelConnector.this.connectionOpened(endpoint.getAsyncConnection());
+ SelectChannelConnector.this.connectionOpened(endpoint.getConnection());
}
@Override
- public void connectionUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
+ public void connectionUpgraded(EndPoint endpoint, Connection oldConnection)
{
super.connectionUpgraded(endpoint, oldConnection);
- SelectChannelConnector.this.connectionUpgraded(oldConnection, endpoint.getAsyncConnection());
+ SelectChannelConnector.this.connectionUpgraded(oldConnection, endpoint.getConnection());
}
@Override
@@ -285,7 +285,7 @@ public class SelectChannelConnector extends AbstractNetConnector
}
@Override
- public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment) throws IOException
+ public Connection newConnection(SocketChannel channel, EndPoint endpoint, Object attachment) throws IOException
{
return SelectChannelConnector.this.newConnection(endpoint);
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
index 52be91c8f90..163fae4e8b8 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/NetworkTrafficSelectChannelConnector.java
@@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.NetworkTrafficListener;
import org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint;
@@ -88,7 +88,7 @@ public class NetworkTrafficSelectChannelConnector extends SelectChannelConnector
}
@Override
- protected void endPointClosed(AsyncEndPoint endpoint)
+ protected void endPointClosed(EndPoint endpoint)
{
super.endPointClosed(endpoint);
((NetworkTrafficSelectChannelEndPoint)endpoint).notifyClosed();
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
index 4cf56be084b..f082e9162c9 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java
@@ -150,7 +150,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
// Get the server side endpoint
EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS);
if (endp instanceof SslConnection.DecryptedEndPoint)
- endp=((SslConnection.DecryptedEndPoint)endp).getAsyncConnection().getEndPoint();
+ endp=((SslConnection.DecryptedEndPoint)endp).getConnection().getEndPoint();
// read the response
String result=IO.toString(is);
@@ -223,7 +223,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
// Get the server side endpoint
EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS);
if (endp instanceof SslConnection.DecryptedEndPoint)
- endp=((SslConnection.DecryptedEndPoint)endp).getAsyncConnection().getEndPoint();
+ endp=((SslConnection.DecryptedEndPoint)endp).getConnection().getEndPoint();
// read the response
String result=IO.toString(is);
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
index 96ecd8a8ad1..4c620850869 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
@@ -38,9 +38,10 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpURI;
-import org.eclipse.jetty.io.AbstractAsyncConnection;
-import org.eclipse.jetty.io.AsyncByteArrayEndPoint;
-import org.eclipse.jetty.io.AsyncConnection;
+import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.io.AbstractEndPoint;
+import org.eclipse.jetty.io.ByteArrayEndPoint;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.session.HashSessionIdManager;
@@ -71,9 +72,9 @@ public class ResponseTest
_server.start();
_timer=new ScheduledThreadPoolExecutor(1);
- AsyncByteArrayEndPoint endp = new AsyncByteArrayEndPoint(_timer,5000);
+ AbstractEndPoint endp = new ByteArrayEndPoint(_timer,5000);
HttpInput input = new HttpInput();
- AsyncConnection connection = new AbstractAsyncConnection(endp,new Executor()
+ Connection connection = new AbstractConnection(endp,new Executor()
{
@Override
public void execute(Runnable command)
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java
index 874d908752e..5763e00db7c 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SelectChannelStatisticsTest.java
@@ -28,8 +28,8 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper;
import org.eclipse.jetty.util.log.Log;
@@ -62,14 +62,14 @@ public class SelectChannelStatisticsTest
_connector = new SelectChannelConnector(_server)
{
@Override
- protected void endPointClosed(AsyncEndPoint endpoint)
+ protected void endPointClosed(EndPoint endpoint)
{
//System.err.println("Endpoint closed "+endpoint);
super.endPointClosed(endpoint);
}
@Override
- public void connectionClosed(AsyncConnection connection)
+ public void connectionClosed(Connection connection)
{
//System.err.println("Connection closed "+connection);
super.connectionClosed(connection);
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java
index 57eb77d1e19..6ea43951568 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/SlowClientWithPipelinedRequestTest.java
@@ -26,8 +26,8 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.After;
import org.junit.Assert;
@@ -46,7 +46,7 @@ public class SlowClientWithPipelinedRequestTest
connector = new SelectChannelConnector(server)
{
@Override
- protected AsyncConnection newConnection(AsyncEndPoint endpoint)
+ protected Connection newConnection(EndPoint endpoint)
{
return new HttpConnection(getHttpConfig(),this,endpoint)
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
index bcb2e89e32f..0b10ce06b52 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java
@@ -431,8 +431,8 @@ public class ContextHandlerTest
private static final class WriterHandler extends AbstractHandler
{
- boolean error;
- Throwable throwable;
+ volatile boolean error;
+ volatile Throwable throwable;
public void handle(String s, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java
index 772ef521bac..3d400806f00 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java
@@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse;
import junit.framework.TestCase;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.SelectChannelConnector;
@@ -43,7 +43,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
*/
public class SSLCloseTest extends TestCase
{
- private static AsyncEndPoint __endp;
+ private static EndPoint __endp;
private static class CredulousTM implements TrustManager, X509TrustManager
{
public X509Certificate[] getAcceptedIssuers()
diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java
index a5b4741a944..34fa32008c7 100644
--- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java
+++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/AsyncConnectionFactory.java
@@ -15,10 +15,10 @@ package org.eclipse.jetty.spdy;
import java.nio.channels.SocketChannel;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
public interface AsyncConnectionFactory
{
- public AsyncConnection newAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, Object attachment);
+ public Connection newAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment);
}
diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java
index 45b9d0228ab..2b7189c1ad9 100644
--- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java
+++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/EmptyAsyncEndPoint.java
@@ -19,14 +19,14 @@ import java.nio.ByteBuffer;
import java.nio.channels.ReadPendingException;
import java.nio.channels.WritePendingException;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.Callback;
-public class EmptyAsyncEndPoint implements AsyncEndPoint
+public class EmptyEndPoint implements EndPoint
{
private boolean checkForIdle;
- private AsyncConnection connection;
+ private Connection connection;
private boolean oshut;
private boolean closed;
private long maxIdleTime;
@@ -38,13 +38,13 @@ public class EmptyAsyncEndPoint implements AsyncEndPoint
}
@Override
- public AsyncConnection getAsyncConnection()
+ public Connection getConnection()
{
return connection;
}
@Override
- public void setAsyncConnection(AsyncConnection connection)
+ public void setConnection(Connection connection)
{
this.connection = connection;
}
diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java
index fa5d58922de..84d33b34def 100644
--- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java
+++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoClientAsyncConnection.java
@@ -18,15 +18,15 @@ import java.nio.channels.SocketChannel;
import java.util.List;
import java.util.concurrent.Executor;
-import org.eclipse.jetty.io.AbstractAsyncConnection;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.npn.NextProtoNego;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class NextProtoNegoClientAsyncConnection extends AbstractAsyncConnection implements NextProtoNego.ClientProvider
+public class NextProtoNegoClientAsyncConnection extends AbstractConnection implements NextProtoNego.ClientProvider
{
private final Logger logger = Log.getLogger(getClass());
private final SocketChannel channel;
@@ -34,7 +34,7 @@ public class NextProtoNegoClientAsyncConnection extends AbstractAsyncConnection
private final SPDYClient client;
private volatile boolean completed;
- public NextProtoNegoClientAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, Object attachment, Executor executor, SPDYClient client)
+ public NextProtoNegoClientAsyncConnection(SocketChannel channel, EndPoint endPoint, Object attachment, Executor executor, SPDYClient client)
{
super(endPoint, executor);
this.channel = channel;
@@ -86,8 +86,8 @@ public class NextProtoNegoClientAsyncConnection extends AbstractAsyncConnection
public void unsupported()
{
// Server does not support NPN, but this is a SPDY client, so hardcode SPDY
- AsyncEndPoint endPoint = getEndPoint();
- AsyncConnection connection = client.getDefaultAsyncConnectionFactory().newAsyncConnection(channel, endPoint, attachment);
+ EndPoint endPoint = getEndPoint();
+ Connection connection = client.getDefaultAsyncConnectionFactory().newAsyncConnection(channel, endPoint, attachment);
client.replaceAsyncConnection(endPoint, connection);
completed = true;
}
@@ -98,8 +98,8 @@ public class NextProtoNegoClientAsyncConnection extends AbstractAsyncConnection
String protocol = client.selectProtocol(protocols);
if (protocol == null)
return null;
- AsyncEndPoint endPoint = getEndPoint();
- AsyncConnection connection = client.getAsyncConnectionFactory(protocol).newAsyncConnection(channel, endPoint, attachment);
+ EndPoint endPoint = getEndPoint();
+ Connection connection = client.getAsyncConnectionFactory(protocol).newAsyncConnection(channel, endPoint, attachment);
client.replaceAsyncConnection(endPoint, connection);
completed = true;
return protocol;
diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerAsyncConnection.java
index 82329477c3b..18f43502c99 100644
--- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerAsyncConnection.java
+++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/NextProtoNegoServerAsyncConnection.java
@@ -17,22 +17,22 @@ import java.io.IOException;
import java.nio.channels.SocketChannel;
import java.util.List;
-import org.eclipse.jetty.io.AbstractAsyncConnection;
-import org.eclipse.jetty.io.AsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.io.Connection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.npn.NextProtoNego;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class NextProtoNegoServerAsyncConnection extends AbstractAsyncConnection implements NextProtoNego.ServerProvider
+public class NextProtoNegoServerAsyncConnection extends AbstractConnection implements NextProtoNego.ServerProvider
{
private final Logger logger = Log.getLogger(getClass());
private final SocketChannel channel;
private final SPDYServerConnector connector;
private volatile boolean completed;
- public NextProtoNegoServerAsyncConnection(SocketChannel channel, AsyncEndPoint endPoint, SPDYServerConnector connector)
+ public NextProtoNegoServerAsyncConnection(SocketChannel channel, EndPoint endPoint, SPDYServerConnector connector)
{
super(endPoint, connector.getExecutor());
this.channel = channel;
@@ -77,8 +77,8 @@ public class NextProtoNegoServerAsyncConnection extends AbstractAsyncConnection
public void unsupported()
{
AsyncConnectionFactory asyncConnectionFactory = connector.getDefaultAsyncConnectionFactory();
- AsyncEndPoint endPoint = getEndPoint();
- AsyncConnection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
+ EndPoint endPoint = getEndPoint();
+ Connection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
connector.replaceAsyncConnection(endPoint, connection);
completed = true;
}
@@ -93,8 +93,8 @@ public class NextProtoNegoServerAsyncConnection extends AbstractAsyncConnection
public void protocolSelected(String protocol)
{
AsyncConnectionFactory asyncConnectionFactory = connector.getAsyncConnectionFactory(protocol);
- AsyncEndPoint endPoint = getEndPoint();
- AsyncConnection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
+ EndPoint endPoint = getEndPoint();
+ Connection connection = asyncConnectionFactory.newAsyncConnection(channel, endPoint, connector);
connector.replaceAsyncConnection(endPoint, connection);
completed = true;
}
diff --git a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java
index b11e62e1376..810ad41020b 100644
--- a/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java
+++ b/jetty-spdy/spdy-jetty/src/main/java/org/eclipse/jetty/spdy/SPDYAsyncConnection.java
@@ -17,8 +17,8 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.Executor;
-import org.eclipse.jetty.io.AbstractAsyncConnection;
-import org.eclipse.jetty.io.AsyncEndPoint;
+import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.spdy.parser.Parser;
@@ -26,7 +26,7 @@ import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class SPDYAsyncConnection extends AbstractAsyncConnection implements Controller