List of usage examples for java.lang Integer getInteger
public static Integer getInteger(String nm, Integer val)
From source file:org.browsermob.proxy.jetty.http.handler.ProxyHandler.java
protected HttpTunnel newHttpTunnel(HttpRequest request, HttpResponse response, InetAddress iaddr, int port, int timeoutMS) throws IOException { try {//from w w w.j a v a2 s . co m Socket socket = null; InputStream in = null; String chained_proxy_host = System.getProperty("http.proxyHost"); if (chained_proxy_host == null) { socket = new Socket(iaddr, port); socket.setSoTimeout(timeoutMS); socket.setTcpNoDelay(true); } else { int chained_proxy_port = Integer.getInteger("http.proxyPort", 8888).intValue(); Socket chain_socket = new Socket(chained_proxy_host, chained_proxy_port); chain_socket.setSoTimeout(timeoutMS); chain_socket.setTcpNoDelay(true); if (log.isDebugEnabled()) log.debug("chain proxy socket=" + chain_socket); LineInput line_in = new LineInput(chain_socket.getInputStream()); byte[] connect = request.toString() .getBytes(org.browsermob.proxy.jetty.util.StringUtil.__ISO_8859_1); chain_socket.getOutputStream().write(connect); String chain_response_line = line_in.readLine(); HttpFields chain_response = new HttpFields(); chain_response.read(line_in); // decode response int space0 = chain_response_line.indexOf(' '); if (space0 > 0 && space0 + 1 < chain_response_line.length()) { int space1 = chain_response_line.indexOf(' ', space0 + 1); if (space1 > space0) { int code = Integer.parseInt(chain_response_line.substring(space0 + 1, space1)); if (code >= 200 && code < 300) { socket = chain_socket; in = line_in; } else { Enumeration iter = chain_response.getFieldNames(); while (iter.hasMoreElements()) { String name = (String) iter.nextElement(); if (!_DontProxyHeaders.containsKey(name)) { Enumeration values = chain_response.getValues(name); while (values.hasMoreElements()) { String value = (String) values.nextElement(); response.setField(name, value); } } } response.sendError(code); if (!chain_socket.isClosed()) chain_socket.close(); } } } } if (socket == null) return null; HttpTunnel tunnel = new HttpTunnel(socket, in, null); return tunnel; } catch (IOException e) { log.debug(e); response.sendError(HttpResponse.__400_Bad_Request); return null; } }
From source file:net.lightbody.bmp.proxy.jetty.http.handler.ProxyHandler.java
protected HttpTunnel newHttpTunnel(HttpRequest request, HttpResponse response, InetAddress iaddr, int port, int timeoutMS) throws IOException { try {/*from ww w . j a va2s .c om*/ Socket socket = null; InputStream in = null; String chained_proxy_host = System.getProperty("http.proxyHost"); if (chained_proxy_host == null) { socket = new Socket(iaddr, port); socket.setSoTimeout(timeoutMS); socket.setTcpNoDelay(true); } else { int chained_proxy_port = Integer.getInteger("http.proxyPort", 8888).intValue(); Socket chain_socket = new Socket(chained_proxy_host, chained_proxy_port); chain_socket.setSoTimeout(timeoutMS); chain_socket.setTcpNoDelay(true); if (log.isDebugEnabled()) log.debug("chain proxy socket=" + chain_socket); LineInput line_in = new LineInput(chain_socket.getInputStream()); byte[] connect = request.toString() .getBytes(net.lightbody.bmp.proxy.jetty.util.StringUtil.__ISO_8859_1); chain_socket.getOutputStream().write(connect); String chain_response_line = line_in.readLine(); HttpFields chain_response = new HttpFields(); chain_response.read(line_in); // decode response int space0 = chain_response_line.indexOf(' '); if (space0 > 0 && space0 + 1 < chain_response_line.length()) { int space1 = chain_response_line.indexOf(' ', space0 + 1); if (space1 > space0) { int code = Integer.parseInt(chain_response_line.substring(space0 + 1, space1)); if (code >= 200 && code < 300) { socket = chain_socket; in = line_in; } else { Enumeration iter = chain_response.getFieldNames(); while (iter.hasMoreElements()) { String name = (String) iter.nextElement(); if (!_DontProxyHeaders.containsKey(name)) { Enumeration values = chain_response.getValues(name); while (values.hasMoreElements()) { String value = (String) values.nextElement(); response.setField(name, value); } } } response.sendError(code); if (!chain_socket.isClosed()) chain_socket.close(); } } } } if (socket == null) return null; HttpTunnel tunnel = new HttpTunnel(socket, in, null); return tunnel; } catch (IOException e) { log.debug(e); response.sendError(HttpResponse.__400_Bad_Request); return null; } }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
public void testBadEarRedeploy() throws Exception { try {//from w w w . ja v a2s .c o m deploy("jbosstest-bad.ear"); fail("The jbosstest-bad.ear deployment did not fail"); } catch (Exception e) { getLog().debug("jbosstest-bad.ear failed as expected", e); } finally { undeploy("jbosstest-bad.ear"); } // end of finally try { deploy("jbosstest-good.ear"); String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "redeploy/index.html"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK); } finally { undeploy("jbosstest-good.ear"); } // end of try-finally }
From source file:org.openqa.jetty.http.handler.ProxyHandler.java
protected HttpTunnel newHttpTunnel(HttpRequest request, HttpResponse response, InetAddress iaddr, int port, int timeoutMS) throws IOException { try {/*w ww.ja v a2s.c o m*/ Socket socket = null; InputStream in = null; String chained_proxy_host = System.getProperty("http.proxyHost"); if (chained_proxy_host == null) { socket = new Socket(iaddr, port); socket.setSoTimeout(timeoutMS); socket.setTcpNoDelay(true); } else { int chained_proxy_port = Integer.getInteger("http.proxyPort", 8888).intValue(); Socket chain_socket = new Socket(chained_proxy_host, chained_proxy_port); chain_socket.setSoTimeout(timeoutMS); chain_socket.setTcpNoDelay(true); if (log.isDebugEnabled()) log.debug("chain proxy socket=" + chain_socket); LineInput line_in = new LineInput(chain_socket.getInputStream()); byte[] connect = request.toString().getBytes(org.openqa.jetty.util.StringUtil.__ISO_8859_1); chain_socket.getOutputStream().write(connect); String chain_response_line = line_in.readLine(); HttpFields chain_response = new HttpFields(); chain_response.read(line_in); // decode response int space0 = chain_response_line.indexOf(' '); if (space0 > 0 && space0 + 1 < chain_response_line.length()) { int space1 = chain_response_line.indexOf(' ', space0 + 1); if (space1 > space0) { int code = Integer.parseInt(chain_response_line.substring(space0 + 1, space1)); if (code >= 200 && code < 300) { socket = chain_socket; in = line_in; } else { Enumeration iter = chain_response.getFieldNames(); while (iter.hasMoreElements()) { String name = (String) iter.nextElement(); if (!_DontProxyHeaders.containsKey(name)) { Enumeration values = chain_response.getValues(name); while (values.hasMoreElements()) { String value = (String) values.nextElement(); response.setField(name, value); } } } response.sendError(code); if (!chain_socket.isClosed()) chain_socket.close(); } } } } if (socket == null) return null; HttpTunnel tunnel = new HttpTunnel(socket, in, null); return tunnel; } catch (IOException e) { log.debug(e); response.sendError(HttpResponse.__400_Bad_Request); return null; } }
From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java
/** * Helper method to launch remote web driver. * * At times there are issues with starting the remote web driver. For firefox, * problems with locking port 7054 can arise. * * See the Selenium <a// www .j a v a 2 s .com * href="https://code.google.com/p/selenium/issues/detail?id=4790">bug</a> for * more info * * A special case needs to be performed for the Android browser, since it can not be cast to {@link RemoteWebDriver} * * @param capabilities web driver capabilities. * @return {@link WebDriver} instance of the remote web driver * */ protected WebDriver initRemoteWebDriver(DesiredCapabilities capabilities) { URL remoteUrl = getRemoteSeleniumUrl(); LOG.debug("Remote Selenium URL: {}", remoteUrl.toString()); WebDriver driver = null; boolean isAndroid = false; int tries = 1; if (capabilities.getCapability(CapabilityType.BROWSER_NAME).equals(ANDROID_BROWSER_NAME)) { isAndroid = true; } while (driver == null) { LOG.debug("Try {} {}", tries, capabilities.toString()); try { if (isAndroid) { driver = new AndroidDriver(remoteUrl, capabilities); } else { driver = new RemoteWebDriver(remoteUrl, capabilities); } } catch (WebDriverException e) { LOG.error("Remote WebDriver was unable to start! " + e.getMessage(), e); if (tries >= Integer.getInteger(REMOTE_WEBDRIVER_RETRY_ATTEMPTS, 10)) { throw e; } sleep(Integer.getInteger(REMOTE_WEBDRIVER_RETRY_PAUSE_MILLIS, 5000) * tries); tries++; driver = null; } } if (!isAndroid) { // allow screenshots to be taken driver = new Augmenter().augment(driver); } // Allow files from the host to be uploaded to a remote browser ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector()); return driver; }
From source file:com.googlecode.jsonrpc4j.JsonRpcHttpAsyncClient.java
private void initialize() { if (initialized.getAndSet(true)) { return;//from ww w .j ava2 s . c om } // HTTP parameters for the client final HttpParams params = new BasicHttpParams(); params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.getInteger("com.googlecode.jsonrpc4j.async.socket.timeout", 30000)); params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.getInteger("com.googlecode.jsonrpc4j.async.connect.timeout", 30000)); params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, Integer.getInteger("com.googlecode.jsonrpc4j.async.socket.buffer", 8 * 1024)); params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, Boolean.valueOf(System.getProperty("com.googlecode.jsonrpc4j.async.tcp.nodelay", "true"))); params.setParameter(CoreProtocolPNames.USER_AGENT, "jsonrpc4j/1.0"); // Create client-side I/O reactor final ConnectingIOReactor ioReactor; try { IOReactorConfig config = new IOReactorConfig(); config.setIoThreadCount(Integer.getInteger("com.googlecode.jsonrpc4j.async.reactor.threads", 1)); ioReactor = new DefaultConnectingIOReactor(config); } catch (IOReactorException e) { throw new RuntimeException("Exception initializing asynchronous Apache HTTP Client", e); } // Create a default SSLSetupHandler that accepts any certificate if (sslContext == null) { try { sslContext = SSLContext.getDefault(); } catch (Exception e) { throw new RuntimeException(e); } } // Create HTTP connection pool BasicNIOConnFactory nioConnFactory = new BasicNIOConnFactory(sslContext, null, params); pool = new BasicNIOConnPool(ioReactor, nioConnFactory, params); // Limit total number of connections to 500 by default pool.setDefaultMaxPerRoute(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.route", 500)); pool.setMaxTotal(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.total", 500)); // Run the I/O reactor in a separate thread Thread t = new Thread(new Runnable() { public void run() { try { // Create client-side HTTP protocol handler HttpAsyncRequestExecutor protocolHandler = new HttpAsyncRequestExecutor(); // Create client-side I/O event dispatch IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(protocolHandler, sslContext, params); // Ready to go! ioReactor.execute(ioEventDispatch); } catch (InterruptedIOException ex) { System.err.println("Interrupted"); } catch (IOException e) { System.err.println("I/O error: " + e.getMessage()); } } }, "jsonrpc4j HTTP IOReactor"); // Start the client thread t.setDaemon(true); t.start(); // Create HTTP protocol processing chain HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] { // Use standard client-side protocol interceptors new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue() }); // Create HTTP requester requester = new HttpAsyncRequester(httpproc, new DefaultConnectionReuseStrategy(), params); }
From source file:io.adeptj.runtime.server.Server.java
/** * Chaining of Undertow {@link HttpHandler} instances as follows. * <p>/*from w ww . j a v a 2s . co m*/ * 1. GracefulShutdownHandler * 2. RequestLimitingHandler * 3. AllowedMethodsHandler * 4. PredicateHandler which resolves to either RedirectHandler or SetHeadersHandler * 5. RequestBufferingHandler if request buffering is enabled, wrapped in SetHeadersHandler * 5. And Finally ServletInitialHandler * * @param servletInitialHandler the {@link io.undertow.servlet.handlers.ServletInitialHandler} * @return GracefulShutdownHandler as the root handler */ private GracefulShutdownHandler rootHandler(HttpHandler servletInitialHandler) { Config cfg = Objects.requireNonNull(this.cfgReference.get()); Map<HttpString, String> headers = new HashMap<>(); headers.put(HttpString.tryFromString(HEADER_SERVER), cfg.getString(KEY_HEADER_SERVER)); if (Environment.isDev()) { headers.put(HttpString.tryFromString(HEADER_X_POWERED_BY), Version.getFullVersionString()); } HttpHandler headersHandler = Boolean.getBoolean(SYS_PROP_ENABLE_REQ_BUFF) ? new SetHeadersHandler( new RequestBufferingHandler(servletInitialHandler, Integer.getInteger(SYS_PROP_REQ_BUFF_MAX_BUFFERS, cfg.getInt(KEY_REQ_BUFF_MAX_BUFFERS))), headers) : new SetHeadersHandler(servletInitialHandler, headers); return Handlers.gracefulShutdown(new RequestLimitingHandler( Integer.getInteger(SYS_PROP_MAX_CONCUR_REQ, cfg.getInt(KEY_MAX_CONCURRENT_REQS)), new AllowedMethodsHandler( Handlers.predicate(exchange -> CONTEXT_PATH.equals(exchange.getRequestURI()), Handlers.redirect(TOOLS_DASHBOARD_URI), headersHandler), this.allowedMethods(cfg)))); }
From source file:org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport.HTTPTransport.java
private Socket buildSocket(URL url) throws UnknownHostException, IOException { Socket s = null;/*from w ww . ja v a2 s . com*/ String host = url.getHost(); int port = url.getPort(); String proxyHost = System.getProperty(SYS_PROP_HTTP_PROXY_HOST); int proxyPort = Integer.getInteger(SYS_PROP_HTTP_PROXY_PORT, DEFAULT_HTTP_PORT).intValue(); String nonProxyHosts = System.getProperty(SYS_PROP_HTTP_NON_PROXY_HOSTS); // String proxyUserName = System.getProperty(SYS_PROP_HTTP_PROXY_USER_NAME); // String proxyPassword = System.getProperty(SYS_PROP_HTTP_PROXY_PASSWORD); if (url.getProtocol().equalsIgnoreCase(HTTPS)) { proxyHost = System.getProperty(SYS_PROP_HTTPS_PROXY_HOST); proxyPort = Integer.getInteger(SYS_PROP_HTTPS_PROXY_PORT, DEFAULT_HTTPS_PORT).intValue(); nonProxyHosts = System.getProperty(SYS_PROP_HTTPS_NON_PROXY_HOSTS); if (proxyHost != null && proxyHost.length() > 0 && !isHostInNonProxyHosts(host, nonProxyHosts, DEFAULT_CASE_SENSITIVE_FOR_HOST_NAME)) { // SSL with proxy server Socket tunnel = buildTunnelSocket(url, proxyHost, proxyPort); s = ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(tunnel, host, port, true); } else s = SSLSocketFactory.getDefault().createSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT)); // Removing dependency on soap.jar // s = SSLUtils.buildSSLSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT), proxyHost, proxyPort); // TODO: // Build an SSL socket that supports proxyUser and proxyPassword, // as demonstrated in the following (original) line of code: // s = SSLUtils.buildSSLSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT), proxyHost, proxyPort, proxyUserName, proxyPassword); } else if (proxyHost != null && proxyHost.length() > 0 && !isHostInNonProxyHosts(host, nonProxyHosts, DEFAULT_CASE_SENSITIVE_FOR_HOST_NAME)) s = new Socket(proxyHost, proxyPort); else s = new Socket(host, (port > 0 ? port : DEFAULT_HTTP_PORT)); return s; }
From source file:org.eclipse.packagedrone.repo.channel.web.channel.ChannelController.java
private Integer maxWebListSize() { return Integer.getInteger(DRONE_WEB_MAX_LIST_SIZE, DEFAULT_MAX_WEB_SIZE); }
From source file:com.adeptj.runtime.server.Server.java
private int sessionTimeout(Config cfg) { return Integer.getInteger(ServerConstants.SYS_PROP_SESSION_TIMEOUT, cfg.getInt(ServerConstants.KEY_SESSION_TIMEOUT)); }