private void initRequestHandler ( ServletContext context , Properties configProps ) throws ServletException { long initialTime = System . currentTimeMillis ( ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Initializing jawr config for request handler named " + getInitParameter ( "handlerName" ) ) ; this . servletContext = context ; this . overrideProperties = configProps ; resourceType = getInitParameter ( "type" ) ; resourceType = null == resourceType ? "js" : resourceType ; if ( resourceType . equals ( "img" ) ) { throw new BundlingProcessException ( "The resource type 'img' is not supported since the version 3.6. You should use the type 'binary' instead." ) ; } // Check if the resource type is a valid one if ( ! ( resourceType . equals ( JawrConstant . JS_TYPE ) || resourceType . equals ( JawrConstant . CSS_TYPE ) || resourceType . equals ( JawrConstant . BINARY_TYPE ) ) ) { throw new BundlingProcessException ( "Unknown resource Type:" + resourceType ) ; } // Initialize the config properties source that will provide with all // configuration options. ConfigPropertiesSource propsSrc = initConfigPropertiesSource ( context , configProps ) ; // Read properties from properties source Properties props = propsSrc . getConfigProperties ( ) ; // override the properties if needed if ( this . overrideProperties != null ) { props . putAll ( overrideProperties ) ; } // hang onto the propertiesSource for manual reloads this . propertiesSource = propsSrc ; // Initialize the ConfigPropertyResolver initConfigPropertyResolver ( context ) ; initializeJawrContext ( props ) ; // Initialize the properties reloading checker daemon if specified if ( ! ThreadLocalJawrContext . isBundleProcessingAtBuildTime ( ) && null != props . getProperty ( CONFIG_RELOAD_INTERVAL ) ) { int interval = Integer . parseInt ( props . getProperty ( CONFIG_RELOAD_INTERVAL ) ) ; LOGGER . warn ( "Jawr started with configuration auto reloading on. " + "Be aware that a daemon thread will be checking for changes to configuration every " + interval + " seconds." ) ; this . configChangeListenerThread = new ConfigChangeListenerThread ( this . resourceType , propsSrc , this . overrideProperties , this , this . bundlesHandler , interval ) ; configChangeListenerThread . start ( ) ; } if ( this . bundlesHandler != null && jawrConfig . getUseSmartBundling ( ) ) { this . watcher = new ResourceWatcher ( this . bundlesHandler , this . rsReaderHandler ) ; this . bundlesHandler . setResourceWatcher ( watcher ) ; try { this . watcher . initPathToResourceBundleMap ( this . bundlesHandler . getGlobalBundles ( ) ) ; this . watcher . initPathToResourceBundleMap ( this . bundlesHandler . getContextBundles ( ) ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Impossible to initialize Jawr Resource Watcher" , e ) ; } this . watcher . start ( ) ; } if ( LOGGER . isInfoEnabled ( ) ) { long totaltime = System . currentTimeMillis ( ) - initialTime ; LOGGER . info ( "Init method successful. jawr started in " + ( totaltime / 1000 ) + " seconds...." ) ; } // Reset ThreadLocalJawrContext ThreadLocalJawrContext . reset ( ) ; }
Initialize the request handler