本文整理汇总了Java中org.apache.commons.configuration2.io.ClasspathLocationStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ClasspathLocationStrategy类的具体用法?Java ClasspathLocationStrategy怎么用?Java ClasspathLocationStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClasspathLocationStrategy类属于org.apache.commons.configuration2.io包,在下文中一共展示了ClasspathLocationStrategy类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Config
import org.apache.commons.configuration2.io.ClasspathLocationStrategy; //导入依赖的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
示例2: buildFromConfig
import org.apache.commons.configuration2.io.ClasspathLocationStrategy; //导入依赖的package包/类
/**
* Builds the Configuration object from the properties file (apache commons
* properties file format). <br>
* The values provided in the config file will be overwritten environment
* variables (if present)
*
* List of the properties <br>
* loginsight.host = host name <br>
* loginsight.port = port number <br>
* loginsight.user = User name <br>
* loginsight.password = password <br>
* loginsight.ingestion.agentId = agentId <br>
* loginsight.connection.scheme = http protocol scheme <br>
* loginsight.ingestion.port = Ingestion port number <br>
*
* @param configFileName
* Name of the config file to read
* @return Newly created Configuration object
*/
public static Configuration buildFromConfig(String configFileName) {
try {
List<FileLocationStrategy> subs = Arrays.asList(new ProvidedURLLocationStrategy(),
new FileSystemLocationStrategy(), new ClasspathLocationStrategy());
FileLocationStrategy strategy = new CombinedLocationStrategy(subs);
FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(
PropertiesConfiguration.class).configure(
new Parameters().fileBased().setLocationStrategy(strategy).setFileName(configFileName));
PropertiesConfiguration propConfig = builder.getConfiguration();
Map<String, String> propMap = new HashMap<String, String>();
Iterator<String> keys = propConfig.getKeys();
keys.forEachRemaining(key -> {
logger.info(key + ":" + propConfig.getString(key));
propMap.put(key, propConfig.getString(key));
});
Configuration config = Configuration.buildConfig(propMap);
config.loadFromEnv();
return config;
} catch (ConfigurationException e1) {
throw new RuntimeException("Unable to load config", e1);
}
}
开发者ID:vmware,项目名称:loginsight-java-api,代码行数:43,代码来源:Configuration.java
示例3: getFileName
import org.apache.commons.configuration2.io.ClasspathLocationStrategy; //导入依赖的package包/类
/**
* The file {@link URL} can be absolute or relative to the working folder. The configuration file is located using a {@link FileLocatorUtils#DEFAULT_LOCATION_STRATEGY strategy} that uses a number of techniques to determine the file location.
* <p>
* If no file is found, the {@link #FILENAME resource file} is used.
*
* @return the configuration file {@link URL}.
*/
public URL getFileName() {
if (this.propertiesFile == null) {
final List<FileLocationStrategy> subs = Arrays.asList(
new ProvidedURLLocationStrategy(),
new FileSystemLocationStrategy(),
new ClasspathLocationStrategy());
final FileLocationStrategy strategy = new CombinedLocationStrategy(subs);
FileLocator fileLocator = FileLocatorUtils.fileLocator()
.basePath(this.getDefaultFile().getParent())
.fileName(this.getDefaultFile().getName())
.create();
if (!new File(FileLocatorUtils.locate(fileLocator).getFile()).exists()) {
fileLocator = FileLocatorUtils.fileLocator()
.fileName(this.getDefaultFile().getName())
.locationStrategy(strategy)
.create();
}
this.propertiesFile = FileLocatorUtils.locate(fileLocator);
// Ensure that the ConfigurationBuilder is now initialised as that may force a re-initialisation of this FileLocator.
this.getConfigurationBuilder();
}
return this.propertiesFile;
}
开发者ID:CloudRacer,项目名称:MockTCPServer,代码行数:36,代码来源:ConfigurationSettings.java
示例4: Config
import org.apache.commons.configuration2.io.ClasspathLocationStrategy; //导入依赖的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("pdf2xml.properties").setLocationStrategy(new ClasspathLocationStrategy()));
configuration = builder.getConfiguration();
} catch (ConfigurationException e) {
LOG.error(e, e);
}
}
开发者ID:TekstoSense,项目名称:pdf-segmenter,代码行数:15,代码来源:Config.java
示例5: getHeapSpankJarConfiguration
import org.apache.commons.configuration2.io.ClasspathLocationStrategy; //导入依赖的package包/类
private Configuration getHeapSpankJarConfiguration() throws ConfigurationException {
Parameters params = new Parameters();
FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.properties()
.setFileName(PROPERTIES_FILE)
.setLocationStrategy(new ClasspathLocationStrategy())
);
Configuration config = builder.getConfiguration();
return config;
}
开发者ID:eostermueller,项目名称:heapSpank,代码行数:12,代码来源:ApacheCommonsConfigFile.java
注:本文中的org.apache.commons.configuration2.io.ClasspathLocationStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论