com.sun.enterprise.web.connector.grizzly
Class SelectorFactory

java.lang.Object
  extended by com.sun.enterprise.web.connector.grizzly.SelectorFactory

public class SelectorFactory
extends Object

Factory used to dispatch/share Selector.

Author:
Scott Oaks, Jean-Francois Arcand, gustav trede

Field Summary
static int DEFAULT_MAX_SELECTORS
           
 
Constructor Summary
SelectorFactory()
           
 
Method Summary
static void changeSelectorsBy(int delta)
          Changes the Selector cache size
protected static Selector createSelector()
          Creeate Selector
static int getMaxSelectors()
          Returns max selector pool size
static Selector getSelector()
          Please ensure to use try finally around get and return of selector so avoid leaks.
static long getTimeout(TimeUnit timeUnit)
           
static void reimburseSelector()
          Add Selector to the cache.
static void returnSelector(Selector s)
          Please ensure to use try finally around get and return of selector so avoid leaks.
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.
static void setTimeout(long timeout, TimeUnit timeUnit)
           
 
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
Constructor Detail

SelectorFactory

public SelectorFactory()
Method Detail

setMaxSelectors

public static void setMaxSelectors(int size)
                            throws IOException
Set max selector pool size.

Parameters:
size - max pool size
Throws:
IOException

changeSelectorsBy

public static void changeSelectorsBy(int delta)
                              throws IOException
Changes the Selector cache size

Parameters:
delta -
Throws:
IOException

getMaxSelectors

public static int getMaxSelectors()
Returns max selector pool size

Returns:
max pool size

getSelector

public static Selector getSelector()
Please ensure to use try finally around get and return of selector so avoid leaks. Get a exclusive Selector

Returns:
Selector

returnSelector

public static void returnSelector(Selector s)
Please ensure to use try finally around get and return of selector so avoid leaks. Return the Selector to the cache

Parameters:
s - Selector

selectNowAndReturnSelector

public static void selectNowAndReturnSelector(Selector s)
Executes Selector.selectNow() and returns the Selector to the cache


reimburseSelector

public static 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

getTimeout

public static long getTimeout(TimeUnit timeUnit)

setTimeout

public static void setTimeout(long timeout,
                              TimeUnit timeUnit)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.