org.mortbay.jetty.nio
Class HttpChannelEndPoint

java.lang.Object
  extended byorg.mortbay.io.nio.ChannelEndPoint
      extended byorg.mortbay.jetty.nio.SelectChannelConnector.SelectChannelEndPoint
          extended byorg.mortbay.jetty.nio.HttpChannelEndPoint
All Implemented Interfaces:
EndPoint, Runnable

public class HttpChannelEndPoint
extends SelectChannelConnector.SelectChannelEndPoint
implements Runnable


Nested Class Summary
 class HttpChannelEndPoint.IdleTask
           
 
Field Summary
protected  SelectionKey _key
           
 SelectChannelConnector.SelectSet _selectSet
           
protected  boolean _writable
           
 
Fields inherited from class org.mortbay.jetty.nio.SelectChannelConnector.SelectChannelEndPoint
_connection, _connector
 
Fields inherited from class org.mortbay.io.nio.ChannelEndPoint
_channel, _gather2, _gather3, _local, _remote, _socket
 
Constructor Summary
HttpChannelEndPoint(SelectChannelConnector connector, SocketChannel channel, SelectChannelConnector.SelectSet selectSet, SelectionKey key)
           
 
Method Summary
 void blockReadable(long timeoutMs)
           
 void blockWritable(long timeoutMs)
           
 void close()
          Close any backing stream associated with the buffer
 boolean dispatch(boolean assumeShortDispatch)
          Dispatch the endpoint by arranging for a thread to service it.
 int fill(Buffer buffer)
          Fill the buffer from the current putIndex to it's capacity from whatever byte source is backing the buffer.
 int flush(Buffer buffer)
          Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
 int flush(Buffer header, Buffer buffer, Buffer trailer)
          Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
 SelectChannelConnector.SelectSet getSelectSet()
           
 HttpChannelEndPoint.IdleTask getTimeoutTask()
           
 boolean isOpen()
           
 void run()
           
 void syncKey()
          Synchronize the interestOps with the actual key.
 String toString()
           
 void undispatch()
          Called when a dispatched thread is no longer handling the endpoint.
 
Methods inherited from class org.mortbay.jetty.nio.SelectChannelConnector.SelectChannelEndPoint
connectionClosed, connectionOpened
 
Methods inherited from class org.mortbay.io.nio.ChannelEndPoint
getChannel, getConnection, getLocalAddr, getLocalHost, getLocalPort, getRemoteAddr, getRemoteHost, getRemotePort, isBlocking
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_selectSet

public SelectChannelConnector.SelectSet _selectSet

_writable

protected boolean _writable

_key

protected SelectionKey _key
Constructor Detail

HttpChannelEndPoint

public HttpChannelEndPoint(SelectChannelConnector connector,
                           SocketChannel channel,
                           SelectChannelConnector.SelectSet selectSet,
                           SelectionKey key)
Method Detail

dispatch

public boolean dispatch(boolean assumeShortDispatch)
                 throws IOException
Dispatch the endpoint by arranging for a thread to service it. Either a blocked thread is woken up or the endpoint is passed to the server job queue. If the thread is dispatched and then the selection key is modified so that it is no longer selected.

Throws:
IOException

undispatch

public void undispatch()
Called when a dispatched thread is no longer handling the endpoint. The selection key operations are updated.


fill

public int fill(Buffer buffer)
         throws IOException
Description copied from interface: EndPoint
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.

Specified by:
fill in interface EndPoint
Overrides:
fill in class ChannelEndPoint
Throws:
IOException

flush

public int flush(Buffer header,
                 Buffer buffer,
                 Buffer trailer)
          throws IOException
Description copied from interface: EndPoint
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.

Specified by:
flush in interface EndPoint
Overrides:
flush in class ChannelEndPoint
Throws:
IOException

flush

public int flush(Buffer buffer)
          throws IOException
Description copied from interface: EndPoint
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.

Specified by:
flush in interface EndPoint
Overrides:
flush in class ChannelEndPoint
Throws:
IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface EndPoint
Overrides:
isOpen in class ChannelEndPoint

blockReadable

public void blockReadable(long timeoutMs)
Specified by:
blockReadable in interface EndPoint
Overrides:
blockReadable in class ChannelEndPoint

blockWritable

public void blockWritable(long timeoutMs)
Specified by:
blockWritable in interface EndPoint
Overrides:
blockWritable in class ChannelEndPoint

syncKey

public void syncKey()
Synchronize the interestOps with the actual key. Call is scheduled by a call to updateKey


run

public void run()
Specified by:
run in interface Runnable

close

public void close()
           throws IOException
Description copied from interface: EndPoint
Close any backing stream associated with the buffer

Specified by:
close in interface EndPoint
Overrides:
close in class SelectChannelConnector.SelectChannelEndPoint
Throws:
IOException

toString

public String toString()

getTimeoutTask

public HttpChannelEndPoint.IdleTask getTimeoutTask()

getSelectSet

public SelectChannelConnector.SelectSet getSelectSet()