X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Fio%2FConnection.java;fp=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Fio%2FConnection.java;h=96baa01676fcf17bc3108758285f2c886d4133ee;hp=0000000000000000000000000000000000000000;hb=73ef54a38e3930a1a789cdc6b5fa23cdd4c9d086;hpb=515007c7c1351045420669d65b59c08fa46850f2 diff --git a/lib/jetty/org/eclipse/jetty/io/Connection.java b/lib/jetty/org/eclipse/jetty/io/Connection.java new file mode 100644 index 00000000..96baa016 --- /dev/null +++ b/lib/jetty/org/eclipse/jetty/io/Connection.java @@ -0,0 +1,89 @@ +// +// ======================================================================== +// Copyright (c) 1995-2014 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.Closeable; + +import org.eclipse.jetty.util.Callback; + +/** + *

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

+ */ +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(); + + /** + *

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

+ *

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

+ */ + public void onClose(); + + /** + * @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 + * {@link EndPoint} but, for example, SSL connections should write the SSL close message + * before closing the associated {@link EndPoint}.

+ */ + @Override + public void close(); + + public int getMessagesIn(); + public int getMessagesOut(); + public long getBytesIn(); + public long getBytesOut(); + public long getCreatedTimeStamp(); + + + public interface Listener + { + public void onOpened(Connection connection); + + public void onClosed(Connection connection); + + public static class Adapter implements Listener + { + @Override + public void onOpened(Connection connection) + { + } + + @Override + public void onClosed(Connection connection) + { + } + } + } +}