## com.sun.grizzly
Interface SelectionKeyHandler

All Superinterfaces:
  Copyable, Handler

All Known Implementing Classes:
  BaseSelectionKeyHandler, CacheableSelectionKeyHandler, DefaultSelectionKeyHandler

    public interface SelectionKeyHandler

extends Handler, Copyable

A SelectionKeyHandler is used to handle the life cycle of a SelectionKey. Operations like cancelling, registering or closing are handled by SelectionKeyHandler.

Author:
  Jeanfrancois Arcand

Method Summary
`void` `cancel(SelectionKey key)` Cancel a SelectionKey and close its Channel.
`void` `close(SelectionKey key)` Close the SelectionKey's channel input or output, but keep alive the SelectionKey.
`void` `expire(Iterator<SelectionKey> keyIterator)` Expire a `SelectionKey` set.
`void` `expire(SelectionKey key, long currentTime)` Deprecated.
`SelectorHandler` `getSelectorHandler()` Get associated `SelectorHandler`
`void` `postProcess(SelectionKey key)` `SelectionKey` post process notification
`void` `process(SelectionKey key)` `SelectionKey` process notification
`void` `register(Iterator<SelectionKey> keyIterator, int selectionKeyOps)` Register a set of `SelectionKey`s.
`void` `register(SelectableChannel channel, int selectionKeyOps)` Register a `SelectableChannel` on `Selector`.
`void` `register(SelectionKey key, int selectionKeyOps)` Register a `SelectionKey` on `Selector`.
`void` `register(SelectionKey key, long currentTime)` Attach a times out to the SelectionKey used to cancel idle connection.
`void` `setSelectorHandler(SelectorHandler selectorHandler)` Set associated `SelectorHandler`

Methods inherited from interface com.sun.grizzly.util.Copyable
`copyTo`

Method Detail

### getSelectorHandler

    SelectorHandler getSelectorHandler()

  Get associated `SelectorHandler`

### setSelectorHandler

    void setSelectorHandler(SelectorHandler selectorHandler)

  Set associated `SelectorHandler`

### process

    void process(SelectionKey key)

  `SelectionKey` process notification

  Parameters:
    `key` - `SelectionKey` to process

### postProcess

    void postProcess(SelectionKey key)

  `SelectionKey` post process notification

  Parameters:
    `key` - `SelectionKey` to process

### register

    void register(SelectionKey key,
                  long currentTime)

  Attach a times out to the SelectionKey used to cancel idle connection. Null when the feature is not required.

  Parameters:
    `key` - `SelectionKey` to register
    `currentTime` - the System.currentTimeMillis

### register

    void register(SelectionKey key,
                  int selectionKeyOps)

  Register a `SelectionKey` on `Selector`.

  Parameters:
    `key` - `SelectionKey`
    `selectionKeyOps` - The interest set to apply when registering. to register

### register

    void register(SelectableChannel channel,
                  int selectionKeyOps)
                  throws ClosedChannelException

  Register a `SelectableChannel` on `Selector`.

  Parameters:
    `channel` - `SelectableChannel`
    `selectionKeyOps` - The interest set to apply when registering. to register
  Throws:
    `ClosedChannelException`

### register

    void register(Iterator<SelectionKey> keyIterator,
                  int selectionKeyOps)

  Register a set of `SelectionKey`s. Note: After processing each `SelectionKey` it should be removed from `Iterator`

  Parameters:
    `selectionKeySet` - `Iterator` of `SelectionKey`s
    `selectionKeyOps` - The interest set to apply when registering. to register

### expire

    void expire(SelectionKey key,
                long currentTime)

  Deprecated.

  Expire a `SelectionKey`. If a `SelectionKey` is inactive for certain time (timeout), the `SelectionKey` will be cancelled and its associated Channel closed.

  Parameters:
    `key` - `SelectionKey` to expire
    `currentTime` - the System.currentTimeMillis

### expire

    void expire(Iterator<SelectionKey> keyIterator)

  Expire a `SelectionKey` set. Method checks each `SelectionKey` from the`Set`. And if a `SelectionKey` is inactive for certain time (timeout), the `SelectionKey` will be cancelled and its associated Channel closed.

  Parameters:
    `keyIterator` - `Iterator` of `SelectionKey`s to expire

### cancel

    void cancel(SelectionKey key)

  Cancel a SelectionKey and close its Channel.

  Parameters:
    `key` - `SelectionKey` to cancel

### close

    void close(SelectionKey key)

  Close the SelectionKey's channel input or output, but keep alive the SelectionKey.

  Parameters:
    `key` - `SelectionKey` to close

Copyright © 2008 SUN Microsystems. All Rights Reserved.