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:com.artnaseef.jmeter.report.HitsPerSecondReport.java

protected void extractReportProperties(Properties prop) {
    this.detailOutputFile = prop.getProperty(ReportLauncher.PROPERTY_DETAIL_FILE_NAME);

    String out = prop.getProperty(ReportLauncher.PROPERTY_OUTPUT_FILENAME);
    if (out != null) {
        this.outputFile = out;
    }//w w w .ja  v  a2s  . c om

    Integer size;
    size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_HEIGHT);
    if (size != null) {
        this.reportHeight = size;
    }
    size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_WIDTH);
    if (size != null) {
        this.reportWidth = size;
    }
}

From source file:org.syncope.core.init.ContentLoader.java

@Transactional
public void load() {
    // 0. DB connection, to be used below
    Connection conn = DataSourceUtils.getConnection(dataSource);

    // 1. Check wether we are allowed to load default content into the DB
    Statement statement = null;//from w w  w . ja  va2  s .c  o m
    ResultSet resultSet = null;
    boolean existingData = false;
    try {
        statement = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);

        resultSet = statement.executeQuery("SELECT * FROM " + SyncopeConf.class.getSimpleName());
        resultSet.last();

        existingData = resultSet.getRow() > 0;
    } catch (SQLException e) {
        LOG.error("Could not access to table " + SyncopeConf.class.getSimpleName(), e);

        // Setting this to true make nothing to be done below
        existingData = true;
    } finally {
        try {
            if (resultSet != null) {
                resultSet.close();
            }
        } catch (SQLException e) {
            LOG.error("While closing SQL result set", e);
        }
        try {
            if (statement != null) {
                statement.close();
            }
        } catch (SQLException e) {
            LOG.error("While closing SQL statement", e);
        }
    }

    if (existingData) {
        LOG.info("Data found in the database, leaving untouched");
        return;
    }

    LOG.info("Empty database found, loading default content");

    // 2. Create views
    LOG.debug("Creating views");
    try {
        InputStream viewsStream = getClass().getResourceAsStream("/views.xml");
        Properties views = new Properties();
        views.loadFromXML(viewsStream);

        for (String idx : views.stringPropertyNames()) {
            LOG.debug("Creating view {}", views.get(idx).toString());

            try {
                statement = conn.createStatement();
                statement.executeUpdate(views.get(idx).toString().replaceAll("\\n", " "));
                statement.close();
            } catch (SQLException e) {
                LOG.error("Could not create view ", e);
            }
        }

        LOG.debug("Views created, go for indexes");
    } catch (Throwable t) {
        LOG.error("While creating views", t);
    }

    // 3. Create indexes
    LOG.debug("Creating indexes");
    try {
        InputStream indexesStream = getClass().getResourceAsStream("/indexes.xml");
        Properties indexes = new Properties();
        indexes.loadFromXML(indexesStream);

        for (String idx : indexes.stringPropertyNames()) {
            LOG.debug("Creating index {}", indexes.get(idx).toString());

            try {
                statement = conn.createStatement();
                statement.executeUpdate(indexes.get(idx).toString());
                statement.close();
            } catch (SQLException e) {
                LOG.error("Could not create index ", e);
            }
        }

        LOG.debug("Indexes created, go for default content");
    } catch (Throwable t) {
        LOG.error("While creating indexes", t);
    } finally {
        DataSourceUtils.releaseConnection(conn, dataSource);
    }

    try {
        conn.close();
    } catch (SQLException e) {
        LOG.error("While closing SQL connection", e);
    }

    // 4. Load default content
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
        SAXParser parser = factory.newSAXParser();
        parser.parse(getClass().getResourceAsStream("/content.xml"), importExport);
        LOG.debug("Default content successfully loaded");
    } catch (Throwable t) {
        LOG.error("While loading default content", t);
    }
}

From source file:com.moviejukebox.tools.GitRepositoryState.java

/**
 * Git Repository State//w w w  .  j  a v  a 2  s  .  c  om
 *
 */
public GitRepositoryState() {
    Properties properties = new Properties();
    try {
        properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));

        this.branch = properties.get("git.branch").toString();
        this.dirty = asBoolean(properties.get("git.dirty").toString());
        this.tags = asList(properties.get("git.tags").toString());
        this.describe = properties.get("git.commit.id.describe").toString();
        this.describeShort = properties.get("git.commit.id.describe-short").toString();
        this.commitId = properties.get("git.commit.id").toString();
        this.commitIdAbbrev = properties.get("git.commit.id.abbrev").toString();
        this.buildUserName = properties.get("git.build.user.name").toString();
        this.buildUserEmail = properties.get("git.build.user.email").toString();
        this.buildTime = properties.get("git.build.time").toString();
        this.commitUserName = properties.get("git.commit.user.name").toString();
        this.commitUserEmail = properties.get("git.commit.user.email").toString();
        this.commitMessageShort = properties.get("git.commit.message.short").toString();
        this.commitMessageFull = properties.get("git.commit.message.full").toString();
        this.commitTime = properties.get("git.commit.time").toString();
    } catch (IOException ex) {
        LOG.warn("Failed to get build properties from git.properties file", ex);
    }
}

From source file:io.syndesis.maven.ExtractConnectorDescriptorsMojo.java

private ObjectNode getComponentMeta(ClassLoader classLoader) {
    Properties properties = loadComponentProperties(classLoader);
    if (properties == null) {
        return null;
    }//from   w  ww. jav  a  2s .  com
    String components = (String) properties.get("components");
    if (components == null) {
        return null;
    }
    String[] part = components.split("\\s");
    ObjectNode componentMeta = new ObjectNode(JsonNodeFactory.instance);
    for (String scheme : part) {
        // find the class name
        String javaType = extractComponentJavaType(classLoader, scheme);
        if (javaType == null) {
            continue;
        }
        String schemeMeta = loadComponentJSonSchema(classLoader, scheme, javaType);
        if (schemeMeta == null) {
            continue;
        }
        componentMeta.set(scheme, new TextNode(schemeMeta));
    }
    return componentMeta.size() > 0 ? componentMeta : null;
}

From source file:com.all.launcher.LauncherConfig.java

public String applicationComand() throws IOException, LauncherConfigException {
    Properties properties = new Properties();
    properties.load(getPropertiesAsInputStream());

    String applicationCommand = null;

    if (Environment.isMac()) {
        applicationCommand = properties.get(EXEC_MAC_KEY).toString();
    } else if (Environment.isWindows()) {
        applicationCommand = properties.get(EXEC_WINDOWS_KEY).toString();
    } else if (Environment.isLinux()) {
        applicationCommand = properties.get(LINUX_WINDOWS_KEY).toString();
    }/*w  w w . j av  a2 s . c  o m*/

    LOG.info("Launcher prepared with executable for the application in: " + applicationCommand);

    return applicationCommand;
}

From source file:de.tudarmstadt.ukp.dkpro.core.rftagger.RfTagger.java

@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    runtimeProvider = new RuntimeProvider("classpath:/de/tudarmstadt/ukp/dkpro/core/rftagger/bin/");

    modelProvider = new ModelProviderBase<File>(this, "rftagger", "morph") {
        @Override//from  w w w.j  a v a  2  s. com
        protected File produceResource(URL aUrl) throws IOException {
            Properties metadata = getResourceMetaData();
            encodingLoadedFromModel = (String) metadata.get("model.encoding");

            SingletonTagset morphFeats = new SingletonTagset(MorphologicalFeatures.class,
                    metadata.getProperty("morph.tagset"));

            SingletonTagset posTags = new SingletonTagset(POS.class, metadata.getProperty("pos.tagset"));

            try (LittleEndianDataInputStream is = new LittleEndianDataInputStream(aUrl.openStream())) {
                long n = is.readLong(); // alphabet size
                for (int i = 0; i < n; i++) {
                    String symbol = readZeroTerminatedString(is, getEncoding());
                    if ("BOUNDARY".equals(symbol)) {
                        // Appears to be an internally used symbol
                        continue;
                    }
                    morphFeats.add(symbol);
                    posTags.add(extractTag(symbol));
                }
            }
            addTagset(posTags);
            addTagset(morphFeats);

            if (printTagSet) {
                getLogger().info(getTagset().toString());
            }

            // FIXME Actually, this is the place where the rftagger process should be
            // started/stopped so that if the language changes during processing, the
            // rftagger is reloaded with the required model.
            // It might not be easy to fix this - but then at least a bug should be
            // opened.
            return ResourceUtils.getUrlAsFile(aUrl, true);
        }

        private String readZeroTerminatedString(DataInput aIn, String aEncoding) throws IOException {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte b = aIn.readByte();
            while (b != 0) {
                bos.write(b);
                b = aIn.readByte();
            }
            return new String(bos.toByteArray(), aEncoding);
        }
    };

    mappingProvider = MappingProviderFactory.createPosMappingProvider(posMappingLocation, language,
            modelProvider);

    featuresParser = new MorphologicalFeaturesParser(this, modelProvider);
}

From source file:configuration.properties.loader.AuthClientPropertiesLoader.java

public synchronized void loadPreferences() {
    FileInputStream is = null;//  w w  w .jav a2 s  .  c  o m
    try {
        File preferencesFile = new File(this.filename);
        //         if (preferencesFile.exists()) {
        is = new FileInputStream(preferencesFile);
        Properties p = new Properties();
        p.load(is);

        this.authClientProperties = new HashMap<String, String>();

        if (p.get("authServerUrl") != null) {
            this.authClientProperties.put("authServerUrl", p.get("authServerUrl").toString());
        }

        if (p.get("otpServerUrl") != null) {
            this.authClientProperties.put("otpServerUrl", p.get("otpServerUrl").toString());
        }

        if (p.get("auaCode") != null) {
            this.authClientProperties.put("auaCode", p.get("auaCode").toString());
        }
        if (p.get("signKeyStore") != null) {
            this.authClientProperties.put("signKeyStore", p.get("signKeyStore").toString());
        }

        if (p.get("sa") != null) {
            this.authClientProperties.put("sa", p.get("sa").toString());
        }

        if (p.get("licenseKey") != null) {
            this.authClientProperties.put("licenseKey", p.get("licenseKey").toString());
        }

        if (p.get("asaLicenseKey") != null) {
            this.authClientProperties.put("asaLicenseKey", p.get("asaLicenseKey").toString());
        }

        if (p.get("terminalId") != null) {
            this.authClientProperties.put("terminalId", p.get("terminalId").toString());
        }

        if (p.get("publicKeyFile") != null) {
            this.authClientProperties.put("publicKeyFile", p.get("publicKeyFile").toString());
        }

        if (p.get("publicKeyFileDSIG") != null && !StringUtils.isEmpty(p.get("publicKeyFileDSIG").toString())) {
            this.authClientProperties.put("publicKeyFileDSIG", p.get("publicKeyFileDSIG").toString());
        } else {
            this.authClientProperties.put("publicKeyFile", p.get("publicKeyFile").toString());
        }

        if (p.get("usesPi") != null) {
            this.authClientProperties.put("usesPi", p.get("usesPi").toString());
        }

        if (p.get("usesPa") != null) {
            this.authClientProperties.put("usesPa", p.get("usesPa").toString());
        }

        if (p.get("usesPfa") != null) {
            this.authClientProperties.put("usesPfa", p.get("usesPfa").toString());
        }

        if (p.get("usesPin") != null) {
            this.authClientProperties.put("usesPin", p.get("usesPin").toString());
        }

        if (p.get("usesOtp") != null) {
            this.authClientProperties.put("usesOtp", p.get("usesOtp").toString());
        }

        if (p.get("usesBio") != null) {
            this.authClientProperties.put("usesBio", p.get("usesBio").toString());
        }

        if (p.get("usesBioFMR") != null) {
            this.authClientProperties.put("usesBioFMR", p.get("usesBioFMR").toString());
        }

        if (p.get("usesBioFIR") != null) {
            this.authClientProperties.put("usesBioFIR", p.get("usesBioFIR").toString());
        }

        if (p.get("usesBioIIR") != null) {
            this.authClientProperties.put("usesBioIIR", p.get("usesBioIIR").toString());
        }

        if (p.get("signatureAlias") != null) {
            this.authClientProperties.put("signatureAlias", p.get("signatureAlias").toString());
        }

        if (p.get("signaturePassword") != null) {
            this.authClientProperties.put("signaturePassword", p.get("signaturePassword").toString());
        }

        if (p.get("udc") != null) {
            this.authClientProperties.put("udc", p.get("udc").toString());
        }

        if (p.get("fdc") != null) {
            this.authClientProperties.put("fdc", p.get("fdc").toString());
        }

        if (p.get("idc") != null) {
            this.authClientProperties.put("idc", p.get("idc").toString());
        }

        if (p.get("pincode") != null) {
            this.authClientProperties.put("pincode", p.get("pincode").toString());
        }

        if (p.get("lot") != null) {
            this.authClientProperties.put("lot", p.get("lot").toString());
        }

        if (p.get("lov") != null) {
            this.authClientProperties.put("lov", p.get("lov").toString());
        }

        if (p.get("publicIP") != null) {
            this.authClientProperties.put("publicIP", p.get("publicIP").toString());
        }

        if (p.get("useSSK") != null) {
            this.authClientProperties.put("useSSK", p.get("useSSK").toString());
        }

        if (p.get("pidType") != null) {
            this.authClientProperties.put("pidType", p.get("pidType").toString());
        }

        if (p.get("bfdServerUrl") != null) {
            this.authClientProperties.put("bfdServerUrl", p.get("bfdServerUrl").toString());
        }

        //         }

    } catch (IOException ex) {
        System.out.println(
                "Failed to load authclient.properties file. Check if the file exists. Place the file in same directory as the jar.");
        //         ex.printStackTrace();
        System.exit(0);
    } finally {
        try {
            if (is != null) {
                is.close();
            }
        } catch (IOException ex) {
            System.out.println(
                    "Failed to load authclient.properties file. Check if the file exists. Place the file in same directory as the jar.");
            //            ex.printStackTrace();
            System.exit(0);
        }
    }
}

From source file:com.omertron.slackbot.utils.GitRepositoryState.java

/**
 * Git Repository State/*from w  w w .ja va2 s  .  c o  m*/
 *
 */
public GitRepositoryState() {
    Properties properties = new Properties();
    try {
        properties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));

        this.branch = properties.get("git.branch").toString();
        this.dirty = asBoolean(properties.get("git.dirty").toString());
        this.tags = asList(properties.get("git.tags").toString());
        this.describe = properties.get("git.commit.id.describe").toString();
        this.describeShort = properties.get("git.commit.id.describe-short").toString();
        this.commitId = properties.get("git.commit.id").toString();
        this.commitIdAbbrev = properties.get("git.commit.id.abbrev").toString();
        this.buildUserName = properties.get("git.build.user.name").toString();
        this.buildUserEmail = properties.get("git.build.user.email").toString();
        this.buildTime = properties.get("git.build.time").toString();
        this.commitUserName = properties.get("git.commit.user.name").toString();
        this.commitUserEmail = properties.get("git.commit.user.email").toString();
        this.commitMessageShort = properties.get("git.commit.message.short").toString();
        this.commitMessageFull = properties.get("git.commit.message.full").toString();
        this.commitTime = properties.get("git.commit.time").toString();
        this.buildVersion = properties.getProperty("git.build.version");

    } catch (IOException ex) {
        LOG.warn("Failed to get build properties from git.properties file", ex);
    }
}

From source file:org.openinfobutton.responder.service.impl.ResponderServiceImpl.java

/**
 *
 * @return//from  www .ja v a  2 s  .  co m
 */
@Override
@Transactional
public Set<String> getRxNormQueryExpansionTermTypes() {

    if (rxNormQueryExpansionTermTypes != null) {
        return rxNormQueryExpansionTermTypes;
    }

    rxNormQueryExpansionTermTypes = new HashSet<>();

    Properties valueSetIds = getApplicationProperties("app.valueset.id");
    String rxNormQueryExpansionValueSetId = (String) valueSetIds.get("RXNORM_QUERY_EXPANSION_TERM_TYPE_CODES");
    List<ValueSetCode> valueSet = responderValueSetDao
            .getValueSetCodes(new BigDecimal(rxNormQueryExpansionValueSetId));

    for (ValueSetCode termType : valueSet) {
        rxNormQueryExpansionTermTypes.add(termType.getCode());
    }

    return rxNormQueryExpansionTermTypes;

}

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

@SuppressWarnings("unchecked")
protected CmdLineSequence getCmdSeq(ResourceBundle rcb, Properties props) throws Exception {
    props.put("urls", new ArrayList<String>());
    final CmdLineQuestion q1 = new CmdLineMandatory("url", getResourceStr(rcb, "cmd.feed.url")) {
        protected String onAnswerSetOutput(String answer, Properties props) {
            List<String> c = (List<String>) props.get("urls");
            if (isEmpty(answer)) {
                return "";
            }/*from  w  ww.j  av  a2 s  .  com*/
            c.add(answer);
            return getId();
        }
    };
    return new CmdLineSequence(super.getCmdSeq(rcb, props), q1) {
        protected String onStart() {
            return q1.getId();
        }
    };

}