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:io.fabric8.forge.camel.commands.project.AbstractCamelProjectCommand.java

protected Set<String> discoverCustomCamelComponentsOnClasspathAndAddToCatalog(CamelCatalog camelCatalog,
        Project project) {/*from w  w w.j  a  va  2  s .co m*/
    Set<String> answer = new LinkedHashSet<>();

    // find the dependency again because forge don't associate artifact on the returned dependency when installed
    MavenDependencyFacet facet = project.getFacet(MavenDependencyFacet.class);
    List<Dependency> list = facet.getEffectiveDependencies();

    for (Dependency dep : list) {
        Properties properties = loadComponentProperties(dep);
        if (properties != null) {
            String components = (String) properties.get("components");
            if (components != null) {
                String[] part = components.split("\\s");
                for (String scheme : part) {
                    if (!camelCatalog.findComponentNames().contains(scheme)) {
                        // find the class name
                        String javaType = extractComponentJavaType(dep, scheme);
                        if (javaType != null) {
                            String json = loadComponentJSonSchema(dep, scheme);
                            if (json != null) {
                                camelCatalog.addComponent(scheme, javaType, json);
                                answer.add(scheme);
                            }
                        }
                    }
                }
            }
        }
    }

    return answer;
}

From source file:de.suse.swamp.webswamp.SwampUIManager.java

/**
 * Load the specified skin on top of the "common" skin.
 */// ww w .j  a  va 2  s.  c  o m
private void loadSkin() {
    resourceProperties = new Properties();

    try {
        FileInputStream is = new FileInputStream(skinsDirectory + "/common/" + RESOURCES_PROPS_FILE);
        resourceProperties.load(is);
        for (Iterator it = resourceProperties.keySet().iterator(); it.hasNext();) {
            String key = (String) it.next();
            resourceProperties.put(key, "common/images/" + resourceProperties.get(key));
        }
    } catch (Exception e) {
        Logger.ERROR("Cannot load resources for skin: common! " + e.getMessage());
    }

    try {
        FileInputStream is = new FileInputStream(skinsDirectory + "/" + getSkin() + "/" + RESOURCES_PROPS_FILE);
        Properties resourceProperties2 = new Properties();
        resourceProperties2.load(is);
        for (Iterator it = resourceProperties2.keySet().iterator(); it.hasNext();) {
            String key = (String) it.next();
            resourceProperties2.put(key, getSkin() + "/images/" + resourceProperties2.get(key));
        }
        resourceProperties.putAll(resourceProperties2);
    } catch (Exception e) {
        Logger.ERROR("Cannot load resources for skin: " + super.getSkin());
    }

    skinProperties = new Properties();

    try {
        FileInputStream is = new FileInputStream(skinsDirectory + "/common/" + SKIN_PROPS_FILE);
        skinProperties.load(is);
    } catch (Exception e) {
        Logger.ERROR("Cannot load common skin props: " + super.getSkin());
    }

    try {
        FileInputStream is = new FileInputStream(skinsDirectory + "/" + getSkin() + "/" + SKIN_PROPS_FILE);
        Properties skinProperties2 = new Properties();
        skinProperties2.load(is);
        skinProperties.putAll(skinProperties2);
    } catch (Exception e) {
        Logger.ERROR("Cannot load skin props for: " + super.getSkin());
    }
}

From source file:com.activequant.server.web.MainController.java

@RequestMapping("/server")
public String server(Map<String, Object> map) {

    Properties properties = new Properties();
    try {/*from w  w w.j a va 2 s.c o m*/
        properties.load(new FileInputStream("framework.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

    TreeMap<String, Object> tmap2 = new TreeMap<String, Object>();
    for (Object s : properties.keySet()) {
        String key = (String) s;
        tmap2.put(key, properties.get(key));
    }

    properties = new Properties();
    try {
        properties.load(new FileInputStream("aq2server.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

    TreeMap<String, Object> tmap = new TreeMap<String, Object>();
    for (Object s : properties.keySet()) {
        String key = (String) s;
        tmap.put(key, properties.get(key));
    }

    map.put("framework", tmap2);
    map.put("aq2server", tmap);
    return "server";
}

From source file:ob.PO.TaskPO.java

@Override
public void run() {
    setTaskLog("");
    if (thistype == 0) {//
        Date tasktime;//from w w w  .j  a v  a 2  s.c  om
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss"); //????
        try {
            tasktime = sdf.parse(thisstr1 + thisstr2);
            //if(cl.)
        } catch (ParseException ex) {
            setTaskLog("");
            return;
        }
        Date nowtime = new Date();
        if (nowtime.after(tasktime)) {
            setTaskLog("??");
            return;
        }
        while (nowtime.before(tasktime)) {
            long deltaminute = (tasktime.getTime() - nowtime.getTime()) / (1000 * 60); //
            long day = deltaminute / (24 * 60);
            long hour = (deltaminute / 60) % 24;
            long minute = deltaminute % 60;
            setTaskLog("\n" + day + "" + hour + "" + minute
                    + "");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException ex) {
                setTaskLog("");
                return;
            }
            nowtime = new Date();
        }
        if (nowtime.getTime() - tasktime.getTime() > 60 * 1000) {//?
            setTaskLog("?");
            return;
        }
        setTaskLog("");
    } else if (thistype == 1) {//
        int lastmessage_num = -1;
        POP3SClient pop3 = new POP3SClient(true);
        POP3MessageInfo[] messages;
        pop3.setDefaultTimeout(600000);
        while (true) {
            try {
                pop3.connect("pop." + thisstr1.split("@")[1]);//pop. + domain
                if (!pop3.login(thisstr1, AESUtil.Decryptor(thisstr2))) {
                    pop3.disconnect();
                    setTaskLog("?.");
                    return;
                }
                messages = pop3.listMessages();
                if (lastmessage_num < 0) {//?
                    lastmessage_num = messages.length;//?
                    setTaskLog("?" + lastmessage_num);
                } else if (lastmessage_num < messages.length) {//
                    break;
                }
                setTaskLog("?" + messages.length);
                Thread.sleep(10000);
            } catch (Exception ex) {
                setTaskLog("");
                return;
            }
        }
        setTaskLog("");
    } else if (thistype == 2) {//?
        setTaskLog("??");
        while (true) {
            try {
                String Access_token;
                if ((Access_token = Sina.getToken(thisstr1, AESUtil.Decryptor(thisstr2))
                        .getAccessToken()) == null) {
                    setTaskLog("???");
                    return;
                }
                String lasttimeline = GetUserTimeline.getTimeline(Access_token);
                if (lasttimeline == null) {
                } else {
                    if (lasttimeline.contains(thistext)) {//?
                        break;
                    }
                }
                setTaskLog("??");
                Thread.sleep(10000);
            } catch (Exception ex) {
                ex.printStackTrace();
                setTaskLog("??");
                return;
            }
        }
        setTaskLog("???");
    }
    if (thattype == 1) {//?
        setTaskLog("??");
        SimpleEmail email = new SimpleEmail();
        Properties props = new Properties();
        String user, pass;
        try {
            props.load(
                    Thread.currentThread().getContextClassLoader().getResourceAsStream("adminmail.properties"));
            if ((user = (String) props.get("user")) == null || (pass = (String) props.get("pass")) == null) {
                setTaskLog("?");
                return;
            }
            email.setHostName("smtp." + user.split("@")[1]);//?  smtp. + domain
            email.setAuthentication(user, pass);//smtp????  
            email.setSSLOnConnect(true);
            email.addTo(thatusername, "JAVA IFTTT RECEIVER");//  
            email.setFrom(user, "JAVA IFTTT SENDER");//?  
            email.setSubject("JAVA IFTTT SEND EMAIL");//  
            email.setCharset("UTF-8");//??  
            email.setMsg(thattext);//  
            email.send();//??  
        } catch (Exception ex) {
            setTaskLog("??");
            return;
        }
        setTaskLog("????");
    } else if (thattype == 0) {//??
        setTaskLog("???");
        try {
            String Access_token;
            if ((Access_token = Sina.getToken(thatusername, AESUtil.Decryptor(thatpassword))
                    .getAccessToken()) == null) {
                setTaskLog("???");
                return;
            }
            UpdateStatus.Update(Access_token, thattext);
        } catch (Exception ex) {
            ex.printStackTrace();
            setTaskLog("???");
            return;
        }
        setTaskLog("?????");
    }
}

From source file:com.feilong.core.bean.ConvertUtilTest.java

@Test
public void test1() {
    Map<String, Object> map = new LinkedHashMap<>();

    map.put("name", "feilong");
    map.put("age", 18);
    map.put("country", "china");

    Properties properties = org.apache.commons.collections4.MapUtils.toProperties(map);

    LOGGER.debug("" + properties.get("age"));
    LOGGER.debug(properties.getProperty("age"));
    LOGGER.debug(JsonUtil.format(properties));

    LOGGER.debug(JsonUtil.format(toMap(properties)));
}

From source file:it.larusba.neo4j.jdbc.http.driver.CypherExecutor.java

/**
 * Default constructor.//from   w ww .ja  v a  2  s . c  om
 *
 * @param host       Hostname of the Neo4j instance.
 * @param port       HTTP port of the Neo4j instance.
 * @param properties Properties of the url connection.
 * @throws SQLException
 */
public CypherExecutor(String host, Integer port, Properties properties) throws SQLException {
    // Create the http client builder
    HttpClientBuilder builder = HttpClients.custom();
    // Adding authentication to the http client if needed
    if (properties.containsKey("user") && properties.containsKey("password")) {
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(
                properties.get("user").toString(), properties.get("password").toString()));
        builder.setDefaultCredentialsProvider(credsProvider);
    }
    // Setting user-agent
    StringBuilder sb = new StringBuilder();
    sb.append("Neo4j JDBC Driver");
    if (properties.containsKey("userAgent")) {
        sb.append(" via ");
        sb.append(properties.getProperty("userAgent"));
    }
    builder.setUserAgent(sb.toString());
    // Create the http client
    this.http = builder.build();

    // Create the url endpoint
    StringBuffer sbEndpoint = new StringBuffer();
    sbEndpoint.append("http://").append(host).append(":").append(port).append("/db/data/transaction");
    this.transactionUrl = sbEndpoint.toString();

    // Setting autocommit
    this.setAutoCommit(Boolean.valueOf(properties.getProperty("autoCommit", "true")));
}

From source file:com.ephesoft.dcma.filebound.FileBoundExporter.java

/**
 * This method is used to fetch the field name according to the lookup.
 * @param fieldName {@link String}/*ww  w  .j  av  a2s . c om*/
 * @return {@link String}
 */
public String getFieldNameFromLookup(final String fieldName) {
    String returnValue = null;
    final String filePath = FileBoundConstants.META_INF + File.separator
            + FileBoundConstants.FIELD_LOOKUP_PROPERTY_FILE;
    InputStream propertyInStream = null;
    try {
        propertyInStream = new ClassPathResource(filePath).getInputStream();
        final Properties properties = new Properties();
        properties.load(propertyInStream);
        returnValue = (String) properties.get(fieldName);
        if (returnValue != null) {
            returnValue = returnValue.trim();
        }
    } catch (Exception e) {
        LOGGER.error("Problem occured while fetching field name for Filebound");
    } finally {
        if (propertyInStream != null) {
            try {
                propertyInStream.close();
            } catch (IOException e) {
                LOGGER.error("Problem in closing stream");
            }
        }
    }
    return returnValue;
}

From source file:com.impetus.client.hbase.schemamanager.HBaseSchemaManager.java

/**
 * Sets the external properties./* w  ww . ja  v a 2  s . co m*/
 * 
 * @param name
 *            the name
 * @param hColumnDescriptor
 *            the h column descriptor
 */
private void setExternalProperties(String name, HColumnDescriptor hColumnDescriptor) {
    Properties properties = externalProperties != null ? externalProperties.get(name) : null;
    if (properties != null && !properties.isEmpty()) {
        for (Object obj : properties.keySet()) {
            hColumnDescriptor.setValue(Bytes.toBytes(obj.toString()),
                    Bytes.toBytes(properties.get(obj).toString()));
        }
    }
}

From source file:org.xmlactions.action.config.ExecContext.java

private Map<String, Object> convertPropertiesToMap(Properties props) {
    Map<String, Object> map = new HashMap<String, Object>();
    for (Object key : props.keySet()) {
        map.put((String) key, props.get(key));
    }/*from w  w  w .ja  va 2 s  . c  o m*/
    return map;
}

From source file:com.zotoh.maedr.device.JettyIO.java

@SuppressWarnings("unchecked")
protected CmdLineSequence getCmdSeq(ResourceBundle rcb, Properties props) throws Exception {
    props.put("filters", new ArrayList<Map<String, Object>>());
    props.put("urlpatterns", new ArrayList<String>());
    CmdLineQuestion q7 = new CmdLineMandatory("fcz", getResourceStr(rcb, "cmd.http.fcz")) {
        protected String onAnswerSetOutput(String answer, Properties props) {
            List<Map<String, Object>> a = (List<Map<String, Object>>) props.get("filters");
            Map<String, Object> m = MP();
            String uri = nsb(props.remove("f_uri"));
            m.put("urlpattern", uri);
            m.put("class", answer);
            m.put("params", new HashMap<String, String>());
            a.add(m);/*from   w ww .j  av a  2  s .c o  m*/
            return "fpath";
        }
    };
    CmdLineQuestion q6 = new CmdLineMandatory("fpath", getResourceStr(rcb, "cmd.http.fpath")) {
        protected String onAnswerSetOutput(String answer, Properties props) {
            if (isEmpty(answer)) {
                props.remove("f_uri");
                return "";
            }
            props.put("f_uri", answer);
            return "fcz";
        }
    };
    CmdLineQuestion q5 = new CmdLineQuestion("filters", getResourceStr(rcb, "cmd.http.filters"), "y/n", "n") {
        protected String onAnswerSetOutput(String answer, Properties props) {
            return "Yy".indexOf(answer) >= 0 ? "fpath" : "";
        }
    };
    CmdLineQuestion q4 = new CmdLineMandatory("spath", getResourceStr(rcb, "cmd.http.spath")) {
        protected String onAnswerSetOutput(String answer, Properties props) {
            if (isEmpty(answer))
                return "filters";
            List<String> lst = (List<String>) props.get("urlpatterns");
            lst.add(answer);
            return "spath";
        }
    };
    CmdLineQuestion q2 = new CmdLineQuestion("base", getResourceStr(rcb, "cmd.http.resbase"), "", ".") {
        protected String onAnswerSetOutput(String answer, Properties props) {
            props.put("resbase", answer);
            return "spath";
        }
    };
    final CmdLineQuestion q1 = new CmdLineQuestion("ctx", getResourceStr(rcb, "cmd.http.ctx")) {
        protected String onAnswerSetOutput(String answer, Properties props) {
            props.put("contextpath", answer);
            return "base";
        }
    };
    return new CmdLineSequence(super.getCmdSeq(rcb, props), q1, q2, q4, q5, q6, q7) {
        protected String onStart() {
            return q1.getId();
        }
    };
}