Example usage for java.util Properties getProperty

List of usage examples for java.util Properties getProperty

Introduction

In this page you can find the example usage for java.util Properties getProperty.

Prototype

public String getProperty(String key) 

Source Link

Document

Searches for the property with the specified key in this property list.

Usage

From source file:com.feilong.commons.core.configure.PropertiesUtil.java

/**
 * ClassLoaderproperties./*from w w  w  .ja  va  2s  .c o  m*/
 * 
 * @param clz
 *            ?Class
 * @param propertiesPath
 *            Properties "/WEB-INF/classes/feilong.user.properties"
 * @param key
 *            ?.??. null.
 * @return ClassLoaderproperties
 * @see #getPropertiesWithClassLoader(Class, String)
 * @see java.util.Properties#getProperty(String)
 */
public static String getPropertiesValueWithClassLoader(Class<?> clz, String propertiesPath, String key) {
    Properties properties = getPropertiesWithClassLoader(clz, propertiesPath);
    return properties.getProperty(key);
}

From source file:playground.app.Application.java

public static HttpHandler createHttpHandler() throws IOException {
    Properties prop = new Properties();
    prop.load(Application.class.getClassLoader().getResourceAsStream("application.properties"));
    String profiles = prop.getProperty("profiles");
    if (profiles != null) {
        System.setProperty("spring.profiles.active", profiles);
    }/*from  w  w w  .j a  v  a 2  s .c  o m*/

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground");

    DispatcherHandler dispatcherHandler = new DispatcherHandler();
    dispatcherHandler.setApplicationContext(context);

    Map<String, WebFilter> beanNameToFilters = context.getBeansOfType(WebFilter.class);
    WebFilter[] filters = beanNameToFilters.values().toArray(new WebFilter[0]);
    Arrays.sort(filters, AnnotationAwareOrderComparator.INSTANCE);

    return WebHttpHandlerBuilder.webHandler(dispatcherHandler)
            .exceptionHandlers(new ResponseStatusExceptionHandler()).filters(filters).build();
}

From source file:gobblin.util.JobConfigurationUtils.java

/**
 * Put all configuration properties in a given {@link Properties} object into a given
 * {@link Configuration} object./*from  w w w.  ja v a 2s.  co  m*/
 *
 * @param properties the given {@link Properties} object
 * @param configuration the given {@link Configuration} object
 */
public static void putPropertiesIntoConfiguration(Properties properties, Configuration configuration) {
    for (String name : properties.stringPropertyNames()) {
        configuration.set(name, properties.getProperty(name));
    }
}

From source file:com.opengamma.bbg.test.BloombergTestUtils.java

/**
 * Creates Bloomberg session options for testing.
 * //from w w w.  j a va2 s  .  c o  m
 * @return the session options, not null
 */
private static SessionOptions getSessionOptions() {
    SessionOptions options = new SessionOptions();
    Properties properties = TestProperties.getTestProperties();
    String serverHost = properties.getProperty("bbgServer.host");
    if (StringUtils.isBlank(serverHost)) {
        throw new OpenGammaRuntimeException("bloomberg.host is missing in tests.properties");
    }
    String serverPort = properties.getProperty("bbgServer.port");
    if (StringUtils.isBlank(serverPort)) {
        throw new OpenGammaRuntimeException("bloomberg.port is missing in tests.properties");
    }
    options.setServerHost(serverHost);
    options.setServerPort(Integer.parseInt(serverPort));
    return options;
}

From source file:com.opengamma.bbg.test.BloombergTestUtils.java

/**
 * Creates a Mongo connector for testing.
 * /* w w  w  .  j a v a  2 s  .c o  m*/
 * @return the connector, not null
 */
public static MongoConnector getMongoConnector() {
    Properties testProperties = TestProperties.getTestProperties();
    String mongoHost = testProperties.getProperty("mongoServer.host");
    int mongoPort = Integer.parseInt(testProperties.getProperty("mongoServer.port"));
    MongoConnectorFactoryBean mongoFactory = new MongoConnectorFactoryBean();
    mongoFactory.setName("BloombergTestUtils");
    mongoFactory.setHost(mongoHost);
    mongoFactory.setPort(mongoPort);
    mongoFactory.setDatabaseName("testReferenceData");
    mongoFactory.setCollectionSuffix("bloomberg-security-loader-test-context");
    return mongoFactory.getObjectCreating();
}

From source file:Main.java

static String extractComment(String tag, Properties properties) {
    if (properties == null || "span".equals(tag)) {
        return null;
    }//from  w w  w. ja va 2  s . c om

    String[] attributes = new String[] { "id", "name", "class" };
    for (String a : attributes) {
        String comment = properties.getProperty(a);
        if (comment != null) {
            return "<span class=\"com\">&lt;!-- " + comment.replaceAll("[-]{2,}", "-") + " --&gt;</span>";
        }
    }

    return null;
}

From source file:com.imolinfo.offline.CrossFoldValidation.java

public static void invokePipeline(JavaSparkContext jsc)
        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {

    JavaRDD<Document> trainingSet, testSet;
    Logger.getLogger("org").setLevel(Level.OFF);
    Logger.getLogger("akka").setLevel(Level.OFF);

    // CARICAMENTO DEL DATASET E PARTIZIONE IN PIU PEZZETTINI
    Properties prop = GlobalVariable.getInstance().getProperties();

    DocumentProvider tp = (DocumentProvider) Class.forName(prop.getProperty("sourceClass")).newInstance();
    JavaRDD<Document> corpus = tp.getTextFromDs(jsc,
            prop.getProperty("splitDatasetPath") + "/" + prop.getProperty("corpus"));
    DocumentStandardCleaner tc = new DocumentStandardCleaner();
    corpus = tc.cleanData(corpus);/*w ww.  j av  a2s .c om*/
    corpus.cache();
    ArrayList<JavaRDD<Document>[]> LabelPortionSplits = new ArrayList<JavaRDD<Document>[]>();
    for (final String label : GlobalVariable.getInstance().getIntLabelMap().values()) {
        JavaRDD<Document> labelPortion = corpus.filter(new Function<Document, Boolean>() {

            @Override
            public Boolean call(Document arg0) throws Exception {
                return arg0.getLabel().equals(label);
            }
        });
        labelPortion.cache();
        JavaRDD<Document>[] labelPortionSplit = labelPortion
                .randomSplit(new double[] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 });
        LabelPortionSplits.add(labelPortionSplit);
    }

    // metto in cache tutti dataset piccolini divisi per label e poi partizionati secondo il fattore K...
    for (JavaRDD<Document>[] line : LabelPortionSplits) {
        for (int j = 0; j < line.length; j++) {
            line[j].cache();
        }
    }
    JavaRDD<Document>[] splitDataset = LabelPortionSplits.get(0);
    ArrayList<JavaRDD<Document>> otherSplits = new ArrayList<JavaRDD<Document>>();

    String result = "";
    // combino i dataset in modo da realizzare partizioni stratificati
    for (int i = 0; i < splitDataset.length; i++) {
        otherSplits.clear();
        for (int j = 1; j < LabelPortionSplits.size(); j++) {
            JavaRDD<Document>[] target = LabelPortionSplits.get(j);
            target[i].cache();
            otherSplits.add(target[i]);
        }
        splitDataset[i] = jsc.union(splitDataset[i], otherSplits);
        splitDataset[i].cache();
    }
    ArrayList<JavaRDD<Document>> trainingSetList = new ArrayList<JavaRDD<Document>>();
    // metto assieme le partizioni stratificate in modo da iterare training e testset
    List<JavaRDD<Document>> splitDocuments = Arrays.asList(splitDataset);
    for (int i = 0; i < splitDocuments.size(); i++) {
        testSet = splitDocuments.get(i);
        trainingSet = corpus.subtract(testSet);
        result = result + "\n" + trainAndTest(jsc, trainingSet, testSet);

    }
    System.out.println(result);

}

From source file:com.founder.fix.fixflow.I18N.PropertiesUtil.java

/**
 * // www  .ja  v  a 2  s. com
 * @param path 
 * @param key 
 * @return 
 */
public static String getProperty(String path, String key) {
    Properties prop = propsMap.get(path);
    if (prop == null)
        prop = load(path);
    if (prop == null)
        return null;
    return prop.getProperty(key);
}

From source file:org.eclipse.lyo.testsuite.oslcv2.SimplifiedQueryRdfXmlTests.java

@Parameters
public static Collection<Object[]> getAllDescriptionUrls() throws IOException {
    Properties setupProps = SetupProperties.setup(null);
    ArrayList<String> serviceUrls = getServiceProviderURLsUsingRdfXml(setupProps.getProperty("baseUri"),
            onlyOnce);/* w w w . j  av  a 2 s.  c o m*/
    ArrayList<String> capabilityURLsUsingRdfXml = TestsBase
            .getCapabilityURLsUsingRdfXml(OSLCConstants.QUERY_BASE_PROP, serviceUrls, true);
    return toCollection(capabilityURLsUsingRdfXml);
}

From source file:com.glaf.core.jdbc.connection.ConnectionProviderFactory.java

protected static void closeAndCreate(Properties properties) {
    String jdbcUrl = properties.getProperty(DBConfiguration.JDBC_URL);
    String cacheKey = DigestUtils.md5Hex(jdbcUrl);
    ConnectionProvider provider = null;/*w  ww  .  ja v  a  2  s .  c  o m*/
    if (providerCache.get(cacheKey) != null) {
        provider = providerCache.get(cacheKey);
        provider.close();
    }
    provider = createProvider(properties, null);
    providerCache.put(cacheKey, provider);
}