connManager = factory.newInstance(params, registry); } else { connManager = new SingleClientConnManager(getParams(), registry);
public ManagedClientConnection getConnection( long timeout, TimeUnit tunit) { return SingleClientConnManager.this.getConnection( route, state); }
throw new IllegalArgumentException("Route may not be null."); assertStillUp(); revokeConnection(); closeExpiredConnections();
public void closeIdleConnections(long idletime, TimeUnit tunit) { assertStillUp(); // idletime can be 0 or negative, no problem there if (tunit == null) { throw new IllegalArgumentException("Time unit must not be null."); } if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) { final long cutoff = System.currentTimeMillis() - tunit.toMillis(idletime); if (lastReleaseTime <= cutoff) { try { uniquePoolEntry.close(); } catch (IOException iox) { // ignore log.debug("Problem closing idle connection.", iox); } } } }
@Override protected void finalize() throws Throwable { shutdown(); super.finalize(); }
public void closeExpiredConnections() { if(System.currentTimeMillis() >= connectionExpiresTime) { closeIdleConnections(0, TimeUnit.MILLISECONDS); } }
/** * Creates a new simple connection manager. * * @param params the parameters for this manager * @param schreg the scheme registry */ public SingleClientConnManager(HttpParams params, SchemeRegistry schreg) { if (schreg == null) { throw new IllegalArgumentException ("Scheme registry must not be null."); } this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); this.uniquePoolEntry = new PoolEntry(); this.managedConn = null; this.lastReleaseTime = -1L; this.alwaysShutDown = false; //@@@ from params? as argument? this.isShutDown = false; } // <constructor>
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { assertStillUp();
@Override protected void finalize() throws Throwable { shutdown(); super.finalize(); }
public void closeExpiredConnections() { if(System.currentTimeMillis() >= connectionExpiresTime) { closeIdleConnections(0, TimeUnit.MILLISECONDS); } }
/** * Creates a new simple connection manager. * * @param params the parameters for this manager * @param schreg the scheme registry */ public SingleClientConnManager(HttpParams params, SchemeRegistry schreg) { if (schreg == null) { throw new IllegalArgumentException ("Scheme registry must not be null."); } this.schemeRegistry = schreg; this.connOperator = createConnectionOperator(schreg); this.uniquePoolEntry = new PoolEntry(); this.managedConn = null; this.lastReleaseTime = -1L; this.alwaysShutDown = false; //@@@ from params? as argument? this.isShutDown = false; } // <constructor>
public ClientConnectionManager getSCCM() { KeyStore trustStore; try { trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); SSLSocketFactory sf = new TrustAllSSLSocketFactory(trustStore); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sf, 443)); ClientConnectionManager ccm = new SingleClientConnManager(null, registry); return ccm; } catch (Exception e) { return null; } }
throw new IllegalArgumentException("Route may not be null."); assertStillUp(); revokeConnection(); closeExpiredConnections();
public void closeIdleConnections(long idletime, TimeUnit tunit) { assertStillUp(); // idletime can be 0 or negative, no problem there if (tunit == null) { throw new IllegalArgumentException("Time unit must not be null."); } if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) { final long cutoff = System.currentTimeMillis() - tunit.toMillis(idletime); if (lastReleaseTime <= cutoff) { try { uniquePoolEntry.close(); } catch (IOException iox) { // ignore log.debug("Problem closing idle connection.", iox); } } } }
public ManagedClientConnection getConnection( long timeout, TimeUnit tunit) { return SingleClientConnManager.this.getConnection( route, state); }
@Override protected void finalize() throws Throwable { shutdown(); super.finalize(); }
public void closeExpiredConnections() { final long time = connectionExpiresTime; if (System.currentTimeMillis() >= time) { closeIdleConnections(0, TimeUnit.MILLISECONDS); } }