/** Load the config parameters from fortress.properties file. */ private void loadLocalConfig() { try { // Load the system config file. URL fUrl = Config.class.getClassLoader().getResource(PROP_FILE); config.setDelimiterParsingDisabled(true); if (fUrl == null) { String error = "static init: Error, null cfg file: " + PROP_FILE; LOG.warn(error); } else { LOG.info("static init: found from: {} path: {}", PROP_FILE, fUrl.getPath()); config.load(fUrl); LOG.info("static init: loading from: {}", PROP_FILE); } URL fUserUrl = Config.class.getClassLoader().getResource(USER_PROP_FILE); if (fUserUrl != null) { LOG.info( "static init: found user properties from: {} path: {}", USER_PROP_FILE, fUserUrl.getPath()); config.load(fUserUrl); } } catch (org.apache.commons.configuration.ConfigurationException ex) { String error = "static init: Error loading from cfg file: [" + PROP_FILE + "] ConfigurationException=" + ex; LOG.error(error); throw new CfgRuntimeException(GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex); } }
/** @see Plugin#init() */ public void init() throws PluginException { try { if (System.getProperty("roda.home") != null) { RODA_HOME = System.getProperty("roda.home"); } else if (System.getenv("RODA_HOME") != null) { RODA_HOME = System.getenv("RODA_HOME"); } else { RODA_HOME = null; } if (StringUtils.isBlank(RODA_HOME)) { throw new PluginException( "RODA_HOME enviroment variable and ${roda.home} system property are not set."); } final File pluginsConfigDirectory = new File(new File(RODA_HOME, "config"), "plugins"); final File configFile = new File(pluginsConfigDirectory, CONFIGURATION_FILENAME); final PropertiesConfiguration configuration = new PropertiesConfiguration(); if (configFile.isFile()) { configuration.load(configFile); logger.info("Loading configuration file from " + configFile); } else { configuration.load(getClass().getResourceAsStream("/" + CONFIGURATION_FILENAME)); logger.info("Loading default configuration file from resources"); } taverna_bin = configuration.getString("taverna_bin"); logger.debug("taverna_bin=" + taverna_bin); xpathSelectIDs = configuration.getString("xpathSelectIDs"); logger.debug("xpathSelectIDs=" + xpathSelectIDs); xpathSelectWorkflow = configuration.getString("xpathSelectWorkflow"); logger.debug("xpathSelectWorkflow=" + xpathSelectWorkflow); workflowInputPort = configuration.getString("workflowInputPort"); logger.debug("workflowInputPort=" + workflowInputPort); workflowOutputPort = configuration.getString("workflowOutputPort"); logger.debug("workflowOutputPort=" + workflowOutputPort); workflowExtraPorts = configuration.getStringArray("workflowExtraPorts"); logger.debug("workflowExtraPorts=" + Arrays.asList(workflowExtraPorts)); } catch (ConfigurationException ex) { logger.debug("Error reading plugin configuration - " + ex.getMessage(), ex); throw new PluginException("Error reading plugin configuration - " + ex.getMessage(), ex); } planFile = new File(new File(RODA_HOME, "data"), PLAN_FILENAME); logger.debug("init() OK"); }
public SenseiServerBuilder(File confDir, Map<String, Object> properties) throws Exception { if (properties != null) { _senseiConfFile = null; _senseiConf = new MapConfiguration(properties); ((MapConfiguration) _senseiConf).setDelimiterParsingDisabled(true); } else { _senseiConfFile = new File(confDir, SENSEI_PROPERTIES); if (!_senseiConfFile.exists()) { throw new ConfigurationException( "configuration file: " + _senseiConfFile.getAbsolutePath() + " does not exist."); } _senseiConf = new PropertiesConfiguration(); ((PropertiesConfiguration) _senseiConf).setDelimiterParsingDisabled(true); ((PropertiesConfiguration) _senseiConf).load(_senseiConfFile); } pluginRegistry = SenseiPluginRegistry.build(_senseiConf); pluginRegistry.start(); processRelevanceFunctionPlugins(pluginRegistry); processRelevanceExternalObjectPlugins(pluginRegistry); _gateway = pluginRegistry.getBeanByFullPrefix(SENSEI_GATEWAY, SenseiGateway.class); _schemaDoc = loadSchema(confDir); _senseiSchema = SenseiSchema.build(_schemaDoc); }
@BeforeClass public void setup() throws Exception { TableDataManagerProvider.setServerMetrics(new ServerMetrics(new MetricsRegistry())); File confDir = new File(QueryExecutorTest.class.getClassLoader().getResource("conf").toURI()); setupSegmentList(2); // 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())); }
/** @see Plugin#init() */ public void init() throws PluginException { PropertiesConfiguration configuration = new PropertiesConfiguration(); try { String RODA_HOME = null; if (System.getProperty("roda.home") != null) { RODA_HOME = System.getProperty("roda.home"); // $NON-NLS-1$ } else if (System.getenv("RODA_HOME") != null) { RODA_HOME = System.getenv("RODA_HOME"); // $NON-NLS-1$ } else { RODA_HOME = null; } if (StringUtils.isBlank(RODA_HOME)) { throw new PluginException( "RODA_HOME enviroment variable and ${roda.home} system property are not set."); } File RODA_PLUGINS_CONFIG_DIRECTORY = new File(new File(RODA_HOME, "config"), "plugins"); File configFile = new File(RODA_PLUGINS_CONFIG_DIRECTORY, getConfigurationFile()); logger.debug("Trying to load configuration file from " + configFile); if (configFile.isFile()) { configuration.load(configFile); logger.info("Loading configuration file from " + configFile); } else { configuration.load(getClass().getResourceAsStream(getConfigurationFile())); logger.info("Loading default configuration file from resources"); } this.converterServiceURL = configuration.getString("converterServiceURL"); this.representationSubTypes = configuration.getStringArray("representationSubTypes"); if (this.representationSubTypes == null) { this.representationSubTypes = new String[0]; } } catch (ConfigurationException e) { logger.debug("Error reading plugin configuration - " + e.getMessage(), e); throw new PluginException("Error reading plugin configuration - " + e.getMessage(), e); } }
/** * Dado el nombre de un fichero <b>Properties</b> genera una instancia del objeto que gestiona el * fichero mediante <i>Apache commons-configuration</i>. * * @param filename del fichero de propiedades <i>(p.e.: config.properties)</i>. * @throws ConfigUtilException si el fichero no existe */ public ConfigPropertiesUtil(String filename) throws ConfigUtilException { try { configuration = new PropertiesConfiguration(filename); configuration.load(); } catch (ConfigurationException ce) { throw new ConfigUtilException(ce.getMessage(), ce); } catch (Exception e) { throw new ConfigUtilException(e.getMessage(), e); } }
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 = "Failed to load serengeti error message file."; Logger.getLogger(RestResource.class).fatal(message, ex); throw BddException.APP_INIT_ERROR(ex, message); } return config; }
@Override public void initliaze(InputStream input, WebApplicationConfiguration configuration) throws Exception { PropertiesConfiguration pc = new PropertiesConfiguration(); pc.load(input); BeanUtilsBean bu = retrieveBeanUtilsBean(); Iterator<String> keys = pc.getKeys(); while (keys.hasNext()) { String key = keys.next(); String value = pc.getString(key); fillConfiguration(configuration, bu, key, value); } }
/** * Loads our SQL statements from the appropriate properties file * * @param vendor DB vendor string. Must be one of mysql, oracle, hsqldb */ private void initStatements(String vendor) { URL url = getClass().getClassLoader().getResource(vendor + ".properties"); try { statements = new PropertiesConfiguration(); // must use blank constructor so it doesn't parse just yet // (as it will split) statements.setReloadingStrategy(new InvariantReloadingStrategy()); // don't watch for reloads statements.setThrowExceptionOnMissing(true); // throw exception if no prop statements.setDelimiterParsingDisabled(true); // don't split properties statements.load(url); // now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage(), e); return; } }
@Provides @Singleton public SSEnvironment getEnvironment() { try { String systemEnviroment = System.getProperty(Constants.ENVIRONMENT_VARIABLE); if (systemEnviroment == null || systemEnviroment.isEmpty()) { InputStream stream = Thread.currentThread() .getContextClassLoader() .getResourceAsStream("environment.properties"); PropertiesConfiguration propsConfig = new PropertiesConfiguration(); propsConfig.load(stream); systemEnviroment = propsConfig.getProperty(Constants.ENVIRONMENT_VARIABLE).toString(); } return SSEnvironment.valueOf(systemEnviroment.toUpperCase()); } catch (Exception e) { return SSEnvironment.LOCAL; } }
@Test public void testCompositeConfiguration() throws URISyntaxException { CompositeConfiguration configuration = new CompositeConfiguration(); try { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration("conf/pss-settings.properties"); // // propertiesConfiguration.setFileName("E:/study/jelyworkspace/jelypss/pss-core/target/test-classes/conf/pss-settings.properties"); propertiesConfiguration.load( "E:/study/jelyworkspace/jelypss/pss-core/target/test-classes/conf/pss-settings.properties"); configuration.addConfiguration(propertiesConfiguration); // propertiesConfiguration.setProperty("haha", 1235); configuration.setProperty("asdf", "aaaaaaaaa"); System.out.println(configuration.getInt("haha")); System.out.println(this.getClass().getClassLoader().getResource("").toURI().toString()); System.out.println(this.getClass().getClassLoader().getResource("").toString()); propertiesConfiguration.save(); } catch (ConfigurationException e) { e.printStackTrace(); } }
// Loads the settings from config file. If no values defined, the deafult values are returned. public static Settings loadSettings() { config.setListDelimiter('|'); Settings s = new Settings(); try { config.load("vidor.config"); } catch (ConfigurationException ex) { ex.printStackTrace(); } s.setVlcLocation(config.getString("vlclocation", "")); s.setThumbnailCount(config.getInt("thumbnailcount", 10)); s.setThumbnailWidth(config.getInt("thumbnailwidth", 200)); s.setThumbnailHighlightColor(config.getString("thumbnailhighlightcolor", "")); List<String> f = new ArrayList(Arrays.asList(config.getStringArray("folders"))); if (!f.get(0).trim().isEmpty()) { // Bug fix - Empty folder check s.setFolders(f); } return s; }
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(); 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"); final Map<String, String> appServerProperties = ServerUtil.configureAppServerProperties(getProject()); final IStatus directDeployStatus = sdk.war( getProject(), properties, true, appServerProperties, 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 IFile propertiesFile = CoreUtil.getDocrootFile(getProject(), pluginPropertiesPath.toOSString()); if (propertiesFile != null) { try { if (propertiesFile.exists()) { final PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration(); final InputStream is = propertiesFile.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()); }
public LogicTreeProcessor(String calcConfigFile) throws ConfigurationException { config = new PropertiesConfiguration(); ((PropertiesConfiguration) config).load(calcConfigFile); System.out.println(config); hasPath = true; }
protected static MimetypesFileTypeMap getMimetypesFileTypeMap() { if (mimetypesFileTypeMap == null) { mimetypesFileTypeMap = new MimetypesFileTypeMap(); PropertiesConfiguration mimetypeConfiguration = new PropertiesConfiguration(); mimetypeConfiguration.setDelimiterParsingDisabled(false); // PropertiesConfiguration.setDefaultListDelimiter(','); try { mimetypeConfiguration.load( FormatUtility.class.getResourceAsStream("mime.types-extensions.properties")); Iterator<String> keysIterator = mimetypeConfiguration.getKeys(); while (keysIterator.hasNext()) { String mimeType = keysIterator.next(); String mimetypevalue = mimeType + " " + mimetypeConfiguration.getString(mimeType); mimetypesFileTypeMap.addMimeTypes(mimetypevalue); } } catch (ConfigurationException e) { logger.warn("Error reading mime.types-extensions.properties file - " + e.getMessage(), e); logger.warn("Using default predefined values for mimetype/extensions"); mimetypesFileTypeMap.addMimeTypes("application/pdf pdf PDF"); mimetypesFileTypeMap.addMimeTypes("application/msword doc DOC"); mimetypesFileTypeMap.addMimeTypes( "application/vnd.openxmlformats-officedocument.wordprocessingml.document docx DOCX"); mimetypesFileTypeMap.addMimeTypes("application/vnd.oasis.opendocument.text odt ODT"); mimetypesFileTypeMap.addMimeTypes("text/xml xml XML"); mimetypesFileTypeMap.addMimeTypes("text/dbml dbml DBML"); mimetypesFileTypeMap.addMimeTypes("video/mpeg mpg MPG"); mimetypesFileTypeMap.addMimeTypes( "video/mpeg2 m2p M2P m2v M2V mpv2 MPV2 mp2v MP2V vob VOB"); mimetypesFileTypeMap.addMimeTypes("video/avi avi AVI"); mimetypesFileTypeMap.addMimeTypes("video/x-ms-wmv wmv WMV"); mimetypesFileTypeMap.addMimeTypes("video/quicktime mov MOV"); mimetypesFileTypeMap.addMimeTypes("audio/wav wav WAV"); mimetypesFileTypeMap.addMimeTypes("audio/mpeg mp1 MP1 mp2 MP2 mp3 MP3 mpa MPA"); mimetypesFileTypeMap.addMimeTypes("audio/aiff aif AIF aiff AIFF"); mimetypesFileTypeMap.addMimeTypes("audio/ogg ogg OGG"); mimetypesFileTypeMap.addMimeTypes("application/vnd.ms-powerpoint ppt PPT"); mimetypesFileTypeMap.addMimeTypes( "application/vnd.openxmlformats-officedocument.presentationml.presentation pptx PPTX"); mimetypesFileTypeMap.addMimeTypes( "application/vnd.oasis.opendocument.presentation odp ODP"); mimetypesFileTypeMap.addMimeTypes("application/vnd.ms-excel xls XLS"); mimetypesFileTypeMap.addMimeTypes( "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx XLSX"); mimetypesFileTypeMap.addMimeTypes("application/vnd.oasis.opendocument.spreadsheet ods ODS"); mimetypesFileTypeMap.addMimeTypes("application/cdr cdr CDR"); mimetypesFileTypeMap.addMimeTypes("application/illustrator ai AI"); mimetypesFileTypeMap.addMimeTypes("application/x-qgis shp SHP"); mimetypesFileTypeMap.addMimeTypes("application/acad dwg DWG"); mimetypesFileTypeMap.addMimeTypes("message/rfc822 eml EML"); mimetypesFileTypeMap.addMimeTypes("application/msoutlook msg MSG"); } } return mimetypesFileTypeMap; }
@BeforeClass public void setUp() throws Exception { jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks"); providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri(); String persistDir = TestUtils.getTempDirectory(); setupKDCAndPrincipals(); setupCredentials(); // client will actually only leverage subset of these properties final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl); persistSSLClientConfiguration(configuration); TestUtils.writeConfiguration( configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); String confLocation = System.getProperty("atlas.conf"); URL url; if (confLocation == null) { url = NegativeSSLAndKerberosTest.class.getResource( "/" + ApplicationProperties.APPLICATION_PROPERTIES); } else { url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL(); } configuration.load(url); configuration.setProperty(TLS_ENABLED, true); configuration.setProperty("atlas.authentication.method.kerberos", "true"); configuration.setProperty("atlas.authentication.keytab", userKeytabFile.getAbsolutePath()); configuration.setProperty("atlas.authentication.principal", "dgi/localhost@" + kdc.getRealm()); configuration.setProperty("atlas.authentication.method.file", "false"); configuration.setProperty("atlas.authentication.method.kerberos", "true"); configuration.setProperty( "atlas.authentication.method.kerberos.principal", "HTTP/localhost@" + kdc.getRealm()); configuration.setProperty( "atlas.authentication.method.kerberos.keytab", httpKeytabFile.getAbsolutePath()); configuration.setProperty( "atlas.authentication.method.kerberos.name.rules", "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT"); configuration.setProperty("atlas.authentication.method.file", "true"); configuration.setProperty( "atlas.authentication.method.file.filename", persistDir + "/users-credentials"); configuration.setProperty("atlas.auth.policy.file", persistDir + "/policy-store.txt"); TestUtils.writeConfiguration( configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); setupUserCredential(persistDir); setUpPolicyStore(persistDir); // save original setting originalConf = System.getProperty("atlas.conf"); System.setProperty("atlas.conf", persistDir); dgiClient = new AtlasClient(configuration, DGI_URL); secureEmbeddedServer = new TestSecureEmbeddedServer(21443, getWarPath()) { @Override public Configuration getConfiguration() { return configuration; } }; secureEmbeddedServer.getServer().start(); }
public static void main(String[] args) throws IOException, InitializationException, ConfigurationException { CmdLineConfig parserCmdLine = new CmdLineConfig(); try { parserCmdLine.parserCmdLine(args); if (parserCmdLine.printHelp) { parserCmdLine.printUsage(); System.exit(0); } } catch (Exception e) { parserCmdLine.printUsage(); System.err.println(e.getMessage()); return; } finally { checkIfShowBatchProcessingIsEnabled(parserCmdLine); } BatchProcessor batchProcessor = new BatchProcessor(); batchProcessor.setFiles(parserCmdLine.files); if (parserCmdLine.dirWithJars != null) { File f = new File(parserCmdLine.dirWithJars); URL[] urls = null; if (f.isDirectory()) { File[] listFiles = f.listFiles(f1 -> f1.isFile() && f1.getName().endsWith(".jar")); urls = new URL[listFiles.length]; for (int i = 0; i < urls.length; i++) { urls[i] = listFiles[i].toURI().toURL(); } } else if (f.getName().endsWith("jar")) { urls = new URL[] {f.toURI().toURL()}; } if (urls == null) { System.err.println( "Dir with additional jars or single jars do not point to dir with jars or single jar"); System.exit(1); } URLClassLoader classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); } ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { batchProcessor.setLogDataParsedListener( (LogDataParsedListener) cl.loadClass(parserCmdLine.logDataParsedListenerClass).newInstance()); // batchProcessor.setLogDataCollector((LogDataParsedListener) // cl.loadClass(parserCmdLine.logDataParsedListenerClass).newInstance()); } catch (Exception e2) { System.err.println("Can't load log data collector: " + e2.getMessage()); } batchProcessor.batchProcessingContext.setVerbose(parserCmdLine.verbose); // load processing configuration if (parserCmdLine.batchConfigurationFile != null) { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.load(parserCmdLine.batchConfigurationFile); batchProcessor.batchProcessingContext.getConfiguration().append(propertiesConfiguration); } batchProcessor.batchProcessingContext.printIfVerbose("Processing started"); try { batchProcessor.process(); batchProcessor.batchProcessingContext.printIfVerbose("Finished"); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); System.out.println(Throwables.getStackTraceAsString(e)); } }