FileDocCategorySizeDatePackage
SelectorThreadConfig.javaAPI DocGlassfish v2 API12962Wed Jun 27 08:31:24 BST 2007com.sun.enterprise.web.connector.grizzly

SelectorThreadConfig

public class SelectorThreadConfig extends Object

Fields Summary
private static final String
SELECTOR_TIMEOUT
System property for the selector timeout value.
private static final String
MIN_THREAD
The minimum number of threads used when creating a new Pipeline
private static final String
MAX_THREAD
The maximum number of threads used when creating a new Pipeline
private static final String
DISPLAY_CONFIGURATION
Property used to turn on/off NIO blocking mode.
private static final String
MAX_KEEP_ALIVE_REQUEST
private static final String
ENABLE_COMET_SUPPORT
private static final String
DIRECT_BYTE_BUFFER_READ
Is the ByteBuffer used by the ReadTask use direct ByteBuffer or not.
private static final String
PIPELINE_CLASS
Always attach a ProcessorTask when creating a ReadTask
private static final String
MAX_SELECTOR_READ_THREAD
private static final String
HTTP_HEADER_BUFFER_SIZE
private static final String
BYTE_BUFFER_VIEW
private static final String
ALGORITHM_CLASS_NAME
private static final String
MAX_SELECTOR
private static final String
FACTORY_TIMEOUT
private static final String
ASYNCH_HANDLER_CLASS
private static final String
ASYNCH_HANDLER_PORT
private static final String
SNOOP_LOGGING
private static final String
TEMPORARY_SELECTOR_TIMEOUT
private static final String
WRITE_TIMEOUT
private static final String
NOTIFICATION_HANDLER
private static final String
BUFFER_RESPONSE
private static final String
OOBInline
Constructors Summary
Methods Summary
public static voidconfigure(SelectorThread selectorThread)
Configure properties on SelectorThread

        configureProperties(selectorThread);
    
protected static voidconfigureProperties(SelectorThread selectorThread)
Read systems properties and configure the SelectorThread.

 
    // --------------------------------------------------------- Static -----//


               
        
        if (System.getProperty(SELECTOR_TIMEOUT) != null){
            try{
                selectorThread.selectorTimeout = 
                      Integer.parseInt(System.getProperty(SELECTOR_TIMEOUT));
            } catch (NumberFormatException ex){
                SelectorThread.logger().log(Level.WARNING, "selectorThread.invalidSelectorTimeout");
            }
        }

        if (System.getProperty(TEMPORARY_SELECTOR_TIMEOUT) != null){
            try{
                int timeout =  Integer.parseInt(
                        System.getProperty(TEMPORARY_SELECTOR_TIMEOUT));
                ByteBufferInputStream.setDefaultReadTimeout(timeout);
                SSLUtils.setReadTimeout(timeout);
            } catch (NumberFormatException ex){
                SelectorThread.logger().log(Level.WARNING, 
                                            "selectorThread.invalidReadTimeout");
            }
        }             

        if (System.getProperty(WRITE_TIMEOUT) != null){
            try{
                int timeout =  Integer.parseInt(
                        System.getProperty(WRITE_TIMEOUT));
                OutputWriter.setDefaultWriteTimeout(timeout);
            } catch (NumberFormatException ex){
                SelectorThread.logger().log(Level.WARNING, 
                                            "selectorThread.invalidWriteTimeout");
            }
        } 
        
        if (System.getProperty(MIN_THREAD) != null){
            try{
                selectorThread.minWorkerThreads = 
                    Integer.parseInt(System.getProperty(MIN_THREAD));
            } catch (NumberFormatException ex){
                SelectorThread.logger().log(Level.WARNING, "selectorThread.invalidMinThreads");
            }
        }    
        
        
        if (System.getProperty(MAX_THREAD) != null){
            try{
                selectorThread.maxProcessorWorkerThreads = 
                    Integer.parseInt(System.getProperty(MAX_THREAD));
            } catch (NumberFormatException ex){
                SelectorThread.logger().log(Level.WARNING, "selectorThread.invalidMaxThreads");
            }
        }  
        
        if (System.getProperty(DISPLAY_CONFIGURATION)!= null){
            selectorThread.displayConfiguration = 
                Boolean.valueOf(System.getProperty(DISPLAY_CONFIGURATION))
                                                                .booleanValue();
        }
        
        if (System.getProperty(OOBInline)!= null){
            selectorThread.oOBInline = 
                Boolean.valueOf(System.getProperty(OOBInline)).booleanValue();
        }
        
        if (System.getProperty(ENABLE_COMET_SUPPORT) != null){
            selectorThread.enableCometSupport(
                Boolean.valueOf(
                    System.getProperty(ENABLE_COMET_SUPPORT)).booleanValue());
        }       
        
        if (System.getProperty(ASYNCH_HANDLER_PORT) != null){
            String ports = System.getProperty(ASYNCH_HANDLER_PORT);
            StringTokenizer st = new StringTokenizer(ports,",");
            while(st.hasMoreTokens()){
                
                if ( st.nextToken()
                        .equals(String.valueOf(selectorThread.getPort()))
                        && System.getProperty(ASYNCH_HANDLER_CLASS)!= null){
                    
                    selectorThread.asyncHandler = (AsyncHandler)
                        loadClassAndInstanciate(
                            System.getProperty(ASYNCH_HANDLER_CLASS)); 
                    selectorThread.asyncExecution = true;
                }
            }
        }           
        
        if (System.getProperty(DIRECT_BYTE_BUFFER_READ)!= null){
            selectorThread.useDirectByteBuffer = 
                Boolean.valueOf(
                    System.getProperty(DIRECT_BYTE_BUFFER_READ)).booleanValue();
        }        
       
        if (System.getProperty(MAX_KEEP_ALIVE_REQUEST) != null){
            try{
                selectorThread.maxKeepAliveRequests = 
                  Integer.parseInt(System.getProperty(MAX_KEEP_ALIVE_REQUEST));
            } catch (NumberFormatException ex){
                ;
            }
        }
        
        if (System.getProperty(PIPELINE_CLASS)!= null){
            selectorThread.pipelineClassName = 
                                            System.getProperty(PIPELINE_CLASS);
        }    
        
        if (System.getProperty(NOTIFICATION_HANDLER)!= null){
            CometEngine.setNotificationHandlerClassName( 
                System.getProperty(NOTIFICATION_HANDLER));
        }    
                
        if (System.getProperty(ALGORITHM_CLASS_NAME)!= null){
            selectorThread.algorithmClassName = 
                                      System.getProperty(ALGORITHM_CLASS_NAME);
        }   

        if (System.getProperty(BYTE_BUFFER_VIEW)!= null){
            selectorThread.useByteBufferView = 
                Boolean.valueOf(
                            System.getProperty(BYTE_BUFFER_VIEW)).booleanValue();
        }    
             
        if (System.getProperty(MAX_SELECTOR_READ_THREAD) != null){
            try{
                selectorThread.multiSelectorsCount = 
                  Integer.parseInt(System.getProperty(MAX_SELECTOR_READ_THREAD));
            } catch (NumberFormatException ex){
                ;
            }
        }
        
        if (System.getProperty(MAX_SELECTOR) != null){
            try{
                SelectorFactory.maxSelectors = 
                  Integer.parseInt(System.getProperty(MAX_SELECTOR));
            } catch (NumberFormatException ex){
                ;
            }
        }

        if (System.getProperty(FACTORY_TIMEOUT) != null){
            try{
                SelectorFactory.timeout = 
                  Integer.parseInt(System.getProperty(FACTORY_TIMEOUT));
            } catch (NumberFormatException ex){
                ;
            }
        }     
        
        if (System.getProperty(SNOOP_LOGGING)!= null){
            selectorThread.setEnableNioLogging( 
                Boolean.valueOf(
                            System.getProperty(SNOOP_LOGGING)).booleanValue());
        } 
               
        if (System.getProperty(BUFFER_RESPONSE)!= null){
            selectorThread.setBufferResponse( 
                Boolean.valueOf(
                            System.getProperty(BUFFER_RESPONSE)).booleanValue());
        }  
    
private static java.lang.ObjectloadClassAndInstanciate(java.lang.String className)

         try{
            Class clazz = Class.forName(className);
            return clazz.newInstance();
        } catch (Throwable ex){
            SelectorThread.logger().log(Level.SEVERE,ex.getMessage()
                + ":" + className, ex);          
        }
        return null;