Example usage for java.util Properties Properties

List of usage examples for java.util Properties Properties

Introduction

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

Prototype

public Properties() 

Source Link

Document

Creates an empty property list with no default values.

Usage

From source file:com.mirth.connect.model.converters.tests.HL7SerializerTest.java

@Before
public void setUp() throws Exception {
    defaultProperties = new Properties();
    defaultProperties.put("useStrictParser", "false");
    defaultProperties.put("handleRepetitions", "false");
    defaultProperties.put("handleSubcomponents", "false");
    defaultProperties.put("convertLFtoCR", "false");
}

From source file:com.swcguild.dummy.CaptchaTag.java

@Override
public void doTag() throws JspException, IOException {
    ReCaptcha captcha = ReCaptchaFactory.newReCaptcha(publickey, privatekey, false);
    Properties properties = new Properties();

    if (StringUtils.isNotEmpty(themeName)) {
        properties.put("theme", themeName);
    }/*from  ww w  .  ja v a  2  s  .  c o m*/

    String captchaHtml = captcha.createRecaptchaHtml(null, properties);
    getJspContext().getOut().write(captchaHtml);
}

From source file:carmen.utils.CommandLineUtilities.java

/**
 * This uses the apache Jakarta CLI to parse the command line.
 * A single static instance of this class exists for global access by all parts 
 * of the program./*  ww w.java  2 s .c  om*/
 * To use this class, a list of options must be specified and passed to this method.
 * Manditory arguments should be encoded as strings.
 * @param args The command line received by main
 * @param manditory_args A list of strings that contain the names of manditory arguments.
 * @param specified_options A list of options to use for this program.
 */
public static void initCommandLineParameters(String[] args, List<Option> specified_options,
        String[] manditory_args) {
    Options options = new Options();
    if (specified_options != null)
        for (Option option : specified_options)
            options.addOption(option);

    Option option = null;

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("A file containing command line parameters as a Java properties file.");
    option = OptionBuilder.create("parameter_file");

    options.addOption(option);

    CommandLineParser command_line_parser = new GnuParser();
    CommandLineUtilities._properties = new Properties();
    try {
        CommandLineUtilities._command_line = command_line_parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println("***ERROR: " + e.getClass() + ": " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("parameters:", options);
        System.exit(0);
    }
    if (CommandLineUtilities.hasArg("parameter_file")) {
        String parameter_file = CommandLineUtilities.getOptionValue("parameter_file");
        // Read the property file.
        try {
            _properties.load(new FileInputStream(parameter_file));
        } catch (IOException e) {
            System.err.println("Problem reading parameter file: " + parameter_file);
        }
    }

    boolean failed = false;
    if (manditory_args != null) {
        for (String arg : manditory_args) {
            if (!CommandLineUtilities.hasArg(arg)) {
                failed = true;
                System.out.println("Missing argument: " + arg);
            }
        }
        if (failed) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("parameters:", options);
            System.exit(0);
        }

    }
}

From source file:fedora.utilities.Log4J.java

/**
 * Initializes Log4J from a properties file.
 * //from w  w w .j  av a2  s  . co  m
 * @param propFile the Log4J properties file.
 * @param options a set of name-value pairs to use while expanding any
 *                replacement variables (e.g. ${some.name}) in the 
 *                properties file.  These may also be specified in
 *                the properties file itself.  If found, the value
 *                in the properties file will take precendence.
 * @throws IOException if configuration fails due to problems with the file.
 */
public static void initFromPropFile(File propFile, Map<String, String> options) throws IOException {
    Properties props = new Properties();
    props.load(new FileInputStream(propFile));
    if (options != null) {
        for (String name : options.keySet()) {
            String value = options.get(name);
            if (!props.containsKey(name)) {
                props.setProperty(name, value);
            }
        }
    }
    PropertyConfigurator.configure(props);
}

From source file:io.fabric8.profiles.ProfilesHelpers.java

public static Properties readPropertiesFile(Path path) throws IOException {
    Properties properties = new Properties();
    try (InputStream is = Files.newInputStream(path)) {
        properties.load(is);//from   w w w .  j a  v a  2s .  c  om
    }
    return properties;
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.db.TopicDaoImplTest.java

@BeforeClass
public static void setupDatabase() throws Exception {
    InputStream inputStream = DeviceDAOImplTest.class.getResourceAsStream("/test.properties");

    Properties testProperties = new Properties();
    testProperties.load(inputStream);/*  w  ww  .j av  a 2 s.  c om*/

    String host = testProperties.getProperty("db.host");
    String port = testProperties.getProperty("db.port");
    String user = testProperties.getProperty("db.user");
    String password = testProperties.getProperty("db.password");
    String driver = testProperties.getProperty("db.driver");
    String schema = testProperties.getProperty("db.schema");

    String url = "jdbc:mysql://" + host + ":" + port + "/" + schema;

    ds = new BasicDataSource();
    ds.setDriverClassName(driver);
    ds.setUsername(user);
    ds.setPassword(password);
    ds.setUrl(url);

    DBTestUtil.setBasicDataSource(ds);
}

From source file:gov.nih.nci.cagrid.caarray.stubs.cql.CaArrayCQLQueryProcessor.java

private static synchronized CaArraySearchService getSearchService() {
    try {/*from  w  ww  .j  a  v  a 2  s.co m*/
        final Properties jndiProp = new Properties();
        jndiProp.load(CaArraySvcImpl.class.getResourceAsStream("/gov/nih/nci/cagrid/caarray/jndi.properties"));

        if (jndiProp.getProperty("java.naming.factory.initial") == null
                || jndiProp.getProperty("java.naming.factory.url.pkgs") == null
                || jndiProp.getProperty("java.naming.provider.url") == null) {
            throw new IllegalArgumentException(
                    "Unable to find all required properties in jndi.properties file.");
        }

        final Context context = new InitialContext(jndiProp);
        searchService = (CaArraySearchService) context.lookup(CaArraySearchService.JNDI_NAME);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
    return searchService;
}

From source file:com.lang.pat.kafkairc.Consumer.java

private static ConsumerConfig createConsumerConfig() {
    Properties props = new Properties();
    props.put("zookeeper.connect", ClientMain.HOSTNAME + ":" + ClientMain.PORT);
    props.put("group.id", ClientMain.USERNAME);
    props.put("zookeeper.session.timeout.ms", "400");
    props.put("zookeeper.sync.time.ms", "200");
    props.put("auto.commit.interval.ms", "1000");

    return new ConsumerConfig(props);
}

From source file:com.espertech.esperio.db.SupportDatabaseService.java

public static ConfigurationDBRef makeDBConfig() {
    ConfigurationDBRef configDB = new ConfigurationDBRef();
    configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL,
            new Properties());
    return configDB;
}

From source file:com.sap.prd.mobile.ios.mios.FatBinaryTest.java

@BeforeClass
public static void __setup() throws Exception {
    final String testName = "fatLibPreparation";

    final Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, masterRemoteRepoDir.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion);

    if (masterRemoteRepoDir.exists())
        com.sap.prd.mobile.ios.mios.FileUtils.deleteDirectory(masterRemoteRepoDir);

    test(testName, new File(getTestRootDirectory(), "straight-forward/MyLibrary"), "deploy", THE_EMPTY_LIST,
            THE_EMPTY_MAP, pomReplacements, new NullProjectModifier());
}