Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#setThrowExceptionOnMissing()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#setThrowExceptionOnMissing() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelegatedAccessDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * 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; } }
Example 2
Source File: DelegatedAccessDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * 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; } }
Example 3
Source File: Config.java From jmxmon with Apache License 2.0 | 5 votes |
public void init(String configPath) throws ConfigurationException, IOException{ logger.info("init config"); PropertiesConfiguration config = new PropertiesConfiguration(configPath); config.setThrowExceptionOnMissing(true); this.workDir = config.getString("workDir"); if (new File(workDir).isDirectory() == false) { throw new IllegalArgumentException("workDir is not a directory"); } this.hostname = config.getString("hostname", Utils.getHostNameForLinux()); this.jvmContextFile = new File(workDir, "jmxmon.jvm.context.json"); if (jvmContextFile.exists() && jvmContextFile.isFile() && jvmContextFile.length() > 0) { logger.info(jvmContextFile.getAbsolutePath() + " is exist, start loading..."); this.jvmContext = JacksonUtil.readBeanFromFile(jvmContextFile, JVMContext.class); } else { logger.info(jvmContextFile.getAbsolutePath() + " is not exist"); } this.agentPostUrl = config.getString("agent.posturl"); this.step = config.getInt("step", Constants.defaultStep); // 默认的jmxHost为localhost,除非通过-D参数设置(线上不建议以远程方式采集,最好每台机器上部署agent,这样agent才能水平伸缩) this.jmxHost = System.getProperty("debug.jmx.host"); if (this.jmxHost == null) { this.jmxHost = "localhost"; } String[] jmxPortArray = config.getStringArray("jmx.ports"); jmxPorts = new int[jmxPortArray.length]; for (int i = 0; i < jmxPortArray.length; i++) { jmxPorts[i] = Integer.parseInt(jmxPortArray[i]); } logger.info("init config ok"); }
Example 4
Source File: TutorialEntityProviderImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private void initConfig() { URL url = getClass().getClassLoader().getResource("Tutorial.config"); try { tutorialProps = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) tutorialProps.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads tutorialProps.setThrowExceptionOnMissing(false); //throw exception if no prop tutorialProps.setDelimiterParsingDisabled(true); //don't split properties tutorialProps.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage()); return; } }
Example 5
Source File: TutorialEntityProviderImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private void initConfig() { URL url = getClass().getClassLoader().getResource("Tutorial.config"); try { tutorialProps = new PropertiesConfiguration(); //must use blank constructor so it doesn't parse just yet (as it will split) tutorialProps.setReloadingStrategy(new InvariantReloadingStrategy()); //don't watch for reloads tutorialProps.setThrowExceptionOnMissing(false); //throw exception if no prop tutorialProps.setDelimiterParsingDisabled(true); //don't split properties tutorialProps.load(url); //now load our file } catch (ConfigurationException e) { log.error(e.getClass() + ": " + e.getMessage()); return; } }
Example 6
Source File: AbstractKeycloakTest.java From keycloak with Apache License 2.0 | 4 votes |
private void loadConstantsProperties() throws ConfigurationException { constantsProperties = new PropertiesConfiguration(System.getProperty("testsuite.constants")); constantsProperties.setThrowExceptionOnMissing(true); }