Top Description Inners Fields Constructors Methods
org.mortbay.io.nio

public Class SelectChannelEndPoint

extends ChannelEndPoint
implements Runnable, AsyncEndPoint
Class Inheritance
All Implemented Interfaces
org.mortbay.io.AsyncEndPoint, org.mortbay.io.EndPoint, java.lang.Runnable
Imports
java.io.IOException, java.nio.channels.ClosedChannelException, .SelectableChannel, .SelectionKey, .SocketChannel, org.mortbay.io.AsyncEndPoint, .Buffer, .Connection, org.mortbay.io.nio.SelectorManager.SelectSet, org.mortbay.jetty.EofException, .HttpException, org.mortbay.log.Log, org.mortbay.thread.Timeout

An Endpoint that can be scheduled by SelectorManager.
Author
gregw

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
protected Connection
protected boolean
private Timeout.Task
protected int
protected SelectionKey
protected SelectorManager
private boolean
protected boolean
protected boolean
protected SelectorManager.SelectSet
protected boolean
protected boolean
Inherited from org.mortbay.io.nio.ChannelEndPoint:
_channel_gather2_local_remote_socket

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public void
public void
close()

Overrides org.mortbay.io.nio.ChannelEndPoint.close.

Implements org.mortbay.io.EndPoint.close.

Close any backing stream associated with the buffer
public boolean
dispatch()

Implements org.mortbay.io.AsyncEndPoint.dispatch.

Dispatch the endpoint to a thread to attend to it.
pack-priv void
doUpdateKey()

Synchronize the interestOps with the actual key.

public int
flush(Buffer
A buffer to write before flushing this buffer. This buffers getIndex is updated.
header
,
Buffer
The buffer to flush. This buffers getIndex is updated.
buffer
,
Buffer
A buffer to write after flushing this buffer. This buffers getIndex is updated.
trailer
)

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
public int
flush(Buffer
The buffer to flush. This buffers getIndex is updated.
buffer
)

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
public Connection
public SelectorManager.SelectSet
public Timeout.Task
protected void
public boolean
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public void
schedule()

Called by selectSet to schedule handling

public void
public void
public void
setWritable(boolean writable)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected boolean
undispatch()

Called when a dispatched thread is no longer handling the endpoint.

private void
updateKey()

Updates selection key.

Inherited from org.mortbay.io.nio.ChannelEndPoint:
fillflushgetChannelgetLocalAddrgetLocalHostgetLocalPortgetRemoteAddrgetRemoteHostgetRemotePortgetTransportisBlockingisBufferingInputisBufferingOutputisBufferredisOpen

Field Detail

_connectionback to summary
protected Connection _connection
_dispatchedback to summary
protected boolean _dispatched
_idleTaskback to summary
private Timeout.Task _idleTask
_interestOpsback to summary
protected int _interestOps
_keyback to summary
protected SelectionKey _key
_managerback to summary
protected SelectorManager _manager
_openback to summary
private boolean _open
_readBlockedback to summary
protected boolean _readBlocked
_redispatchedback to summary
protected boolean _redispatched
_selectSetback to summary
protected SelectorManager.SelectSet _selectSet
_writableback to summary
protected boolean _writable
_writeBlockedback to summary
protected boolean _writeBlocked

Constructor Detail

SelectChannelEndPointback to summary
public SelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key)

Method Detail

blockReadableback to summary
public boolean blockReadable(long timeoutMs) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.blockReadable.

Implements org.mortbay.io.EndPoint.blockReadable.

blockWritableback to summary
public boolean blockWritable(long timeoutMs) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.blockWritable.

Implements org.mortbay.io.EndPoint.blockWritable.

cancelIdleback to summary
public void cancelIdle()
closeback to summary
public void close() throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.close.

Implements org.mortbay.io.EndPoint.close.

Doc from org.mortbay.io.EndPoint.close.

Close any backing stream associated with the buffer

dispatchback to summary
public boolean dispatch()

Implements org.mortbay.io.AsyncEndPoint.dispatch.

Doc from org.mortbay.io.AsyncEndPoint.dispatch.

Dispatch the endpoint to a thread to attend to it.

Returns:boolean

True If the dispatched succeeded

doUpdateKeyback to summary
pack-priv void doUpdateKey()

Synchronize the interestOps with the actual key. Call is scheduled by a call to updateKey

flushback to summary
public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Doc from org.mortbay.io.EndPoint.flush.

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.

Parameters
header:Buffer

A buffer to write before flushing this buffer. This buffers getIndex is updated.

buffer:Buffer

The buffer to flush. This buffers getIndex is updated.

trailer:Buffer

A buffer to write after flushing this buffer. This buffers getIndex is updated.

Returns:int

the total number of bytes written.

flushback to summary
public int flush(Buffer buffer) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Doc from org.mortbay.io.EndPoint.flush.

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.

Parameters
buffer:Buffer

The buffer to flush. This buffers getIndex is updated.

Returns:int

the number of bytes written

getConnectionback to summary
public Connection getConnection()
getSelectSetback to summary
public SelectorManager.SelectSet getSelectSet()
getTimeoutTaskback to summary
public Timeout.Task getTimeoutTask()
idleExpiredback to summary
protected void idleExpired()
isReadyForDispatchback to summary
public boolean isReadyForDispatch()

Implements org.mortbay.io.AsyncEndPoint.isReadyForDispatch.

Returns:boolean

Doc from org.mortbay.io.AsyncEndPoint.isReadyForDispatch.

true if this endpoint can accept a dispatch. False if the endpoint cannot accept a dispatched (eg is suspended or already dispatched)

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

scheduleback to summary
public void schedule() throws IOException

Called by selectSet to schedule handling

scheduleIdleback to summary
public void scheduleIdle()
scheduleWriteback to summary
public void scheduleWrite()
setWritableback to summary
public void setWritable(boolean writable)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

undispatchback to summary
protected boolean undispatch()

Called when a dispatched thread is no longer handling the endpoint. The selection key operations are updated.

updateKeyback to summary
private void updateKey()

Updates selection key. Adds operations types to the selection key as needed. No operations are removed as this is only done during dispatch. This method records the new key and schedules a call to doUpdateKey to do the keyChange

org.mortbay.io.nio back to summary

public Class SelectChannelEndPoint.IdleTask

extends Task
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.mortbay.thread.Timeout.Task:
cancelexpiregetAgegetTimestampisExpiredisScheduledreschedulescheduleschedule

Constructor Detail

IdleTaskback to summary
public IdleTask()

Method Detail

expiredback to summary
public void expired()

Overrides org.mortbay.thread.Timeout.Task.expired.

Doc from org.mortbay.thread.Timeout.Task.expired.

Expire task. This method is called when the timeout expires. It is called outside of any synchronization scope and may be delayed.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object