Example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration.

Prototype

public PropertiesConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Creates and loads the extended properties from the specified URL.

Usage

From source file:com.microrisc.simply.config.ConfigurationReader.java

/**
 * Creates configuration from specified .property file.
 * @param file source property file//ww  w . j  a  va  2  s  . co m
 * @return configuration
 */
private static Configuration createConfigurationFromProperties(String file) throws ConfigurationException {
    return new PropertiesConfiguration(file);
}

From source file:com.brunomcustodio.dojo.keycloak.auth.AuthServiceEndpointsImpl.java

public AuthServiceEndpointsImpl() throws ConfigurationException {
    Configuration config = new PropertiesConfiguration("auth.properties");

    bauth = BasicAuth.createHeader(config.getString("keycloak.client"), config.getString("keycloak.secret"));
    realm = config.getString("keycloak.realm");

    Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();

    RestAdapter.Builder builder = new RestAdapter.Builder();
    builder.setConverter(new GsonConverter(gson));
    builder.setEndpoint(config.getString("keycloak.root"));
    RestAdapter ra = builder.build();/*  w  ww.j a v a2  s.  co m*/

    client = ra.create(KeycloakClient.class);
}

From source file:com.chicm.cmraft.common.CmRaftConfiguration.java

@Override
public void useResource(String resourceName) {
    try {/*from   w w w.  j  a v a 2 s  . c  om*/
        conf = new PropertiesConfiguration(resourceName);
    } catch (ConfigurationException e) {
        LOG.error("load resource exception", e);
    }
}

From source file:com.dhenton9000.embedded.jetty.PhantomJSTest.java

public PhantomJSTest() {

    LOG.debug("using properties file");
    try {//from   w ww. j a  v a  2  s. c o m
        config = new PropertiesConfiguration("env.properties");
        LOG.debug("reading config in " + this.getClass().getName());
        driver = configureDriver(config);

        this.automation = new GenericAutomationRepository(driver, config);
    } catch (ConfigurationException | IOException ex) {
        throw new RuntimeException(ex);

    }
}

From source file:edu.emory.library.tast.AppConfig.java

private static void load() {
    try {/*from  w  ww  .ja  va  2 s  .  com*/
        conf = new PropertiesConfiguration(TAST_PROPERTIES);
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.continuent.tungsten.common.security.SecurityHelper.java

/**
 * Save passwords from a TungstenProperties into a file
 * //from w ww .j a  v a  2 s  .c  om
 * @param authenticationInfo containing password file location
 */
public static void saveCredentialsFromAuthenticationInfo(AuthenticationInfo authenticationInfo)
        throws ServerRuntimeException {
    String passwordFileLocation = authenticationInfo.getPasswordFileLocation();

    try {
        String username = authenticationInfo.getUsername();
        String password = authenticationInfo.getPassword();

        PropertiesConfiguration props = new PropertiesConfiguration(passwordFileLocation); // Use Apache commons-configuration:
                                                                                           // preserves comments in .properties
                                                                                           // !
        props.setProperty(username, password);
        props.save();
    } catch (org.apache.commons.configuration.ConfigurationException ce) {
        logger.error("Error while saving properties for file:" + authenticationInfo.getPasswordFileLocation(),
                ce);
        throw new ServerRuntimeException("Error while saving Credentials: " + ce.getMessage());
    }
}

From source file:com.talis.inject.guice.PropertiesConfiguredModuleFactory.java

@Override
public Module[] getModules() {
    List<Module> modules = new ArrayList<Module>();
    String filename = System.getProperty(PROPERTIES_LOCATION_PROP, PROPERTIES_FILENAME);
    try {//  w  w w  . jav  a2  s .  com
        PropertiesConfiguration config = new PropertiesConfiguration(filename);

        List<String> classes = config.getList(MODULE_PROPERTY);
        LOG.debug(String.format("Configuration properties list %s module classes", classes.size()));

        for (String classname : classes) {
            LOG.debug(String.format("Found module specified, instantiating instance: %s", classname));
            Module module = (Module) Class.forName(classname).newInstance();
            modules.add(module);
        }

    } catch (ConfigurationException e) {
        LOG.error(String.format("Error reading properties file from %s. " + "Current classpath is %s", filename,
                System.getProperty("java.class.path")));
        throw new com.google.inject.ConfigurationException(
                getExceptionMessages("Unable to read configuration for ModuleFactory", e));

    } catch (Exception e) {
        LOG.error(String.format("A module specified in %s could not be instantiated", filename));
        throw new com.google.inject.ConfigurationException(
                getExceptionMessages("Unable to initialise ModuleFactory from configuration", e));

    }
    return modules.toArray(new Module[modules.size()]);
}

From source file:es.tid.cosmos.platform.injection.server.Configuration.java

/**
 * /*  w  ww  .  ja  v a 2 s . c  o m*/
 * @param url
 * @throws ConfigurationException
 */
public Configuration(URL url) throws ConfigurationException {
    this.properties = new PropertiesConfiguration(url);
}

From source file:com.siemens.scr.avt.ad.query.common.MappingDictionaryTest.java

@Test
public void testLoadingFromHibernateMapping() throws JDOMException, IOException, ConfigurationException {
    DicomMappingDictionary dict = new DicomMappingDictionary();
    dict.loadFromHibernateMapping(mappingFile);

    PropertiesConfiguration config = new PropertiesConfiguration(expectedMappingFile);
    Map<String, MappingEntry> expected = new HashMap<String, MappingEntry>();
    Iterator it = config.getKeys();
    while (it.hasNext()) {
        String key = (String) it.next();

        List<String> list = config.getList(key);

        int type = Integer.parseInt(list.get(2));
        MappingEntry entry;/*from  w  w w .j  a  v a 2s .  c  o  m*/
        if (type == java.sql.Types.OTHER) {
            entry = new WildcardEntry(list.get(0));
        } else {
            entry = new SimpleEntry(list.get(0), list.get(1), type);
        }
        expected.put(key, entry);
    }
    Map<String, MappingEntry> actual = dict.getDict();

    assertEquals(expected.size(), actual.size());

    for (String key : expected.keySet()) {
        assertEquals(expected.get(key), actual.get(key));
    }

}

From source file:net.orpiske.ssps.common.repository.ProviderFactory.java

private static void setRepositoryCredentials(RepositoryInfo repositoryInfo) {
    String repositoryPath = RepositoryUtils.getUserRepository();

    String path = repositoryPath + File.separator + repositoryInfo.getName() + File.separator + "user.conf";

    try {//from  w w w  .ja va  2  s .  c o  m
        PropertiesConfiguration userConfig = new PropertiesConfiguration(path);

        String userName = userConfig.getString(repositoryInfo.getName() + ".auth.user");
        repositoryInfo.setUserName(userName);

        String password = userConfig.getString(repositoryInfo.getName() + ".auth.password");
        repositoryInfo.setPassword(password);

    } catch (ConfigurationException e) {
        logger.warn(
                "Unable to load user configuration settings for " + repositoryInfo.getName() + "repository");
    }
}