Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.io.nio
Class SelectChannelEndPoint

    java.lang.Object
      org.mortbay.io.nio.ChannelEndPoint
          org.mortbay.io.nio.SelectChannelEndPoint

All Implemented Interfaces:
  java.lang.Runnable, EndPoint

Direct Known Subclasses:
  SelectChannelConnector.ConnectorEndPoint

    public class SelectChannelEndPoint

extends ChannelEndPoint
implements java.lang.Runnable

An Endpoint that can be scheduled by `SelectorManager`.

Author:
  gregw

Nested Class Summary
`class` | `SelectChannelEndPoint.IdleTask`

Field Summary
`protected Connection` | `_connection`
`protected boolean` | `_dispatched`
`protected int` | `_interestOps`
`protected java.nio.channels.SelectionKey` | `_key`
`protected SelectorManager` | `_manager`
`protected boolean` | `_readBlocked`
`protected SelectorManager.SelectSet` | `_selectSet`
`protected boolean` | `_writable`
`protected boolean` | `_writeBlocked`

Fields inherited from class org.mortbay.io.nio.ChannelEndPoint
`_channel, _gather2, _local, _remote, _socket`

Constructor Summary
`SelectChannelEndPoint(java.nio.channels.SocketChannel channel, SelectorManager.SelectSet selectSet, java.nio.channels.SelectionKey key)`

Method Summary
`boolean` | `blockReadable(long timeoutMs)`
`boolean` | `blockWritable(long timeoutMs)`
`void` | `cancelIdle()`
`void` | `close()` Close any backing stream associated with the buffer
`boolean` | `dispatch(boolean assumeShortDispatch)` Put the endpoint into the dispatched state.
`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.
`Connection` | `getConnection()`
`SelectorManager.SelectSet` | `getSelectSet()`
`Timeout.Task` | `getTimeoutTask()`
`protected void` | `idleExpired()`
`void` | `run()`
`void` | `scheduleIdle()`
`void` | `scheduleWrite()`
`void` | `setWritable(boolean writable)`
`java.lang.String` | `toString()`
`void` | `undispatch()` Called when a dispatched thread is no longer handling the endpoint.

Methods inherited from class org.mortbay.io.nio.ChannelEndPoint
`fill, flush, getChannel, getLocalAddr, getLocalHost, getLocalPort, getRemoteAddr, getRemoteHost, getRemotePort, getTransport, isBlocking, isBufferingInput, isBufferingOutput, isBufferred, isOpen, shutdownOutput`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### _manager

    protected SelectorManager _manager

### _selectSet

    protected SelectorManager.SelectSet _selectSet

### _dispatched

    protected boolean _dispatched

### _writable

    protected boolean _writable

### _key

    protected java.nio.channels.SelectionKey _key

### _interestOps

    protected int _interestOps

### _readBlocked

    protected boolean _readBlocked

### _writeBlocked

    protected boolean _writeBlocked

### _connection

    protected Connection _connection

Constructor Detail

### SelectChannelEndPoint

    public SelectChannelEndPoint(java.nio.channels.SocketChannel channel,
                                 SelectorManager.SelectSet selectSet,
                                 java.nio.channels.SelectionKey key)

Method Detail

### getConnection

    public Connection getConnection()

### dispatch

    public boolean dispatch(boolean assumeShortDispatch)
                     throws java.io.IOException

  Put the endpoint into the dispatched state. A blocked thread may be woken up by this call, or the endpoint placed in a state ready for a dispatch to a threadpool.

  Parameters:
    `assumeShortDispatch` - If true, the interested ops are not modified.
  Returns:
    True if the endpoint should be dispatched to a thread pool.
  Throws:
    `java.io.IOException`

### scheduleIdle

    public void scheduleIdle()

### cancelIdle

    public void cancelIdle()

### idleExpired

    protected void idleExpired()

### undispatch

    public void undispatch()

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

### flush

    public int flush(Buffer header,
                     Buffer buffer,
                     Buffer trailer)
              throws java.io.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`
  Parameters:
    `header` - A buffer to write before flushing this buffer. This buffers getIndex is updated.
    `buffer` - The buffer to flush. This buffers getIndex is updated.
    `trailer` - A buffer to write after flushing this buffer. This buffers getIndex is updated.
  Returns:
    the total number of bytes written.
  Throws:
    `java.io.IOException`

### flush

    public int flush(Buffer buffer)
              throws java.io.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`
  Parameters:
    `buffer` - The buffer to flush. This buffers getIndex is updated.
  Returns:
    the number of bytes written
  Throws:
    `java.io.IOException`

### blockReadable

    public boolean blockReadable(long timeoutMs)
                          throws java.io.IOException

  Specified by:
    `blockReadable` in interface `EndPoint`
  Overrides:
    `blockReadable` in class `ChannelEndPoint`
  Throws:
    `java.io.IOException`

### blockWritable

    public boolean blockWritable(long timeoutMs)
                          throws java.io.IOException

  Specified by:
    `blockWritable` in interface `EndPoint`
  Overrides:
    `blockWritable` in class `ChannelEndPoint`
  Throws:
    `java.io.IOException`

### setWritable

    public void setWritable(boolean writable)

### scheduleWrite

    public void scheduleWrite()

### run

    public void run()

  Specified by:
    `run` in interface `java.lang.Runnable`

### close

    public void close()
               throws java.io.IOException

  Description copied from interface: `EndPoint`
  Close any backing stream associated with the buffer

  Specified by:
    `close` in interface `EndPoint`
  Overrides:
    `close` in class `ChannelEndPoint`
  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getTimeoutTask

    public Timeout.Task getTimeoutTask()

### getSelectSet

    public SelectorManager.SelectSet getSelectSet()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.