List of usage examples for org.apache.commons.configuration PropertiesConfiguration load
public synchronized void load(Reader in) throws ConfigurationException
From source file:com.liferay.ide.project.core.SDKProjectRemoteServerPublisher.java
@Override public IPath publishModuleFull(IProgressMonitor monitor) throws CoreException { final IPath deployPath = LiferayServerCore.getTempLocation("direct-deploy", StringPool.EMPTY); //$NON-NLS-1$ File warFile = deployPath.append(getProject().getName() + ".war").toFile(); //$NON-NLS-1$ warFile.getParentFile().mkdirs();/* www. ja v a 2 s. c om*/ final Map<String, String> properties = new HashMap<String, String>(); properties.put(ISDKConstants.PROPERTY_AUTO_DEPLOY_UNPACK_WAR, "false"); //$NON-NLS-1$ final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(getProject()); final String appServerDeployDirProp = ServerUtil .getAppServerPropertyKey(ISDKConstants.PROPERTY_APP_SERVER_DEPLOY_DIR, runtime); properties.put(appServerDeployDirProp, deployPath.toOSString()); // IDE-1073 LPS-37923 properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE_DEFAULT, warFile.getAbsolutePath()); properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE, warFile.getAbsolutePath()); final String fileTimeStamp = System.currentTimeMillis() + ""; // IDE-1491 properties.put(ISDKConstants.PROPERTY_LP_VERSION, fileTimeStamp); properties.put(ISDKConstants.PROPERTY_LP_VERSION_SUFFIX, ".0"); IStatus status = sdk.validate(); if (!status.isOK()) { throw new CoreException(status); } final IStatus directDeployStatus = sdk.war(getProject(), properties, true, new String[] { "-Duser.timezone=GMT" }, monitor); if (!directDeployStatus.isOK() || (!warFile.exists())) { String pluginVersion = "1"; final IPath pluginPropertiesPath = new Path("WEB-INF/liferay-plugin-package.properties"); final IWebProject webproject = LiferayCore.create(IWebProject.class, getProject()); if (webproject != null) { final IResource propsRes = webproject.findDocrootResource(pluginPropertiesPath); if (propsRes instanceof IFile && propsRes.exists()) { try { final PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration(); final InputStream is = ((IFile) propsRes).getContents(); pluginPackageProperties.load(is); pluginVersion = pluginPackageProperties.getString("module-incremental-version"); is.close(); } catch (Exception e) { LiferayCore.logError("error reading module-incremtnal-version. ", e); } } warFile = sdk.getLocation().append("dist") .append(getProject().getName() + "-" + fileTimeStamp + "." + pluginVersion + ".0" + ".war") .toFile(); if (!warFile.exists()) { throw new CoreException(directDeployStatus); } } } return new Path(warFile.getAbsolutePath()); }
From source file:edu.cmu.lti.oaqa.bioasq.triple.retrieval.GoPubMedTripleRetrievalExecutor.java
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); String conf = UimaContextHelper.getConfigParameterStringValue(context, "conf"); PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration(); try {/*w w w.j a v a 2s .com*/ gopubmedProperties.load(getClass().getResourceAsStream(conf)); } catch (ConfigurationException e) { throw new ResourceInitializationException(e); } service = new GoPubMedService(gopubmedProperties); pages = UimaContextHelper.getConfigParameterIntValue(context, "pages", 1); hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100); bopQueryStringConstructor = new BagOfPhraseQueryStringConstructor(); }
From source file:edu.cmu.lti.oaqa.bioasq.concept.rerank.scorers.GoPubMedConceptRetrievalScorer.java
@Override public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { super.initialize(aSpecifier, aAdditionalParams); String conf = String.class.cast(getParameterValue("conf")); PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration(); try {//from www.j ava 2 s.co m gopubmedProperties.load(getClass().getResourceAsStream(conf)); } catch (ConfigurationException e) { throw new ResourceInitializationException(e); } service = new GoPubMedService(gopubmedProperties); pages = Integer.class.cast(getParameterValue("pages")); hits = Integer.class.cast(getParameterValue("hits")); timeout = Integer.class.cast(getParameterValue("timeout")); String stoplistPath = String.class.cast(getParameterValue("stoplist-path")); try { stoplist = Resources.readLines(getClass().getResource(stoplistPath), UTF_8).stream().map(String::trim) .collect(toSet()); } catch (IOException e) { throw new ResourceInitializationException(e); } uri2conf2score = HashBasedTable.create(); uri2conf2rank = HashBasedTable.create(); return true; }
From source file:com.nilostep.xlsql.database.xlInstance.java
private xlInstance(String cfg) throws xlException { logger = Logger.getLogger(this.getClass().getName()); instance = this; try {/*ww w. jav a 2s. c om*/ PropertiesConfiguration config = new PropertiesConfiguration(); config.load(this.getClass().getResourceAsStream(cfg + ".properties")); this.config = config; engine = config.getString("general.engine"); logger.info("Configuration engine: " + engine + " loaded"); } catch (ConfigurationException e) { e.printStackTrace(); throw new xlException(e.getMessage()); } try { boolean append = true; FileHandler loghandler = new FileHandler(getLog(), append); loghandler.setFormatter(new SimpleFormatter()); logger.addHandler(loghandler); } catch (IOException e) { throw new xlException("error while creating logfile"); } logger.info("Instance created with engine " + getEngine()); }
From source file:com.francetelecom.clara.cloud.logicalmodel.LogicalConfigServiceUtils.java
/** * * * @param reader/*w w w . j av a 2 s .c o m*/ * @return */ public StructuredLogicalConfigServiceContent parseConfigContent(Reader reader) throws InvalidConfigServiceException { List<ConfigEntry> parsedEntries = new ArrayList<ConfigEntry>(); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); try { propertiesConfiguration.load(reader); } catch (ConfigurationException e) { InvalidConfigServiceException invalidConfigServiceException = new InvalidConfigServiceException( "Invalid config content. Caught:" + e, e); throw invalidConfigServiceException; } PropertiesConfigurationLayout layout = propertiesConfiguration.getLayout(); String headerComment = layout.getHeaderComment(); Set<String> keys = layout.getKeys(); Set<String> duplicates = new HashSet<String>(); for (String key : keys) { String comment = layout.getComment(key); if (comment != null) { comment = escapesPoundsInComments(comment); } if (!layout.isSingleLine(key)) { //reject the duplicate key duplicates.add(key); } else { String value = propertiesConfiguration.getString(key); parsedEntries.add(new ConfigEntry(key, value, comment)); } } if (duplicates.size() > 0) { InvalidConfigServiceException invalidConfigServiceException = new InvalidConfigServiceException( "Collisions! " + duplicates); invalidConfigServiceException.setType(ErrorType.DUPLICATE_KEYS); invalidConfigServiceException.getDuplicateKeys().addAll(duplicates); throw invalidConfigServiceException; } List<ConfigEntry> configEntries = parsedEntries; StructuredLogicalConfigServiceContent structuredLogicalConfigServiceContent = new StructuredLogicalConfigServiceContent( headerComment, configEntries); return structuredLogicalConfigServiceContent; }
From source file:com.baidu.cc.configuration.service.impl.ConfigItemServiceImpl.java
/** * properties??.// w w w .j a v a 2 s . c o m * * @param groupId * ?groupId * @param versionId * ?versionId * @param content * properties */ @Override public void batchInsertConfigItems(Long groupId, Long versionId, String content) { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); Properties properties = new Properties(); try { propertiesConfiguration.load(new StringReader(content)); properties.load(new StringReader(content)); Date now = new Date(); Iterator<String> keys = propertiesConfiguration.getKeys(); List<ConfigItem> configItems = new ArrayList<ConfigItem>(); while (keys.hasNext()) { String key = keys.next(); String value = properties.getProperty(key); ConfigItem configItem = new ConfigItem(); configItem.setName(key); configItem.setVal(value); configItem.setCreateTime(now); configItem.setUpdateTime(now); configItem.setGroupId(groupId); configItem.setVersionId(versionId); configItem.setShareable(false); configItem.setRef(false); configItems.add(configItem); } configItemDao.deleteByGroupId(groupId); saveOrUpdateAll(configItems); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.linkedin.pinot.query.executor.QueryExecutorTest.java
@BeforeClass public void setup() throws Exception { TableDataManagerProvider.setServerMetrics(new ServerMetrics(new MetricsRegistry())); File confDir = new File(QueryExecutorTest.class.getClassLoader().getResource("conf").toURI()); setupSegmentList(2);/*from www. j a v a 2 s . c o m*/ // ServerBuilder serverBuilder = new ServerBuilder(confDir.getAbsolutePath()); String configFilePath = confDir.getAbsolutePath(); // build _serverConf PropertiesConfiguration serverConf = new PropertiesConfiguration(); serverConf.setDelimiterParsingDisabled(false); serverConf.load(new File(configFilePath, PINOT_PROPERTIES)); FileBasedInstanceDataManager instanceDataManager = FileBasedInstanceDataManager.getInstanceDataManager(); instanceDataManager .init(new FileBasedInstanceDataManagerConfig(serverConf.subset("pinot.server.instance"))); instanceDataManager.start(); for (int i = 0; i < 2; ++i) { instanceDataManager.getTableDataManager("midas"); instanceDataManager.getTableDataManager("midas").addSegment(_indexSegmentList.get(i)); } _queryExecutor = new ServerQueryExecutorV1Impl(); _queryExecutor.init(serverConf.subset("pinot.server.query.executor"), instanceDataManager, new ServerMetrics(new MetricsRegistry())); }
From source file:com.linkedin.pinot.server.integration.IntegrationTest.java
@BeforeTest public void setUp() throws Exception { //Process Command Line to get config and port FileUtils.deleteDirectory(new File("/tmp/pinot/test1")); setupSegmentList();//ww w . ja va 2s . c om File confFile = new File(TestUtils.getFileFromResourceUrl( InstanceServerStarter.class.getClassLoader().getResource("conf/" + PINOT_PROPERTIES))); // build _serverConf PropertiesConfiguration serverConf = new PropertiesConfiguration(); serverConf.setDelimiterParsingDisabled(false); serverConf.load(confFile); _serverConf = new ServerConf(serverConf); LOGGER.info("Trying to create a new ServerInstance!"); _serverInstance = new ServerInstance(); LOGGER.info("Trying to initial ServerInstance!"); _serverInstance.init(_serverConf, new MetricsRegistry()); LOGGER.info("Trying to start ServerInstance!"); _serverInstance.start(); _queryExecutor = _serverInstance.getQueryExecutor(); FileBasedInstanceDataManager instanceDataManager = (FileBasedInstanceDataManager) _serverInstance .getInstanceDataManager(); for (int i = 0; i < 2; ++i) { instanceDataManager.getTableDataManager("testTable"); instanceDataManager.getTableDataManager("testTable").addSegment(_indexSegmentList.get(i)); } }
From source file:com.github.htfv.maven.plugins.buildconfigurator.core.configurators.propertyfiles.PropertyFileConfigurator.java
protected void loadPropertyFile(final ConfigurationContext ctx, final PropertyFileConfiguration propertyFile) throws ConfigurationException, IOException { BufferedReader reader = null; try {/* w ww.j a v a 2s. c o m*/ final String action = getAction(ctx, propertyFile); if (PropertyFileConfiguration.ACTION_SKIP.equals(action)) { return; } // // Check to see whether the file exists. // final File file = getFile(ctx, propertyFile); if (!file.exists()) { // // Throw an error if missing file is not allowed. // final Boolean ignoreMissing = ctx.getBooleanValue(propertyFile.getIgnoreMissing(), ctx.getConfiguration().getIgnoreMissingPropertyFiles(), getDefaultIgnoreMissingPropertyFiles()); if (ignoreMissing) { return; } else { throw new PropertyFileMissingException(file); } } // // Open file reader with appropriate encoding. // final String encoding = ctx.getStringValue(propertyFile.getEncoding(), ctx.getConfiguration().getDefaultPropertyFilesEncoding(), getDefaultPropertyFileEncoding()); reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); // // Load the properties. // final PropertiesConfiguration properties = new PropertiesConfiguration(); properties.setDelimiterParsingDisabled(true); properties.load(reader); // // Add loaded properties to the context. // ctx.addProperties(properties); } finally { if (reader != null) { reader.close(); } } }
From source file:com.mirth.connect.server.ExtensionLoader.java
private String getServerVersion() throws FileNotFoundException, ConfigurationException { PropertiesConfiguration versionConfig = new PropertiesConfiguration(); versionConfig.setDelimiterParsingDisabled(true); InputStream versionPropertiesStream = ResourceUtil.getResourceStream(ExtensionLoader.class, "version.properties"); versionConfig.load(versionPropertiesStream); IOUtils.closeQuietly(versionPropertiesStream); return versionConfig.getString("mirth.version"); }