public void init() { HttpConnectionParams httpParams = new HttpConnectionParams(); httpParams.setConnectionTimeout(httpConnectionTimeout); /* 连接超时 */ httpParams.setSoTimeout(socketTimeout); Protocol myhttps = new Protocol("https", new MySSLSocketFactory(), 443); Protocol.registerProtocol("https", myhttps); connManager = new MultiThreadedHttpConnectionManager(); connManager.setMaxTotalConnections(maxTotalConnections); connManager.setMaxConnectionsPerHost(40); }
{ String useMultiThreadedConnectionMgr = LPS.getProperty("http.useConnectionPool", "true"); if (Boolean.valueOf(useMultiThreadedConnectionMgr).booleanValue()) { mLogger.info( /* (non-Javadoc) * @i18n.test * @org-mes="using connection pool" */ org.openlaszlo.i18n.LaszloMessages.getMessage( HTTPDataSource.class.getName(), "051018-81")); mConnectionMgr = new MultiThreadedHttpConnectionManager(); } else { mLogger.info( /* (non-Javadoc) * @i18n.test * @org-mes="not using connection pool" */ org.openlaszlo.i18n.LaszloMessages.getMessage( HTTPDataSource.class.getName(), "051018-91")); } // Parse multi connection properties anyway. May be used by AXIS. See // ResponderCache for details. { String maxConns = LPS.getProperty("http.maxConns", "1000"); mMaxTotalConnections = Integer.parseInt(maxConns); if (mConnectionMgr != null) { mConnectionMgr.setMaxTotalConnections(mMaxTotalConnections); } maxConns = LPS.getProperty("http.maxConnsPerHost", maxConns); mMaxConnectionsPerHost = Integer.parseInt(maxConns); if (mConnectionMgr != null) { mConnectionMgr.setMaxConnectionsPerHost(mMaxConnectionsPerHost); } } String maxRetries = LPS.getProperty("http.maxBackendRetries", "1"); mMaxRetries = Integer.parseInt(maxRetries); String followRedirects = LPS.getProperty("http.followRedirects", "0"); mFollowRedirects = Integer.parseInt(followRedirects); String timeout = LPS.getProperty("http.backendTimeout", "30000"); mTimeout = Integer.parseInt(timeout); timeout = LPS.getProperty("http.backendConnectionTimeout", timeout); mConnectionTimeout = Integer.parseInt(timeout); timeout = LPS.getProperty("http.connectionPoolTimeout", "0"); mConnectionPoolTimeout = Integer.parseInt(timeout); String useHttp11 = LPS.getProperty("http.useHttp11", "true"); mUseHttp11 = Boolean.valueOf(useHttp11).booleanValue(); if (mUseHttp11) { mLogger.info("using HTTP 1.1"); } else { mLogger.info("not using HTTP 1.1"); } }