List of usage examples for java.util Properties getProperty
public String getProperty(String key)
From source file:com.googlecode.jsendnsca.NagiosSettingsFactory.java
private static String getValue(Properties properties, String name) throws NagiosConfigurationException { String value = properties.getProperty(name); if (StringUtils.isBlank(value)) { throw new NagiosConfigurationException("Key [%s] value cannot be empty or purely whitespace", name); }/*from w ww . j a v a2 s .c om*/ return value; }
From source file:edu.usc.polar.NLTKNERRecogniser.java
public static String readRestUrl() throws IOException { Properties nltkProperties = new Properties(); nltkProperties.load(NLTKNERRecogniser.class.getResourceAsStream("NLTKServer.properties")); return nltkProperties.getProperty("nltk.server.url"); }
From source file:com.github.dryangkun.hbase.tidx.hive.HiveHFileOutputFormat.java
/** * Retrieve the family path, first check the JobConf, then the table properties. * @return the family path or null if not specified. *///from www . j a va 2 s. co m public static String getFamilyPath(Configuration jc, Properties tableProps) { return jc.get(HFILE_FAMILY_PATH, tableProps.getProperty(HFILE_FAMILY_PATH)); }
From source file:de.steilerdev.myVerein.server.apns.PushService.java
/** * This function creates a new APNS instance. If the function returns null, APNS is not supported. * @return The current APNS instance. If null APNS is not supported by this server. *///from ww w .jav a 2s .c o m public static PushManager<SimpleApnsPushNotification> getInstanced() { if (pushManager == null) { logger.debug("Creating new APNS instance"); try { Resource settingsResource = new ClassPathResource(apnsSettingsFile); Properties settings = PropertiesLoaderUtils.loadProperties(settingsResource); InputStream certFile = Thread.currentThread().getContextClassLoader() .getResourceAsStream(settings.getProperty(fileKey)); pushManager = new PushManager<>(ApnsEnvironment.getSandboxEnvironment(), SSLContextUtil.createDefaultSSLContext(certFile, settings.getProperty(passwordKey)), null, // Optional: custom event loop group null, // Optional: custom ExecutorService for calling listeners null, // Optional: custom BlockingQueue implementation new PushManagerConfiguration(), "ExamplePushManager"); logger.debug("Created new APNS instance, starting"); //pushManager.start(); } catch (IOException e) { logger.warn("Unable to load APNS settings file: {}", e.getMessage()); return null; } catch (Exception e) { logger.warn("An unknown error occurred: {}", e.getMessage()); } } logger.info("Returning APNS instance"); return pushManager; }
From source file:controllers.FormsController.java
private static JsonNode generateFieldFromProperty(String fieldName) { Properties props = getPropertyFile(); ObjectNode formElememt = Json.newObject(); formElememt.put("name", fieldName); formElememt.put("label", props.getProperty(fieldName + "_label")); formElememt.put("type", props.getProperty(fieldName + "_type")); if (formElememt.get("type").asText().equalsIgnoreCase("list")) { try {//from ww w.j a v a2 s .c om Class<?> cl = Class.forName("models.fixed." + Character.toString(fieldName.charAt(0)).toUpperCase() + fieldName.substring(1)); List<?> l = Ebean.find(cl).findList(); formElememt.put("options", Json.toJson(l)); } catch (ClassNotFoundException ex) { Logger.getLogger(FormsController.class.getName()).log(Level.SEVERE, null, ex); } } ObjectNode validations = Json.newObject(); validations.put("required", props.getProperty(fieldName + "_validations_required")); validations.put("pattern", props.getProperty(fieldName + "_validations_pattern")); formElememt.put("validations", validations); ObjectNode messages = Json.newObject(); messages.put("invalid", props.getProperty(fieldName + "_validationmessages_invalid")); messages.put("required", props.getProperty(fieldName + "_validationmessages_required")); messages.put("pattern", props.getProperty(fieldName + "_validationmessages_pattern")); formElememt.put("validationMessages", messages); return Json.toJson(formElememt); }
From source file:energy.usef.time.Config.java
/** * Returns the configuration folder of the application or for unit tests. * * @return the configuration Folder/*from w ww . j a v a2s .com*/ */ public static String getConfigurationFolder() { String folderName; if (isDeployed()) { Properties localProperties = readApplicationProperties(); String applicationName = localProperties.getProperty(APPLICATION_NAME_PROPERTY); folderName = DOMAIN_CONFIG_FOLDER + File.separator + applicationName + File.separator; } else { folderName = SRC_TEST_RESOURCES_FOLDER; } return folderName; }
From source file:gobblin.util.SchedulerUtils.java
/** * Load job configuration from job configuration files stored in general file system, * located by Path/*from w w w.j ava 2 s. c om*/ * @param sysProps Gobblin framework configuration properties * @return a list of job configurations in the form of {@link java.util.Properties} */ public static List<Properties> loadGenericJobConfigs(Properties sysProps) throws ConfigurationException, IOException { Path rootPath = new Path(sysProps.getProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY)); PullFileLoader loader = new PullFileLoader(rootPath, rootPath.getFileSystem(new Configuration()), getJobConfigurationFileExtensions(sysProps), PullFileLoader.DEFAULT_HOCON_PULL_FILE_EXTENSIONS); Config sysConfig = ConfigUtils.propertiesToConfig(sysProps); Collection<Config> configs = loader.loadPullFilesRecursively(rootPath, sysConfig, true); List<Properties> jobConfigs = Lists.newArrayList(); for (Config config : configs) { try { jobConfigs.add(resolveTemplate(ConfigUtils.configToProperties(config))); } catch (IOException ioe) { LOGGER.error("Could not parse job config at " + ConfigUtils.getString(config, ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, "Unknown path"), ioe); } } return jobConfigs; }
From source file:com.textocat.textokit.eval.EvaluationLauncher.java
private static Map<String, String> getPrefixedKeyPairs(Properties props, String prefix) { Map<String, String> result = Maps.newHashMap(); for (String key : props.stringPropertyNames()) { if (key.startsWith(prefix)) { result.put(key.substring(prefix.length()), props.getProperty(key)); }//from ww w . java2 s . c o m } return result; }
From source file:net.padlocksoftware.padlock.KeyManager.java
/** * Import a Padlock 2.x (DSA based) KeyPair from an InputStream. The stream is * assumed to have been previously exported in a supported format using the * exportKeyPair methods./* w w w .j a v a2 s.com*/ * @param stream The KeyPair stream to import. * @return The DSA KeyPair contained in the specified file. * @throws java.io.IOException If file is missing or contain invalid data. * @since 2.0 */ public static KeyPair importKeyPair(InputStream stream) throws IOException { if (stream == null) throw new IllegalArgumentException("Stream cannot be null"); KeyPair pair = null; Properties p = new Properties(); p.load(stream); stream.close(); String pri = p.getProperty("private"); String pub = p.getProperty("public"); if (pri == null || pub == null) { throw new IOException("Stream data is invalid"); } // Load the keys try { PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(Hex.decodeHex(pri.toCharArray())); KeyFactory keyFactory = KeyFactory.getInstance("DSA"); PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec); X509EncodedKeySpec pubSpec = new X509EncodedKeySpec(Hex.decodeHex(pub.toCharArray())); PublicKey publicKey = keyFactory.generatePublic(pubSpec); pair = new KeyPair(publicKey, privateKey); } catch (Exception e) { throw new RuntimeException("Invalid stream: " + e.getMessage()); } return pair; }
From source file:com.kurento.test.base.BaseArquillianTst.java
@Deployment public static WebArchive createDeployment() throws IOException { InputStream inputStream = new FileInputStream("target/test-classes/test.properties"); Properties properties = new Properties(); properties.load(inputStream);/*from w ww .java2 s . c om*/ WebArchive war = ShrinkWrap.create(ZipImporter.class, "kmf-content-api-test.war") .importFrom(new File("target/" + properties.getProperty("project.artifactId") + "-" + properties.getProperty("project.version") + ".war")) .as(WebArchive.class).addPackages(true, "com.kurento"); return war; }