Example usage for java.lang System getProperties

List of usage examples for java.lang System getProperties

Introduction

In this page you can find the example usage for java.lang System getProperties.

Prototype

public static Properties getProperties() 

Source Link

Document

Determines the current system properties.

Usage

From source file:com.omertron.thetvdbapi.tools.WebBrowser.java

/**
 * Open a connection using proxy parameters if they exist.
 *
 * @param url//from  ww  w . j  a v a2  s .c  o m
 * @throws IOException
 */
public static URLConnection openProxiedConnection(URL url) throws IOException {
    if (proxyHost != null) {
        System.getProperties().put("proxySet", "true");
        System.getProperties().put("proxyHost", proxyHost);
        System.getProperties().put("proxyPort", proxyPort);
    }

    URLConnection cnx = url.openConnection();

    if (proxyUsername != null) {
        cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
    }

    return cnx;
}

From source file:io.gatling.mojo.GatlingJavaMainCallerByFork.java

public GatlingJavaMainCallerByFork(AbstractMojo requester1, String mainClassName1, String classpath,
        String[] jvmArgs1, String[] args1, boolean forceUseArgFile, Toolchain toolchain,
        boolean propagateSystemProperties) throws Exception {
    super(requester1, mainClassName1, classpath, jvmArgs1, args1, forceUseArgFile, toolchain);

    if (propagateSystemProperties) {
        for (Entry<Object, Object> systemProp : System.getProperties().entrySet()) {
            String name = systemProp.getKey().toString();
            String value = systemProp.getValue().toString();
            if (isPropagatableProperty(name)) {
                addJvmArgs("-D" + name + "=" + StringUtils.escape(value));
            }/*from   ww w .j  a  v  a 2s . com*/
        }
    }
}

From source file:com.streamsets.datacollector.el.TestRuntimeEL.java

@AfterClass
public static void afterClass() throws IOException {
    System.getProperties().remove(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.CONFIG_DIR);
    System.getProperties().remove(RuntimeModule.SDC_PROPERTY_PREFIX + RuntimeInfo.RESOURCES_DIR);
}

From source file:org.camunda.connect.httpclient.HttpConnectorSystemPropertiesTest.java

@After
public void clearCustomSystemProperties() {
    for (String property : updatedSystemProperties) {
        System.getProperties().remove(property);
    }
}

From source file:com.asakusafw.bulkloader.testutil.UnitTestUtil.java

public static void tearDownEnv() throws Exception {
    Properties p = System.getProperties();
    p.remove(Constants.ASAKUSA_HOME);/*from  w w  w.j a v  a  2 s  . com*/
    p.remove(Constants.THUNDER_GATE_HOME);
    ConfigurationLoader.setSysProp(p);
    System.setProperties(p);
}

From source file:com.clothcat.sysutils.info.Arch.java

public static void arch(String[] args) {
    // parse commandline
    Options options = new Options();
    options.addOption("h", "help", false, "display help output and exit");
    options.addOption("v", "version", false, "output version information and exit");

    CommandLineParser parser = new GnuParser();
    try {//  w  ww .ja  va2s . c  o  m
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Arch [options]", options);
            return;
        }
        if (cmd.hasOption("version")) {
            System.out.println(version);
            return;
        }
    } catch (ParseException ex) {
        Logger.getLogger(Arch.class.getName()).log(Level.SEVERE, null, ex);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Arch [options]", options);
    }
    System.out.println(System.getProperties().getProperty("os.arch"));
}

From source file:PropertiesHelper.java

/**
 * Adds new properties to an existing set of properties while
 * substituting variables. This function will allow value
 * substitutions based on other property values. Value substitutions
 * may not be nested. A value substitution will be ${property.key},
 * where the dollar-brace and close-brace are being stripped before
 * looking up the value to replace it with. Note that the ${..}
 * combination must be escaped from the shell.
 *
 * @param b is the set of properties to add to existing properties.
 * @return the combined set of properties.
 *///from w w  w  . j  a va 2  s.c  o m
protected Properties addProperties(Properties b) {
    // initial
    // Properties result = new Properties(this);
    Properties sys = System.getProperties();
    Pattern pattern = Pattern.compile("\\$\\{[-a-zA-Z0-9._]+\\}");

    for (Enumeration e = b.propertyNames(); e.hasMoreElements();) {
        String key = (String) e.nextElement();
        String value = b.getProperty(key);

        // unparse value ${prop.key} inside braces
        Matcher matcher = pattern.matcher(value);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            // extract name of properties from braces
            String newKey = value.substring(matcher.start() + 2, matcher.end() - 1);

            // try to find a matching value in result properties
            String newVal = getProperty(newKey);

            // if still not found, try system properties
            if (newVal == null) {
                newVal = sys.getProperty(newKey);
            }

            // replace braced string with the actual value or empty string
            matcher.appendReplacement(sb, newVal == null ? "" : newVal);
        }
        matcher.appendTail(sb);
        setProperty(key, sb.toString());
    }
    return this;
}

From source file:io.symcpe.hendrix.api.dao.TestTenantManager.java

@BeforeClass
public static void beforeClass() throws Exception {
    Properties config = new Properties(System.getProperties());
    File db = new File(TARGET_RULES_DB);
    if (db.exists()) {
        FileUtils.deleteDirectory(db);//  w ww.j a v  a  2 s  .co  m
    }
    config.setProperty("javax.persistence.jdbc.url", CONNECTION_STRING);
    try {
        emf = Persistence.createEntityManagerFactory("hendrix", config);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:org.obrienlabs.gps.integration.SwaggerConfig.java

private boolean hasDocDev() {
    Properties systemProperties = System.getProperties();
    return systemProperties.containsKey(ENV_DOC_DEV)
            && systemProperties.getProperty(ENV_DOC_DEV).equals("true");
}

From source file:de.unigoettingen.sub.commons.util.stream.StreamUtils.java

/************************************************************************************
 * get MimeType as {@link String} from given URL including proxy details
 * /*from   www.  j  a va2  s  .  c o  m*/
 * @param url the url from where to get the MimeType
 * @param httpproxyhost host of proxy
 * @param httpproxyport port of proxy
 * @param httpproxyusername username for proxy
 * @param httpproxypassword password for proxy
 * @return MimeType as {@link String}
 * @throws IOException
 ************************************************************************************/

public static String getMimeTypeFromUrl(URL url, String httpproxyhost, String httpproxyport,
        String httpproxyusername, String httpproxypassword) throws IOException {
    if (httpproxyhost != null) {
        Properties properties = System.getProperties();
        properties.put("http.proxyHost", httpproxyhost);
        if (httpproxyport != null) {
            properties.put("http.proxyPort", httpproxyport);
        } else {
            properties.put("http.proxyPort", "80");
        }
    }
    URLConnection con = url.openConnection();
    if (httpproxyusername != null) {
        String login = httpproxyusername + ":" + httpproxypassword;
        String encodedLogin = new String(Base64.encodeBase64(login.getBytes()));
        con.setRequestProperty("Proxy-Authorization", "Basic " + encodedLogin);
    }
    return con.getContentType();
}