diff src/org/eclipse/jetty/io/EndPoint.java @ 978:bdb6eb0fbf93

simplify ChannelEndPoint
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 16 Oct 2016 14:53:43 -0600
parents 3428c60d7cfc
children 2b769da7f67d
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/EndPoint.java	Sun Oct 16 01:31:05 2016 -0600
+++ b/src/org/eclipse/jetty/io/EndPoint.java	Sun Oct 16 14:53:43 2016 -0600
@@ -19,6 +19,7 @@
 package org.eclipse.jetty.io;
 
 import java.io.IOException;
+import java.nio.channels.SocketChannel;
 
 
 /**
@@ -27,148 +28,140 @@
  */
 public interface EndPoint
 {
-    /**
-     * Shutdown any backing output stream associated with the endpoint
-     */
-    void shutdownOutput() throws IOException;
+	/**
+	 * Shutdown any backing output stream associated with the endpoint
+	 */
+	void shutdownOutput() throws IOException;
 
-    boolean isOutputShutdown();
+	boolean isOutputShutdown();
 
-    /**
-     * Shutdown any backing input stream associated with the endpoint
-     */
-    void shutdownInput() throws IOException;
+	/**
+	 * Shutdown any backing input stream associated with the endpoint
+	 */
+	void shutdownInput() throws IOException;
 
-    boolean isInputShutdown();
+	boolean isInputShutdown();
 
-    /**
-     * Close any backing stream associated with the endpoint
-     */
-    void close() throws IOException;
+	/**
+	 * Close any backing stream associated with the endpoint
+	 */
+	void close() throws IOException;
 
-    /**
-     * Fill the buffer from the current putIndex to it's capacity from whatever
-     * byte source is backing the buffer. The putIndex is increased if bytes filled.
-     * The buffer may chose to do a compact before filling.
-     * @return an <code>int</code> value indicating the number of bytes
-     * filled or -1 if EOF is reached.
-     * @throws EofException If input is shutdown or the endpoint is closed.
-     */
-    int fill(Buffer buffer) throws IOException;
+	/**
+	 * Fill the buffer from the current putIndex to it's capacity from whatever
+	 * byte source is backing the buffer. The putIndex is increased if bytes filled.
+	 * The buffer may chose to do a compact before filling.
+	 * @return an <code>int</code> value indicating the number of bytes
+	 * filled or -1 if EOF is reached.
+	 * @throws EofException If input is shutdown or the endpoint is closed.
+	 */
+	int fill(Buffer buffer) throws IOException;
 
 
-    /**
-     * Flush the buffer from the current getIndex to it's putIndex using whatever byte
-     * sink is backing the buffer. The getIndex is updated with the number of bytes flushed.
-     * Any mark set is cleared.
-     * If the entire contents of the buffer are flushed, then an implicit empty() is done.
-     *
-     * @param buffer The buffer to flush. This buffers getIndex is updated.
-     * @return  the number of bytes written
-     * @throws EofException If the endpoint is closed or output is shutdown.
-     */
-    int flush(Buffer buffer) throws IOException;
+	/**
+	 * Flush the buffer from the current getIndex to it's putIndex using whatever byte
+	 * sink is backing the buffer. The getIndex is updated with the number of bytes flushed.
+	 * Any mark set is cleared.
+	 * If the entire contents of the buffer are flushed, then an implicit empty() is done.
+	 *
+	 * @param buffer The buffer to flush. This buffers getIndex is updated.
+	 * @return  the number of bytes written
+	 * @throws EofException If the endpoint is closed or output is shutdown.
+	 */
+	int flush(Buffer buffer) throws IOException;
 
-    /**
-     * Flush the buffer from the current getIndex to it's putIndex using whatever byte
-     * sink is backing the buffer. The getIndex is updated with the number of bytes flushed.
-     * Any mark set is cleared.
-     * If the entire contents of the buffer are flushed, then an implicit empty() is done.
-     * The passed header/trailer buffers are written before/after the contents of this buffer. This may be done
-     * either as gather writes, as a poke into this buffer or as several writes. The implementation is free to
-     * select the optimal mechanism.
-     * @param header A buffer to write before flushing this buffer. This buffers getIndex is updated.
-     * @param buffer The buffer to flush. This buffers getIndex is updated.
-     * @param trailer A buffer to write after flushing this buffer. This buffers getIndex is updated.
-     * @return the total number of bytes written.
-     */
-    int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException;
+	/**
+	 * Flush the buffer from the current getIndex to it's putIndex using whatever byte
+	 * sink is backing the buffer. The getIndex is updated with the number of bytes flushed.
+	 * Any mark set is cleared.
+	 * If the entire contents of the buffer are flushed, then an implicit empty() is done.
+	 * The passed header/trailer buffers are written before/after the contents of this buffer. This may be done
+	 * either as gather writes, as a poke into this buffer or as several writes. The implementation is free to
+	 * select the optimal mechanism.
+	 * @param header A buffer to write before flushing this buffer. This buffers getIndex is updated.
+	 * @param buffer The buffer to flush. This buffers getIndex is updated.
+	 * @param trailer A buffer to write after flushing this buffer. This buffers getIndex is updated.
+	 * @return the total number of bytes written.
+	 */
+	int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException;
 
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The local IP address to which this <code>EndPoint</code> is bound, or <code>null</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public String getLocalAddr();
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The local IP address to which this <code>EndPoint</code> is bound, or <code>null</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public String getLocalAddr();
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The local host name to which this <code>EndPoint</code> is bound, or <code>null</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public String getLocalHost();
-
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The local port number on which this <code>EndPoint</code> is listening, or <code>0</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public int getLocalPort();
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The local host name to which this <code>EndPoint</code> is bound, or <code>null</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public String getLocalHost();
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The remote IP address to which this <code>EndPoint</code> is connected, or <code>null</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public String getRemoteAddr();
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The local port number on which this <code>EndPoint</code> is listening, or <code>0</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public int getLocalPort();
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The host name of the remote machine to which this <code>EndPoint</code> is connected, or <code>null</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public String getRemoteHost();
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The remote IP address to which this <code>EndPoint</code> is connected, or <code>null</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public String getRemoteAddr();
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The remote port number to which this <code>EndPoint</code> is connected, or <code>0</code>
-     * if this <code>EndPoint</code> does not represent a network connection.
-     */
-    public int getRemotePort();
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The host name of the remote machine to which this <code>EndPoint</code> is connected, or <code>null</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public String getRemoteHost();
 
-    /* ------------------------------------------------------------ */
-    public boolean isBlocking();
-
-    /* ------------------------------------------------------------ */
-    public boolean blockReadable(long millisecs) throws IOException;
-
-    /* ------------------------------------------------------------ */
-    public boolean blockWritable(long millisecs) throws IOException;
+	/* ------------------------------------------------------------ */
+	/**
+	 * @return The remote port number to which this <code>EndPoint</code> is connected, or <code>0</code>
+	 * if this <code>EndPoint</code> does not represent a network connection.
+	 */
+	public int getRemotePort();
 
-    /* ------------------------------------------------------------ */
-    public boolean isOpen();
+	public boolean isBlocking();
+
+	public boolean blockReadable(long millisecs) throws IOException;
 
-    /* ------------------------------------------------------------ */
-    /**
-     * @return The underlying transport object (socket, channel, etc.)
-     */
-    public Object getTransport();
+	public boolean blockWritable(long millisecs) throws IOException;
+
+	public boolean isOpen();
+
+	public SocketChannel getChannel();
 
-    /* ------------------------------------------------------------ */
-    /** Flush any buffered output.
-     * May fail to write all data if endpoint is non-blocking
-     * @throws EofException If the endpoint is closed or output is shutdown.
-     */
-    public void flush() throws IOException;
+	/* ------------------------------------------------------------ */
+	/** Flush any buffered output.
+	 * May fail to write all data if endpoint is non-blocking
+	 * @throws EofException If the endpoint is closed or output is shutdown.
+	 */
+	public void flush() throws IOException;
 
-    /* ------------------------------------------------------------ */
-    /** Get the max idle time in ms.
-     * <p>The max idle time is the time the endpoint can be idle before
-     * extraordinary handling takes place.  This loosely corresponds to
-     * the {@link java.net.Socket#getSoTimeout()} for blocking connections,
-     * but {@link AsyncEndPoint} implementations must use other mechanisms
-     * to implement the max idle time.
-     * @return the max idle time in ms or if ms <= 0 implies an infinite timeout
-     */
-    public int getMaxIdleTime();
+	/* ------------------------------------------------------------ */
+	/** Get the max idle time in ms.
+	 * <p>The max idle time is the time the endpoint can be idle before
+	 * extraordinary handling takes place.  This loosely corresponds to
+	 * the {@link java.net.Socket#getSoTimeout()} for blocking connections,
+	 * but {@link AsyncEndPoint} implementations must use other mechanisms
+	 * to implement the max idle time.
+	 * @return the max idle time in ms or if ms <= 0 implies an infinite timeout
+	 */
+	public int getMaxIdleTime();
 
-    /* ------------------------------------------------------------ */
-    /** Set the max idle time.
-     * @param timeMs the max idle time in MS. Timeout <= 0 implies an infinite timeout
-     * @throws IOException if the timeout cannot be set.
-     */
-    public void setMaxIdleTime(int timeMs) throws IOException;
+	/* ------------------------------------------------------------ */
+	/** Set the max idle time.
+	 * @param timeMs the max idle time in MS. Timeout <= 0 implies an infinite timeout
+	 * @throws IOException if the timeout cannot be set.
+	 */
+	public void setMaxIdleTime(int timeMs) throws IOException;