Package org.eclipse.jetty.io
Class AbstractEndPoint
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- All Implemented Interfaces:
Closeable,AutoCloseable,EndPoint
- Direct Known Subclasses:
ByteArrayEndPoint,ChannelEndPoint,SslConnection.DecryptedEndPoint
public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEndPoint(Scheduler scheduler, InetSocketAddress local, InetSocketAddress remote)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close any backing stream associated with the endpointprotected voidclose(Throwable failure)voidfillInterested(Callback callback)Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.ConnectiongetConnection()longgetCreatedTimeStamp()FillInterestgetFillInterest()InetSocketAddressgetLocalAddress()InetSocketAddressgetRemoteAddress()protected WriteFlushergetWriteFlusher()booleanisFillInterested()booleanisOptimizedForDirectBuffers()Is the endpoint optimized for DirectBuffer usageprotected abstract voidneedsFillInterest()protected voidonIdleExpired(TimeoutException timeout)This abstract method is called when the idle timeout has expired.protected abstract voidonIncompleteFlush()voidonOpen()Callback method invoked when thisEndPointis opened.voidsetConnection(Connection connection)StringtoString()booleantryFillInterested(Callback callback)Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.voidupgrade(Connection newConnection)Upgrade connections.voidwrite(Callback callback, ByteBuffer... buffers)Writes the given buffers viaEndPoint.flush(ByteBuffer...)and invokes callback methods when either all the data has been flushed or an error occurs.-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getIdleTimestamp, getScheduler, isOpen, notIdle, onClose, setIdleTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.io.EndPoint
fill, flush, getIdleTimeout, getTransport, isInputShutdown, isOpen, isOutputShutdown, onClose, setIdleTimeout, shutdownOutput
-
-
-
-
Constructor Detail
-
AbstractEndPoint
protected AbstractEndPoint(Scheduler scheduler, InetSocketAddress local, InetSocketAddress remote)
-
-
Method Detail
-
getCreatedTimeStamp
public long getCreatedTimeStamp()
- Specified by:
getCreatedTimeStampin interfaceEndPoint
-
getLocalAddress
public InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceEndPoint- Returns:
- The local Inet address to which this
EndPointis bound, ornullif thisEndPointdoes not represent a network connection.
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceEndPoint- Returns:
- The remote Inet address to which this
EndPointis bound, ornullif thisEndPointdoes not represent a network connection.
-
getConnection
public Connection getConnection()
- Specified by:
getConnectionin interfaceEndPoint- Returns:
- the
Connectionassociated with thisEndPoint - See Also:
EndPoint.setConnection(Connection)
-
setConnection
public void setConnection(Connection connection)
- Specified by:
setConnectionin interfaceEndPoint- Parameters:
connection- theConnectionassociated with thisEndPoint- See Also:
EndPoint.getConnection(),EndPoint.upgrade(Connection)
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
Description copied from interface:EndPointIs the endpoint optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffersin interfaceEndPoint- Returns:
- True if direct buffers can be used optimally.
-
onOpen
public void onOpen()
Description copied from interface:EndPointCallback method invoked when this
EndPointis opened.- Specified by:
onOpenin interfaceEndPoint- Overrides:
onOpenin classIdleTimeout- See Also:
EndPoint.onClose()
-
close
public void close()
Description copied from interface:EndPointClose any backing stream associated with the endpoint
-
close
protected void close(Throwable failure)
-
fillInterested
public void fillInterested(Callback callback)
Description copied from interface:EndPointRequests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)would return data or EOF.- Specified by:
fillInterestedin interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or we are readable.
-
tryFillInterested
public boolean tryFillInterested(Callback callback)
Description copied from interface:EndPointRequests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)would return data or EOF.- Specified by:
tryFillInterestedin interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or we are readable.- Returns:
- true if set
-
isFillInterested
public boolean isFillInterested()
- Specified by:
isFillInterestedin interfaceEndPoint- Returns:
- whether
EndPoint.fillInterested(Callback)has been called, butEndPoint.fill(ByteBuffer)has not yet been called
-
write
public void write(Callback callback, ByteBuffer... buffers) throws IllegalStateException
Description copied from interface:EndPointWrites the given buffers via
EndPoint.flush(ByteBuffer...)and invokes callback methods when either all the data has been flushed or an error occurs.- Specified by:
writein interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or the write completed.buffers- one or moreByteBuffers that will be flushed.- Throws:
WritePendingException- if another write operation is concurrent.IllegalStateException
-
onIncompleteFlush
protected abstract void onIncompleteFlush()
-
needsFillInterest
protected abstract void needsFillInterest() throws IOException- Throws:
IOException
-
getFillInterest
public FillInterest getFillInterest()
-
getWriteFlusher
protected WriteFlusher getWriteFlusher()
-
onIdleExpired
protected void onIdleExpired(TimeoutException timeout)
Description copied from class:IdleTimeoutThis abstract method is called when the idle timeout has expired.- Specified by:
onIdleExpiredin classIdleTimeout- Parameters:
timeout- a TimeoutException
-
upgrade
public void upgrade(Connection newConnection)
Description copied from interface:EndPointUpgrade connections. Close the old connection, update the endpoint and open the new connection. If the oldConnection is an instance ofConnection.UpgradeFromthen a prefilled buffer is requested and passed to the newConnection if it is an instance ofConnection.UpgradeTo
-
-