## com.sun.grizzly.util
Class SelectorFactory

    java.lang.Object
      com.sun.grizzly.util.SelectorFactory

    public class SelectorFactory

extends Object

Factory used to dispatch/share `Selector`.

Author:
  Scott Oaks, Jean-Francois Arcand

Field Summary
`static int` `DEFAULT_MAX_SELECTORS`
`static long` `timeout` The timeout before we exit.

Constructor Summary
`SelectorFactory()`

Method Summary
`protected static Selector` `createSelector()` Creeate Selector
`static int` `getMaxSelectors()` Returns max selector pool size
`static Selector` `getSelector()` Get a exclusive `Selector`
`static void` `reimburseSelector()` Add Selector to the cache.
`static void` `returnSelector(Selector s)` Return the `Selector` to the cache
`static void` `selectNowAndReturnSelector(Selector s)` Executes `Selector.selectNow()` and returns the `Selector` to the cache
`static void` `setMaxSelectors(int size)` Set max selector pool size.

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

Field Detail

### DEFAULT_MAX_SELECTORS

    public static final int DEFAULT_MAX_SELECTORS

See Also:
  Constant Field Values

### timeout

    public static long timeout

  The timeout before we exit.

Constructor Detail

### SelectorFactory

    public SelectorFactory()

Method Detail

### setMaxSelectors

    public static final void setMaxSelectors(int size)
                                      throws IOException

  Set max selector pool size.

  Parameters:
    `size` - max pool size
  Throws:
    `IOException`

### getMaxSelectors

    public static final int getMaxSelectors()

  Returns max selector pool size

  Returns:
    max pool size

### getSelector

    public static final Selector getSelector()

  Get a exclusive `Selector`

  Returns:
    `Selector`

### returnSelector

    public static final void returnSelector(Selector s)

  Return the `Selector` to the cache

  Parameters:
    `s` - `Selector`

### selectNowAndReturnSelector

    public static final void selectNowAndReturnSelector(Selector s)

  Executes `Selector.selectNow()` and returns the `Selector` to the cache

### reimburseSelector

    public static final void reimburseSelector()
                                        throws IOException

  Add Selector to the cache. This method could be called to reimberse a lost or problematic Selector.

  Throws:
    `IOException`

### createSelector

    protected static Selector createSelector()
                                      throws IOException

  Creeate Selector

  Returns:
    Selector
  Throws:
    `IOException`

Copyright © 2008 SUN Microsystems. All Rights Reserved.