private String getConfigPath(final BootstrapConfiguration bootstrap) throws ConfigurationException { String ret; if (bootstrap.isConfigurationPresent(CONFIG_PATH)) { ret = bootstrap.getConfiguration(CONFIG_PATH); } else if (bootstrap.isConfigurationPresent(OLD_CONFIG_PATH)) { ret = bootstrap.getConfiguration(OLD_CONFIG_PATH); } else { throw new ConfigurationException("Configuration parameter " + CONFIG_PATH + " not present"); } return ret; } }
/** * Checks whether the string substitution functionality should be enabled. * * @param bootstrapConfig used to provide basic, initial startup configuration * @return true if the configuration substitution should be performed */ private static boolean getIsSubstitutorEnabled(final BootstrapConfiguration bootstrapConfig) { final String ENABLE_SUBSTITUTOR_CONFIG_KEY = "CAF_CONFIG_ENABLE_SUBSTITUTOR"; final boolean ENABLE_SUBSTITUTOR_CONFIG_DEFAULT = true; // Return the default if the setting is not configured if (!bootstrapConfig.isConfigurationPresent(ENABLE_SUBSTITUTOR_CONFIG_KEY)) { return ENABLE_SUBSTITUTOR_CONFIG_DEFAULT; } // Return the configured setting. // The ConfigurationException should never happen since isConfigurationPresent() has already been called. try { return bootstrapConfig.getConfigurationBoolean(ENABLE_SUBSTITUTOR_CONFIG_KEY); } catch (final ConfigurationException ex) { throw new RuntimeException(ex); } }
public static WorkerServices create() throws ModuleLoaderException, CipherException, ConfigurationException, DataStoreException { Codec codec = ModuleLoader.getService(Codec.class); ConfigurationDecoderProvider decoderProvider = ModuleLoader.getService(ConfigurationDecoderProvider.class, CafConfigurationDecoderProvider.class); Decoder decoder = decoderProvider.getDecoder(bootstrapConfiguration, codec); Cipher cipher = ModuleLoader.getService(CipherProvider.class, NullCipherProvider.class).getCipher(bootstrapConfiguration); ServicePath path = bootstrapConfiguration.getServicePath(); ConfigurationSource configurationSource = ModuleLoader.getService(ConfigurationSourceProvider.class).getConfigurationSource(bootstrapConfiguration, cipher, path, decoder); DataStore dataStore = ModuleLoader.getService(DataStoreProvider.class).getDataStore(configurationSource); return new WorkerServices(bootstrapConfiguration, codec, cipher, configurationSource, dataStore); } }
ServicePath servicePath = bootstrap.getServicePath(); Codec codec = ModuleLoader.getService(Codec.class); Cipher cipher = ModuleLoader.getService(CipherProvider.class, NullCipherProvider.class).getCipher(bootstrap);