private ConfigPropertiesSource initConfigPropertiesSource ( ServletContext context , Properties configProps ) throws ServletException { String configLocation = getInitParameter ( "configLocation" ) ; String configPropsSourceClass = getInitParameter ( "configPropertiesSourceClass" ) ; if ( null == configProps && null == configLocation && null == configPropsSourceClass ) throw new ServletException ( "Neither configLocation nor configPropertiesSourceClass init params were set." + " You must set at least the configLocation param. Please check your web.xml file" ) ; // Initialize the config properties source that will provide with all // configuration options. ConfigPropertiesSource propsSrc = null ; // Load a custom class to set config properties if ( null != configPropsSourceClass ) { propsSrc = ( ConfigPropertiesSource ) ClassLoaderResourceUtils . buildObjectInstance ( configPropsSourceClass ) ; if ( propsSrc instanceof ServletContextAware ) { ( ( ServletContextAware ) propsSrc ) . setServletContext ( context ) ; } } else if ( configLocation == null && configProps != null ) { // configuration retrieved from the in memory configuration // properties propsSrc = new PropsConfigPropertiesSource ( configProps ) ; } else { // Default config properties source, reads from a .properties file // in the classpath. propsSrc = new PropsFilePropertiesSource ( ) ; } // If a custom properties source is a subclass of // PropsFilePropertiesSource, we hand it the configLocation param. // This affects the standard one as well. if ( propsSrc instanceof PropsFilePropertiesSource ) ( ( PropsFilePropertiesSource ) propsSrc ) . setConfigLocation ( configLocation ) ; return propsSrc ; }
Initialize the config properties source that will provide with all configuration options .