Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

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

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadResourceWithSelectedDocuments() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResources(new Resource[] {
            new ByteArrayResource("foo: bar\nspam: baz\n---\nfoo: bag\nspam: bad".getBytes()) });
    factory.setDocumentMatchers(Collections.singletonMap("foo", "bag"));
    Properties properties = factory.getObject();
    assertEquals("bag", properties.get("foo"));
    assertEquals("bad", properties.get("spam"));
}

From source file:net.yacy.yacy.java

private static void submitURL(final File homePath, final String path, final String processdescription) {
    final Properties config = configuration("COMMAND-STEERING", homePath);

    // read port/*from   w  ww.  ja  v  a  2  s . com*/
    final int port = Integer.parseInt(config.getProperty(SwitchboardConstants.SERVER_PORT, "8090"));

    // read password
    String encodedPassword = (String) config.get(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5);
    if (encodedPassword == null)
        encodedPassword = ""; // not defined

    // send 'wget' to web interface
    final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
    // con.setHeader(requestHeader.entrySet());
    try {
        con.GETbytes("http://localhost:" + port + "/" + path,
                config.getProperty(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"), encodedPassword,
                false);
        if (con.getStatusCode() > 199 && con.getStatusCode() < 300) {
            ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription);

        } else {
            ConcurrentLog.severe("COMMAND-STEERING",
                    "error response from YACY socket: " + con.getHttpResponse().getStatusLine());
            System.exit(-1);
        }
    } catch (final IOException e) {
        ConcurrentLog.severe("COMMAND-STEERING",
                "could not establish connection to YACY socket: " + e.getMessage());
        System.exit(-1);
    }

    try {
        HTTPClient.closeConnectionManager();
    } catch (final InterruptedException e) {
        e.printStackTrace();
    }
    RemoteInstance.closeConnectionManager();

    // finished
    ConcurrentLog.config("COMMAND-STEERING", "SUCCESSFULLY FINISHED COMMAND: " + processdescription);
}

From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadResourceWithDefaultMatch() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setMatchDefault(true);//ww  w  .  j  a  va  2s.com
    factory.setResources(new Resource[] {
            new ByteArrayResource("one: two\n---\nfoo: bar\nspam: baz\n---\nfoo: bag\nspam: bad".getBytes()) });
    factory.setDocumentMatchers(Collections.singletonMap("foo", "bag"));
    Properties properties = factory.getObject();
    assertEquals("bag", properties.get("foo"));
    assertEquals("bad", properties.get("spam"));
    assertEquals("two", properties.get("one"));
}

From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadResourceWithDefaultMatchSkippingMissedMatch() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setMatchDefault(true);/*  w  w w.  ja  v a 2 s.  c  o  m*/
    factory.setResources(new Resource[] {
            new ByteArrayResource("one: two\n---\nfoo: bag\nspam: bad\n---\nfoo: bar\nspam: baz".getBytes()) });
    factory.setDocumentMatchers(Collections.singletonMap("foo", "bag"));
    Properties properties = factory.getObject();
    assertEquals("bag", properties.get("foo"));
    assertEquals("bad", properties.get("spam"));
    assertEquals("two", properties.get("one"));
}

From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.HashMapToStringUserType.java

@Override
public void setParameterValues(Properties parameters) {
    String keyType = (String) parameters.get("keyType");
    if (!StringUtils.isEmpty(keyType)) {
        try {//  ww w  .  ja  va2 s.  co m
            this.keyType = Class.forName(keyType);
        } catch (ClassNotFoundException e) {
            throw new HibernateException(e);
        }
    } else {
        this.keyType = String.class;
    }

}

From source file:org.intelligentsia.utility.jpa.usertype.JSONUserType.java

/**
 * @see org.hibernate.usertype.ParameterizedType#setParameterValues(java.util.Properties)
 *///  ww  w  .j  a v  a2  s .com
@Override
public void setParameterValues(final Properties parameters) {
    final String name = (String) parameters.get("innerType");
    try {
        exposedClass = Thread.currentThread().getContextClassLoader().loadClass(name);
    } catch (final ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}

From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.PropertiesChainedRegexURLRequestMapperDAOTest.java

/** @throws Exception on error */
public final void testSave() throws Exception {
    final URLRequestMapper c = new ChainedURLRequestMapper(Arrays.asList(new URLRequestMapper[] {
            new RegexURLRequestMapper(Pattern.compile("^/nexus/(.*)$"), "http://localhost:9095/nexus/$1"),
            new RegexURLRequestMapper(Pattern.compile("^/([^/]+)/([^/]+)/([^/]+)/(.*)$"),
                    "http://localhost:9095/nexus/content/repositories/$1-$2-$3/$4"),

    }));/*from   w  ww. j a v a2 s.c  o m*/
    new PropertiesChainedRegexURLRequestMapperDAO(new SimplePropertiesProvider(), new PropertiesPersister() {
        public void save(final Properties properties) {
            assertEquals(2, properties.size());
            assertEquals("^/nexus/(.*)$=http://localhost:9095/nexus/$1", properties.get("0"));
            assertEquals("^/([^/]+)/([^/]+)/([^/]+)/(.*)$=http://"
                    + "localhost:9095/nexus/content/repositories/$1-$2-$3/$4", properties.get("1"));
        }
    }).save(c);
}

From source file:fish.payara.maven.plugins.micro.processor.SystemPropAppendProcessor.java

private Element[] constructElementsForSystemProperties() {
    List<Element> elements = new ArrayList<>();
    Properties properties = System.getProperties();
    for (Object key : properties.keySet()) {
        Element element = element(name("line"), escapeJava(key + "=" + properties.get(key)));
        elements.add(element);/*from   w ww . ja va  2  s.  com*/
    }
    return elements.toArray(new Element[elements.size()]);
}

From source file:com.example.journal.env.JournalEnvironmentPostProcessor.java

private void contributeDefaults(Map<String, Object> defaults, Resource resource) {
    if (resource.exists()) {
        YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
        yamlPropertiesFactoryBean.setResources(resource);
        yamlPropertiesFactoryBean.afterPropertiesSet();
        Properties p = yamlPropertiesFactoryBean.getObject();
        for (Object k : p.keySet()) {
            String key = k.toString();
            defaults.put(key, p.get(key));
        }/* w w w.  ja  v a2s . c om*/
    }
}

From source file:com.przemo.projectmanagementweb.Application.java

@Override
public RuntimeConfigurationType getConfigurationType() {
    Properties applicationProperties = new Properties();
    try {/*from   ww  w .j  a  v a2  s  . com*/
        applicationProperties.load(this.getClass().getResourceAsStream("application.properties"));
        String dm = applicationProperties.get(DEPLOYMENT_MODE).toString();
        return dm.equals("deployment") ? RuntimeConfigurationType.DEPLOYMENT
                : RuntimeConfigurationType.DEVELOPMENT;
    } catch (IOException ex) {
        Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
    }
    return super.getConfigurationType();
}