Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.PropertiesConfiguration.load()


   
    protected void load(String filename) {
        PropertiesConfiguration propertiesConfiguration =
            new PropertiesConfiguration();
        try {
            propertiesConfiguration.load(filename);
            config.addConfiguration(propertiesConfiguration);
        }
        catch (ConfigurationException e) {
            throw new ExceptionInInitializerError(e);
        }
View Full Code Here


   
    InputStream propertiesInputStream = getSystemPropertiesInputStream(servletContext);

    if (propertiesInputStream != null) {
      PropertiesConfiguration properties = new PropertiesConfiguration();
      properties.load(propertiesInputStream);
     
      // TODO: put other useful properties
      properties.setProperty("user.home", System.getProperty("user.home"));
     
      initDefaultSystemProperties(properties);
View Full Code Here

     */
    public void testFromClassPath() throws Exception
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFileName("test.properties");
        config.load();
        assertTrue(config.getBoolean("configuration.loaded"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        assertEquals(config.getURL(), strategy.getFile().toURL());
    }
View Full Code Here

   * @returns properties loaded from the specified path or null.
   */
  public Configuration fromFile(String path) throws ConfigurationLoadException {
    PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
    try {
      propertiesConfiguration.load(path);
    } catch (ConfigurationException e) {
      if (Throwables.getRootCause(e) instanceof AccessControlException){
        AdsServiceLoggers.ADS_API_LIB_LOG.debug("Properties could not be loaded.", e);
      } else {
        throw new ConfigurationLoadException(
View Full Code Here

        propertiesConfiguration.setFileName(fileOrUrlOrClasspathUrl);
        propertiesConfiguration.getLayout().setSingleLine(NinjaConstant.applicationSecret, true);

        try {

            propertiesConfiguration.load(fileOrUrlOrClasspathUrl);

        } catch (ConfigurationException e) {

            logger.info("Could not load file " + fileOrUrlOrClasspathUrl
                    + " (not a bad thing necessarily, but I am returing null)");
View Full Code Here

  }

  public static ClientConfiguration deserialize(String serializedConfig) {
    PropertiesConfiguration propConfig = new PropertiesConfiguration();
    try {
      propConfig.load(new StringReader(serializedConfig));
    } catch (ConfigurationException e) {
      throw new IllegalArgumentException("Error deserializing client configuration: " + serializedConfig, e);
    }
    return new ClientConfiguration(propConfig);
  }
View Full Code Here

    @Test
    public void testFromClassPath() throws Exception
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFileName(TEST_FILE);
        config.load();
        assertTrue(config.getBoolean("configuration.loaded"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        assertEquals(config.getURL().toExternalForm(), strategy.getFile().toURI().toURL().toExternalForm());
    }
View Full Code Here

   
    InputStream propertiesInputStream = getSystemPropertiesInputStream(servletContext);

    if (propertiesInputStream != null) {
      PropertiesConfiguration properties = new PropertiesConfiguration();
      properties.load(propertiesInputStream);
     
      // TODO: put other useful properties
      properties.setProperty("user.home", System.getProperty("user.home"));
      if(!properties.containsKey("siteUrl")) {
        properties.setProperty("siteUrl", servletContext.getContextPath());
View Full Code Here

   private static org.apache.commons.configuration.Configuration init() {
      PropertiesConfiguration config = null;
      try {
         config = new PropertiesConfiguration();
         config.setListDelimiter('\0');
         config.load(ERR_CODE_FILE);
      } catch (ConfigurationException ex) {
         // error out if the configuration file is not there
         String message = "Cannot load Serengeti error message file.";
         Logger.getLogger(RestResource.class).fatal(message, ex);
         throw BddException.APP_INIT_ERROR(ex, message);
View Full Code Here

      PropertiesConfiguration pconf = new PropertiesConfiguration();
      // ','s are value delimiters by default. We don't want ',' delimiters for our error message and properties files
      // as they are not multi-valued. Turn off value delimiters
      // We need to do this before loading the properties
      pconf.setListDelimiter('\0');
      pconf.load(filename);
      return pconf;
   }

   /**
    * Calculate the swap disk size.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.