Package org.eclipse.jetty.io
Class ChannelEndPoint
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- org.eclipse.jetty.io.ChannelEndPoint
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,EndPoint
,ManagedSelector.Selectable
- Direct Known Subclasses:
SocketChannelEndPoint
public abstract class ChannelEndPoint extends AbstractEndPoint implements ManagedSelector.Selectable
Channel End Point.Holds the channel and socket for an NIO endpoint.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_currentInterestOps
The current value forSelectionKey.interestOps()
.protected int
_desiredInterestOps
The desired value forSelectionKey.interestOps()
.protected java.nio.channels.SelectionKey
_key
protected ManagedSelector
_selector
-
Constructor Summary
Constructors Constructor Description ChannelEndPoint(java.nio.channels.ByteChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doClose()
int
fill(java.nio.ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.boolean
flush(java.nio.ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.java.nio.channels.ByteChannel
getChannel()
java.lang.Object
getTransport()
boolean
isOpen()
This abstract method should be called to check if idle timeouts should still be checked.boolean
isOptimizedForDirectBuffers()
Is the endpoint optimized for DirectBuffer usageprotected void
needsFillInterest()
void
onClose()
Callback method invoked when thisEndPoint
is close.protected void
onIncompleteFlush()
java.lang.Runnable
onSelected()
Callback method invoked when a read or write events has been detected by theManagedSelector
for this endpoint.java.lang.String
toEndPointString()
void
updateKey()
Callback method invoked when all the keys selected by theManagedSelector
for this endpoint have been processed.-
Methods inherited from class org.eclipse.jetty.io.AbstractEndPoint
checkFill, checkFlush, close, close, doShutdownInput, doShutdownOutput, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getWriteFlusher, isFillInterested, isInputShutdown, isOutputShutdown, onClose, onIdleExpired, onOpen, reset, setConnection, shutdownInput, shutdownOutput, toConnectionString, toString, tryFillInterested, upgrade, write
-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, 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
getIdleTimeout, getLocalAddress, getRemoteAddress, setIdleTimeout
-
-
-
-
Field Detail
-
_selector
protected final ManagedSelector _selector
-
_key
protected final java.nio.channels.SelectionKey _key
-
_currentInterestOps
protected int _currentInterestOps
The current value forSelectionKey.interestOps()
.
-
_desiredInterestOps
protected int _desiredInterestOps
The desired value forSelectionKey.interestOps()
.
-
-
Constructor Detail
-
ChannelEndPoint
public ChannelEndPoint(java.nio.channels.ByteChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, Scheduler scheduler)
-
-
Method Detail
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
Description copied from interface:EndPoint
Is the endpoint optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffers
in interfaceEndPoint
- Overrides:
isOptimizedForDirectBuffers
in classAbstractEndPoint
- Returns:
- True if direct buffers can be used optimally.
-
isOpen
public boolean isOpen()
Description copied from class:IdleTimeout
This abstract method should be called to check if idle timeouts should still be checked.- Specified by:
isOpen
in interfaceEndPoint
- Overrides:
isOpen
in classAbstractEndPoint
- Returns:
- True if the entity monitored should still be checked for idle timeouts
-
doClose
public void doClose()
- Overrides:
doClose
in classAbstractEndPoint
-
onClose
public void onClose()
Description copied from interface:EndPoint
Callback method invoked when this
EndPoint
is close.- Specified by:
onClose
in interfaceEndPoint
- Overrides:
onClose
in classAbstractEndPoint
- See Also:
EndPoint.onOpen()
-
fill
public int fill(java.nio.ByteBuffer buffer) throws java.io.IOException
Description copied from interface:EndPoint
Fill the passed buffer with data from this endpoint. The bytes are appended to any data already in the buffer by writing from the buffers limit up to it's capacity. The limit is updated to include the filled bytes.- Specified by:
fill
in interfaceEndPoint
- Parameters:
buffer
- The buffer to fill. The position and limit are modified during the fill. After the operation, the position is unchanged and the limit is increased to reflect the new data filled.- Returns:
- an
int
value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown. - Throws:
java.io.IOException
- if the endpoint is closed.
-
flush
public boolean flush(java.nio.ByteBuffer... buffers) throws java.io.IOException
Description copied from interface:EndPoint
Flush data from the passed header/buffer to this endpoint. As many bytes as can be consumed are taken from the header/buffer position up until the buffer limit. The header/buffers position is updated to indicate how many bytes have been consumed.- Specified by:
flush
in interfaceEndPoint
- Parameters:
buffers
- the buffers to flush- Returns:
- True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).
- Throws:
java.io.IOException
- If the endpoint is closed or output is shutdown.
-
getChannel
public java.nio.channels.ByteChannel getChannel()
-
getTransport
public java.lang.Object getTransport()
- Specified by:
getTransport
in interfaceEndPoint
- Returns:
- The underlying transport object (socket, channel, etc.)
-
needsFillInterest
protected void needsFillInterest()
- Specified by:
needsFillInterest
in classAbstractEndPoint
-
onIncompleteFlush
protected void onIncompleteFlush()
- Specified by:
onIncompleteFlush
in classAbstractEndPoint
-
onSelected
public java.lang.Runnable onSelected()
Description copied from interface:ManagedSelector.Selectable
Callback method invoked when a read or write events has been detected by theManagedSelector
for this endpoint.- Specified by:
onSelected
in interfaceManagedSelector.Selectable
- Returns:
- a job that may block or null
-
updateKey
public void updateKey()
Description copied from interface:ManagedSelector.Selectable
Callback method invoked when all the keys selected by theManagedSelector
for this endpoint have been processed.- Specified by:
updateKey
in interfaceManagedSelector.Selectable
-
toEndPointString
public java.lang.String toEndPointString()
- Overrides:
toEndPointString
in classAbstractEndPoint
-
-