public static void injectConfigurations ( String karafEtc , String applicationName , String scopedInstancePath , String domain , String ipAddress ) { File injectionDir = new File ( karafEtc , INJECTED_CONFIGS_DIR ) ; if ( injectionDir . isDirectory ( ) ) { for ( File source : Utils . listAllFiles ( injectionDir , ".cfg.tpl" ) ) { try { File target = new File ( karafEtc , source . getName ( ) . replaceFirst ( "\\.tpl$" , "" ) ) ; // Do not overwrite the agent's configuration file (infinite configuration loop) if ( Constants . KARAF_CFG_FILE_AGENT . equalsIgnoreCase ( target . getName ( ) ) ) continue ; String content = Utils . readFileContent ( source ) ; content = content . replace ( "<domain>" , domain ) ; content = content . replace ( "<application-name>" , applicationName ) ; content = content . replace ( "<scoped-instance-path>" , scopedInstancePath ) ; content = content . replace ( "<ip-address>" , ipAddress ) ; Utils . writeStringInto ( content , target ) ; } catch ( IOException e ) { Logger logger = Logger . getLogger ( AgentUtils . class . getName ( ) ) ; logger . severe ( "A configuration file could not be injected from " + source . getName ( ) ) ; Utils . logException ( logger , e ) ; } } } }
Generates configuration files from templates .