当前位置: 首页>>代码示例>>Java>>正文


Java FileBasedConfiguration类代码示例

本文整理汇总了Java中org.apache.commons.configuration2.FileBasedConfiguration的典型用法代码示例。如果您正苦于以下问题:Java FileBasedConfiguration类的具体用法?Java FileBasedConfiguration怎么用?Java FileBasedConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileBasedConfiguration类属于org.apache.commons.configuration2包,在下文中一共展示了FileBasedConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showBoard

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
@Override
public void showBoard() {
    File paramFile = new File("config/mainboardfx.properties");
    try {
        final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
            PropertiesConfiguration.class)
            .configure(
                new FileBasedBuilderParametersImpl().setFile(paramFile).setEncoding("utf8"));
        cfg = builder.getConfiguration();
    } catch (ConfigurationException ex) {
        QLog.l().logger()
            .error("Не загружен файл конфигурации " + paramFile.getAbsolutePath(), ex);
        throw new ServerException(
            "Не загружен файл конфигурации " + paramFile.getAbsolutePath());
    }

    super.showBoard();
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:19,代码来源:OrangeMainboard.java

示例2: savePropertyForStandaloneProfile

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
/**
 * Save property for standalone profile.
 *
 * @param pair the pair
 */
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
    try {
        final File file = getStandaloneProfileConfigurationDirectory();
        final Parameters params = new Parameters();

        final FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
                new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                        .configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));

        final Configuration config = builder.getConfiguration();
        config.setProperty(pair.getKey(), pair.getValue());
        builder.save();
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:CasConfigurationPropertiesEnvironmentManager.java

示例3: createPropertiesConfiguration

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private static FileBasedConfiguration createPropertiesConfiguration(Reader reader)
    throws ConfigurationException, IOException {
  if (reader == null) {
    throw new NullPointerException("reader: null");
  }

  FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
      new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
          .configure(new Parameters()
              .properties()
              .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

  FileBasedConfiguration config = builder.getConfiguration();
  config.read(reader);
  return config;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:17,代码来源:PropertiesConfigurationSource.java

示例4: createConfiguration

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private static FileBasedConfiguration createConfiguration(Reader reader)
    throws ConfigurationException {
  if (reader == null) {
    throw new NullPointerException("reader: null");
  }

  FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
      new FileBasedConfigurationBuilder<FileBasedConfiguration>(XMLConfiguration.class)
          .configure(new Parameters().xml());

  FileBasedConfiguration fileBasedConfiguration = builder.getConfiguration();

  FileHandler handler = new FileHandler(fileBasedConfiguration);
  handler.load(reader);
  return fileBasedConfiguration;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:17,代码来源:XmlConfigurationSource.java

示例5: Config

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
/**
 * Instantiates a new config.
 */
private Config() {
	try {
		Parameters params = new Parameters();
		FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
				PropertiesConfiguration.class);
		builder.configure(params.fileBased().setFileName("nlp.properties")
				.setLocationStrategy(new ClasspathLocationStrategy()));
		configuration = builder.getConfiguration();
		// Adding TEKSTO_HOME path to Configuration
		String homePath = System.getenv(TEKSTO_HOME);
		if (homePath != null && !homePath.isEmpty()) {
			configuration.setProperty(MODEL_PATH, homePath + "/Models");
		}
	} catch (ConfigurationException e) {
		LOG.error(e, e);
	}
}
 
开发者ID:TekstoSense,项目名称:opennlp-enhancer,代码行数:21,代码来源:Config.java

示例6: testOverride

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
@Test
public void testOverride() {

    Parameters params = new Parameters();
    FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
            new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                    .configure(params.properties()
                            .setFileName("file.properties"));
    Configuration config = null;
    try {
        config = builder.getConfiguration();
        config.setProperty("somekey", "somevalue");
        builder.save();
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:bejondshao,项目名称:personal,代码行数:18,代码来源:PropertyOverrideTest.java

示例7: AliceRecognition

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private AliceRecognition()
{
	try
	{
		CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
		config.addConfiguration(new SystemConfiguration());
		config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			    					  .configure(new Parameters().properties().setFileName(ALICE_PROPERTIES)).getConfiguration());
			
		this.enabled = config.getBoolean(ALICE_ENABLED, false);
		String url = config.getString(ALICE_SERVICE_URL, null); 
		String accessToken = config.getString(ALICE_ACCESS_TOKEN, null); 
		String command = config.getString(ALICE_COMMAND, null); 
	
		if(enabled && !StringUtils.isEmpty(url) && !StringUtils.isEmpty(accessToken))
		{
			this.client = new AliceClient(url, command);
			this.client.setAuthToken(accessToken);
			this.enabled = this.client.isAvailable();
		}
	}
	catch (Exception e) 
	{
		LOGGER.error("Unable to initialize Alice: " + e.getMessage());
	}
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:27,代码来源:AliceRecognition.java

示例8: init

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getHotkeysFile()));
	config = builder.getConfiguration();
	loadHotkeys();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:HotkeyController.java

示例9: init

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
public static void init(String worldLocation) throws ConfigurationException {
	log.debug("World Location for properties: " + worldLocation);
	configManager = new Configurations();
	if(worldLocation == null){
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName(defaultWorldPropertiesLocation));
	}else
	{
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
				.configure(configManager.getParameters().fileBased().setFileName(worldLocation));
	}
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:14,代码来源:WorldConfig.java

示例10: init

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getAppPropFile()));
	
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:AppConfig.java

示例11: firstInit

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
public static void firstInit() throws Exception{
	configManager = new Configurations();
	
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName("src/main/resources/app.properties"));
	
	config = builder.getConfiguration();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:9,代码来源:AppConfig.java

示例12: loadConfigurationManager

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private void loadConfigurationManager() {
    log.trace(() -> "Initializing configuration cache.");

    @NotNull Parameters params = new Parameters();

    FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
            new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                    .configure(params.properties()
                            .setFileName(PROPERTIES_FILE));

    try {
        this.config = builder.getConfiguration();
    } catch (ConfigurationException e) {
        log.fatal(e);
        throw new RuntimeException("Couldnt load configuration file " + PROPERTIES_FILE);
    }
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:18,代码来源:ConfigurationManager.java

示例13: PropertiesConfigurationSource

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private PropertiesConfigurationSource(FileBasedConfiguration configuration, int priority) {
  if (configuration == null) {
    throw new NullPointerException("configuration: null");
  }
  if (priority < 0) {
    throw new IllegalArgumentException("priority of a configuration cannot be negative");
  }

  this.configuration = configuration;
  this.priority = priority;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:12,代码来源:PropertiesConfigurationSource.java

示例14: XmlConfigurationSource

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private XmlConfigurationSource(FileBasedConfiguration configuration, int priority) {
  if (configuration == null) {
    throw new NullPointerException("configuration: null");
  }
  if (priority < 0) {
    throw new IllegalArgumentException("priority of a configuration cannot be negative");
  }

  this.configuration = configuration;
  this.priority = priority;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:12,代码来源:XmlConfigurationSource.java

示例15: Config

import org.apache.commons.configuration2.FileBasedConfiguration; //导入依赖的package包/类
private Config() {

        // https://issues.apache.org/jira/browse/CONFIGURATION-677
        /*BuilderParameters params = new Parameters().properties()
            .setFileName(CONFIG_NAME)
            .setLocationStrategy(new HomeDirectoryLocationStrategy())
            .setEncoding("UTF-8");*/
        
        // workaround:
        HomeDirectoryLocationStrategy location = new HomeDirectoryLocationStrategy();
        File configFile = new File(location.getHomeDirectory(), CONFIG_NAME);
        BuilderParameters params = new Parameters().properties()
                .setFile(configFile)
                .setEncoding("UTF-8");
        
        builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
                PropertiesConfiguration.class, params.getParameters(), true);
        builder.setAutoSave(true);
        
        try {
            config = builder.getConfiguration();
            logger.info("User configuration has been loaded from: {}", configFile);
        } catch(ConfigurationException cex) {
            logger.error("Error loading configuration", cex);
            throw new IllegalStateException("Error loading/creating configuration");
        }
    }
 
开发者ID:rjaros87,项目名称:pm-home-station,代码行数:28,代码来源:Config.java


注:本文中的org.apache.commons.configuration2.FileBasedConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。