Example usage for java.lang Integer getInteger

List of usage examples for java.lang Integer getInteger

Introduction

In this page you can find the example usage for java.lang Integer getInteger.

Prototype

public static Integer getInteger(String nm, Integer val) 

Source Link

Document

Returns the integer value of the system property with the specified name.

Usage

From source file:com.xlson.standalonewar.Starter.java

private static Integer getInteger(String propertyName, Integer defaultValue) {
    return Integer.getInteger(propertyName, config.getInteger(propertyName, defaultValue));
}

From source file:org.hyperic.lather.client.LatherHTTPClient.java

public LatherHTTPClient(String baseURL, int timeoutConn, int timeoutData,
        final boolean acceptUnverifiedCertificates) {
    try {/*from   w  ww  .  jav a 2  s.  c o  m*/
        // get proxy info
        String proxyHostname = System.getProperty("lather.proxyHost", null);
        int proxyPort = Integer.getInteger("lather.proxyPort", new Integer(-1)).intValue();

        // setup http client config
        HttpConfig config = new HttpConfig();

        config.setConnectionTimeout(timeoutConn);
        config.setSocketTimeout(timeoutData);
        config.setProxyHostname(proxyHostname);
        config.setProxyPort(proxyPort);

        this.client = new HQHttpClient(new AgentKeystoreConfig(), config, acceptUnverifiedCertificates);
        this.baseURL = baseURL;
        this.xCoder = new LatherXCoder();
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.adeptj.runtime.core.Launcher.java

private static void pauseForDebug() throws InterruptedException {
    // Useful for debugging the server startup in development mode.
    if (Environment.isDev()) {
        Integer waitTime = Integer.getInteger("wait.time.for.debug.attach", 10);
        LoggerFactory.getLogger(Launcher.class).info("Waiting [{}] seconds for debugger to attach!", waitTime);
        TimeUnit.SECONDS.sleep(waitTime);
    }// w  w  w  .j a  va  2s  .  c o  m
}

From source file:org.apache.cassandra.utils.JMXServerUtils.java

/**
 * Creates a server programmatically. This allows us to set parameters which normally are
 * inaccessable./*from  w  w  w .j  a v a  2 s  .  c  om*/
 */
public static JMXConnectorServer createJMXServer(int port, boolean local) throws IOException {
    Map<String, Object> env = new HashMap<>();

    String urlTemplate = "service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi";
    InetAddress serverAddress = null;
    if (local) {
        serverAddress = InetAddress.getLoopbackAddress();
        System.setProperty("java.rmi.server.hostname", serverAddress.getHostAddress());
    }

    // Configure the RMI client & server socket factories, including SSL config.
    env.putAll(configureJmxSocketFactories(serverAddress, local));

    // Configure authn, using a JMXAuthenticator which either wraps a set log LoginModules configured
    // via a JAAS configuration entry, or one which delegates to the standard file based authenticator.
    // Authn is disabled if com.sun.management.jmxremote.authenticate=false
    env.putAll(configureJmxAuthentication());

    // Configure authz - if a custom proxy class is specified an instance will be returned.
    // If not, but a location for the standard access file is set in system properties, the
    // return value is null, and an entry is added to the env map detailing that location
    // If neither method is specified, no access control is applied
    MBeanServerForwarder authzProxy = configureJmxAuthorization(env);

    // Make sure we use our custom exporter so a full GC doesn't get scheduled every
    // sun.rmi.dgc.server.gcInterval millis (default is 3600000ms/1 hour)
    env.put(RMIExporter.EXPORTER_ATTRIBUTE, new Exporter());

    String url = String.format(urlTemplate,
            (serverAddress != null ? serverAddress.getHostAddress() : "0.0.0.0"), port);

    int rmiPort = Integer.getInteger("com.sun.management.jmxremote.rmi.port", 0);
    JMXConnectorServer jmxServer = JMXConnectorServerFactory.newJMXConnectorServer(
            new JMXServiceURL("rmi", null, rmiPort), env, ManagementFactory.getPlatformMBeanServer());

    // If a custom authz proxy was created, attach it to the server now.
    if (authzProxy != null)
        jmxServer.setMBeanServerForwarder(authzProxy);

    jmxServer.start();

    // use a custom Registry to avoid having to interact with it internally using the remoting interface
    configureRMIRegistry(port, env);

    logger.info("Configured JMX server at: {}", url);
    return jmxServer;
}

From source file:org.jboss.test.web.test.ssl.SSLUnitTestCase.java

/**
 * Test masking of Keystore password via encryption
 * @throws Exception//w  w  w  .  j  a v  a  2s. c  o  m
 */
public void testEncryptPassword() throws Exception {
    log.info("+++ testHttps");
    int port = Integer.getInteger("secureweb.port", 8443).intValue();
    port += 1500;
    String httpsNoAuth = "https://" + getServerHost() + ":" + port + "/";
    doHttps(httpsNoAuth);
}

From source file:org.jboss.test.web.security.GenericHeaderAuthUnitTestCase.java

protected void setUp() throws Exception {
    super.setUp();
    this.testAppBaseURL = "http://" + super.getServerHost() + ":" + Integer.getInteger("web.port", 8080)
            + "/generic-header-auth/";
}

From source file:gridool.util.system.SystemUtils.java

public static boolean is64BitVM() {
    try {// www  .  j  a  va 2  s . co m
        int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
        if (bits != 0) {
            return bits == 64;
        }
        return System.getProperty("java.vm.name").indexOf("64") >= 0;
    } catch (Throwable t) {
        return false;
    }
}

From source file:org.apache.camel.management.DefaultManagementAgent.java

protected void finalizeSettings() {
    if (registryPort == null) {
        registryPort = Integer.getInteger(JmxSystemPropertyKeys.REGISTRY_PORT, DEFAULT_REGISTRY_PORT);
    }/*from  w  w w. ja va 2 s .  c  om*/

    if (connectorPort == null) {
        connectorPort = Integer.getInteger(JmxSystemPropertyKeys.CONNECTOR_PORT, DEFAULT_CONNECTION_PORT);
    }

    if (mBeanServerDefaultDomain == null) {
        mBeanServerDefaultDomain = System.getProperty(JmxSystemPropertyKeys.DOMAIN, DEFAULT_DOMAIN);
    }

    if (mBeanObjectDomainName == null) {
        mBeanObjectDomainName = System.getProperty(JmxSystemPropertyKeys.MBEAN_DOMAIN, DEFAULT_DOMAIN);
    }

    if (serviceUrlPath == null) {
        serviceUrlPath = System.getProperty(JmxSystemPropertyKeys.SERVICE_URL_PATH, DEFAULT_SERVICE_URL_PATH);
    }

    if (createConnector == null) {
        createConnector = Boolean.getBoolean(JmxSystemPropertyKeys.CREATE_CONNECTOR);
    }

    // "Use platform mbean server" is true by default
    if (System.getProperty(JmxSystemPropertyKeys.USE_PLATFORM_MBS) != null) {
        usePlatformMBeanServer = Boolean.getBoolean(JmxSystemPropertyKeys.USE_PLATFORM_MBS);
    }

    if (onlyRegisterProcessorWithCustomId == null) {
        onlyRegisterProcessorWithCustomId = Boolean
                .getBoolean(JmxSystemPropertyKeys.ONLY_REGISTER_PROCESSOR_WITH_CUSTOM_ID);
    }
}

From source file:org.jahia.services.notification.HttpClientService.java

private static String initHttpClient(HttpClient client, String protocol) {
    String host = System.getProperty(protocol + ".proxyHost");
    int port = Integer.getInteger(protocol + ".proxyPort", -1).intValue();
    port = port != -1 ? port : Protocol.getProtocol(protocol).getDefaultPort();

    client.getHostConfiguration().setProxy(host, port);

    String key = host + ':' + port;

    Credentials credentials = null;/*from  w ww . j  av  a  2s  .c  o  m*/
    String user = System.getProperty(protocol + ".proxyUser");
    if (StringUtils.isNotEmpty(user)) {
        credentials = new UsernamePasswordCredentials(user, System.getProperty(protocol + ".proxyPassword"));
        client.getState().setProxyCredentials(AuthScope.ANY, credentials);
    }

    logger.info("Initialized HttpClient for {} protocol using proxy {} {} credentials",
            new String[] { protocol.toUpperCase(), key, credentials != null ? "with" : "without" });

    return key;
}

From source file:org.jboss.test.security.test.CustomPrincipalPropagationUnitTestCase.java

/**
 * A web-app has a welcome jsp (called as index.jsp). Inside this jsp,
 * there is a call made out to an ejb/*from  ww w.j  a  v  a2 s. c  o  m*/
 * 
 * @throws Exception
 */
public void testCustomPrincipalTransmissionInVM() throws Exception {
    String baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/";
    HttpClient httpConn = new HttpClient();
    GetMethod indexGet = new GetMethod(baseURLNoAuth + "custom-principal/");
    int responseCode = httpConn.executeMethod(indexGet);
    String body = indexGet.getResponseBodyAsString();
    assertTrue("Get OK(" + responseCode + ")", responseCode == HttpURLConnection.HTTP_OK);
    assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0);
    HttpState state = httpConn.getState();
    Cookie[] cookies = state.getCookies();
    String sessionID = null;
    for (int c = 0; c < cookies.length; c++) {
        Cookie k = cookies[c];
        if (k.getName().equalsIgnoreCase("JSESSIONID"))
            sessionID = k.getValue();
    }
    getLog().debug("Saw JSESSIONID=" + sessionID);
    // Submit the login form
    PostMethod formPost = new PostMethod(baseURLNoAuth + "custom-principal/j_security_check");
    formPost.addRequestHeader("Referer", baseURLNoAuth + "custom-principal/login.jsp");
    formPost.addParameter("j_username", this.username);
    formPost.addParameter("j_password", new String(password));
    responseCode = httpConn.executeMethod(formPost.getHostConfiguration(), formPost, state);
    String loginResult = formPost.getResponseBodyAsString();
    if (loginResult.indexOf("Encountered a login error") > 0)
        fail("Login Failed");

    String response = formPost.getStatusText();
    log.debug("responseCode=" + responseCode + ", response=" + response);
    assertTrue("Saw HTTP_MOVED_TEMP", responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

    //  Follow the redirect to the index.jsp
    Header location = formPost.getResponseHeader("Location");
    String indexURI = location.getValue();
    GetMethod war1Index = new GetMethod(indexURI);
    responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(), war1Index, state);
    response = war1Index.getStatusText();
    log.debug("responseCode=" + responseCode + ", response=" + response);
    assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
    body = war1Index.getResponseBodyAsString();
    log.debug("Final result obtained:" + body);
    if (body.indexOf("j_security_check") > 0)
        fail("get of " + indexURI + " redirected to login page");
    if (body.indexOf("Propagation Success") < 0)
        fail("Propagation of custom principal within VM failed");
}