X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Fio%2FConnection.java;h=5c7d564d749303dab24b324ced45805da5888825;hp=96baa01676fcf17bc3108758285f2c886d4133ee;hb=d23d7a6fa9dc38c6193fea70017e0bff11257be5;hpb=ec24cf6925bb3729a644580ad4a9375d05883c62 diff --git a/lib/jetty/org/eclipse/jetty/io/Connection.java b/lib/jetty/org/eclipse/jetty/io/Connection.java index 96baa016..5c7d564d 100644 --- a/lib/jetty/org/eclipse/jetty/io/Connection.java +++ b/lib/jetty/org/eclipse/jetty/io/Connection.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// Copyright (c) 1995-2016 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 @@ -19,13 +19,12 @@ package org.eclipse.jetty.io; import java.io.Closeable; - -import org.eclipse.jetty.util.Callback; +import java.nio.ByteBuffer; /** *

A {@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 + *

A typical implementation of {@link Connection} overrides {@link #onOpen(ByteBuffer)} to * {@link EndPoint#fillInterested(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.

@@ -34,10 +33,6 @@ public interface Connection extends Closeable { public void addListener(Listener listener); - /** - *

Callback method invoked when this {@link Connection} is opened.

- *

Creators of the connection implementation are responsible for calling this method.

- */ public void onOpen(); /** @@ -50,7 +45,7 @@ public interface Connection extends Closeable * @return the {@link EndPoint} associated with this {@link Connection} */ public EndPoint getEndPoint(); - + /** *

Performs a logical close of this connection.

*

For simple connections, this may just mean to delegate the close to the associated @@ -66,6 +61,30 @@ public interface Connection extends Closeable public long getBytesOut(); public long getCreatedTimeStamp(); + public interface UpgradeFrom extends Connection + { + /* ------------------------------------------------------------ */ + /** Take the input buffer from the connection on upgrade. + *

This method is used to take any unconsumed input from + * a connection during an upgrade. + * @return A buffer of unconsumed input. The caller must return the buffer + * to the bufferpool when consumed and this connection must not. + */ + ByteBuffer onUpgradeFrom(); + } + + public interface UpgradeTo extends Connection + { + /** + *

Callback method invoked when this {@link Connection} is upgraded.

+ *

This must be called before {@link #onOpen()}.

+ * @param prefilledBuffer An optional buffer that can contain prefilled data. Typically this + * results from an upgrade of one protocol to the other where the old connection has buffered + * data destined for the new connection. The new connection must take ownership of the buffer + * and is responsible for returning it to the buffer pool + */ + void onUpgradeTo(ByteBuffer prefilled); + } public interface Listener {