本文整理汇总了Java中org.apache.http.conn.ManagedClientConnection类的典型用法代码示例。如果您正苦于以下问题:Java ManagedClientConnection类的具体用法?Java ManagedClientConnection怎么用?Java ManagedClientConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManagedClientConnection类属于org.apache.http.conn包,在下文中一共展示了ManagedClientConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: abortConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
/**
* Shuts down the connection.
* This method is called from a <code>catch</code> block in
* {@link #execute execute} during exception handling.
*/
private void abortConnection() {
ManagedClientConnection mcc = managedConn;
if (mcc != null) {
// we got here as the result of an exception
// no response will be returned, release the connection
managedConn = null;
try {
mcc.abortConnection();
} catch (IOException ex) {
if (this.log.isDebugEnabled()) {
this.log.debug(ex.getMessage(), ex);
}
}
// ensure the connection manager properly releases this connection
try {
mcc.releaseConnection();
} catch(IOException ignored) {
this.log.debug("Error releasing connection", ignored);
}
}
}
示例2: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public final ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
public void abortRequest() {
// Nothing to abort, since requests are immediate.
}
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit) {
return BasicClientConnectionManager.this.getConnection(
route, state);
}
};
}
示例3: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public final ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
public void abortRequest() {
// Nothing to abort, since requests are immediate.
}
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
};
}
示例4: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
if (route == null) {
throw new IllegalArgumentException("HTTP route may not be null");
}
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<HttpPoolEntry> future = this.pool.lease(route, state);
return new ClientConnectionRequest() {
public void abortRequest() {
future.cancel(true);
}
public ManagedClientConnection getConnection(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例5: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
@Override
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<HttpPoolEntry> future = this.pool.lease(route, state);
return new ClientConnectionRequest() {
@Override
public void abortRequest() {
future.cancel(true);
}
@Override
public ManagedClientConnection getConnection(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例6: abortConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
/**
* Shuts down the connection.
* This method is called from a {@code catch} block in
* {@link #execute execute} during exception handling.
*/
private void abortConnection() {
final ManagedClientConnection mcc = managedConn;
if (mcc != null) {
// we got here as the result of an exception
// no response will be returned, release the connection
managedConn = null;
try {
mcc.abortConnection();
} catch (final IOException ex) {
if (this.log.isDebugEnabled()) {
this.log.debug(ex.getMessage(), ex);
}
}
// ensure the connection manager properly releases this connection
try {
mcc.releaseConnection();
} catch(final IOException ignored) {
this.log.debug("Error releasing connection", ignored);
}
}
}
示例7: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
@Override
public final ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
@Override
public void abortRequest() {
// Nothing to abort, since requests are immediate.
}
@Override
public ManagedClientConnection getConnection(
final long timeout, final TimeUnit tunit) {
return BasicClientConnectionManager.this.getConnection(
route, state);
}
};
}
示例8: getConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
Args.notNull(route, "Route");
synchronized (this) {
assertNotShutdown();
if (this.log.isDebugEnabled()) {
this.log.debug("Get connection for route " + route);
}
Asserts.check(this.conn == null, MISUSE_MESSAGE);
if (this.poolEntry != null && !this.poolEntry.getPlannedRoute().equals(route)) {
this.poolEntry.close();
this.poolEntry = null;
}
if (this.poolEntry == null) {
final String id = Long.toString(COUNTER.getAndIncrement());
final OperatedClientConnection opconn = this.connOperator.createConnection();
this.poolEntry = new HttpPoolEntry(this.log, id, route, opconn, 0, TimeUnit.MILLISECONDS);
}
final long now = System.currentTimeMillis();
if (this.poolEntry.isExpired(now)) {
this.poolEntry.close();
this.poolEntry.getTracker().reset();
}
this.conn = new ManagedClientConnectionImpl(this, this.connOperator, this.poolEntry);
return this.conn;
}
}
示例9: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
@Override
public final ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
@Override
public void abortRequest() {
// Nothing to abort, since requests are immediate.
}
@Override
public ManagedClientConnection getConnection(
final long timeout, final TimeUnit tunit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
};
}
示例10: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public final ClientConnectionRequest requestConnection(final HttpRoute paramHttpRoute, Object paramObject)
{
new ClientConnectionRequest()
{
public final void abortRequest()
{
this.val$poolRequest.abortRequest();
}
public final ManagedClientConnection getConnection(long paramAnonymousLong, TimeUnit paramAnonymousTimeUnit)
throws InterruptedException, ConnectionPoolTimeoutException
{
if (paramHttpRoute == null) {
throw new IllegalArgumentException("Route may not be null.");
}
BasicPoolEntry localBasicPoolEntry = this.val$poolRequest.getPoolEntry(paramAnonymousLong, paramAnonymousTimeUnit);
return new ElegantThreadSafeConnManager.ElegantBasicPooledConnAdapter(ElegantThreadSafeConnManager.this, localBasicPoolEntry);
}
};
}
示例11: releaseConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public final void releaseConnection(ManagedClientConnection paramManagedClientConnection, long paramLong, TimeUnit paramTimeUnit)
{
HttpConnectionMetrics localHttpConnectionMetrics = paramManagedClientConnection.getMetrics();
if (localHttpConnectionMetrics != null)
{
long l1 = localHttpConnectionMetrics.getReceivedBytesCount();
ArrayList localArrayList1 = (ArrayList)jsm.b.get();
int i = localArrayList1.size();
if (i > 0)
{
jso localjso2 = (jso)localArrayList1.get(i - 1);
localjso2.d = (l1 + localjso2.d);
}
long l2 = localHttpConnectionMetrics.getSentBytesCount();
ArrayList localArrayList2 = (ArrayList)jsm.b.get();
int j = localArrayList2.size();
if (j > 0)
{
jso localjso1 = (jso)localArrayList2.get(j - 1);
localjso1.e = (l2 + localjso1.e);
}
}
super.releaseConnection(paramManagedClientConnection, paramLong, paramTimeUnit);
}
示例12: abortConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
/**
* Shuts down the connection.
* This method is called from a <code>catch</code> block in
* {@link #execute execute} during exception handling.
*/
private void abortConnection() {
ManagedClientConnection mcc = managedConn;
if (mcc != null) {
// we got here as the result of an exception
// no response will be returned, release the connection
managedConn = null;
try {
mcc.abortConnection();
} catch (IOException ex) {
if (this.log.isDebugEnabled()) {
this.log.debug(ex.getMessage(), ex);
}
}
// ensure the connection manager properly releases this connection
try {
mcc.releaseConnection();
} catch(IOException ignored) {
this.log.debug("Error releasing connection", ignored);
}
}
}
示例13: requestConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
public final ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
public void abortRequest() {
// Nothing to abort, since requests are immediate.
}
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
};
}
示例14: abortConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
/**
* Shuts down the connection.
* This method is called from a <code>catch</code> block in
* {@link #execute execute} during exception handling.
*/
private void abortConnection() {
ManagedClientConnection mcc = managedConn;
if (mcc != null) {
// we got here as the result of an exception
// no response will be returned, release the connection
managedConn = null;
try {
mcc.abortConnection();
} catch (IOException ex) {
if (DEBUG) {
Logger.debug(ex.getMessage(), ex);
}
}
// ensure the connection manager properly releases this connection
try {
mcc.releaseConnection();
} catch (IOException ignored) {
if (DEBUG) {
Logger.debug("Error releasing connection", ignored);
}
}
}
}
示例15: abortConnection
import org.apache.http.conn.ManagedClientConnection; //导入依赖的package包/类
/**
* Shuts down the connection.
* This method is called from a <code>catch</code> block in
* {@link #execute execute} during exception handling.
*/
private void abortConnection() {
ManagedClientConnection mcc = managedConn;
if (mcc != null) {
// we got here as the result of an exception
// no response will be returned, release the connection
managedConn = null;
try {
mcc.abortConnection();
} catch (IOException ex) {
if (Constants.DEBUG) {
logger.debug(ex.getMessage(), ex);
}
}
// ensure the connection manager properly releases this connection
try {
mcc.releaseConnection();
} catch (IOException ignored) {
if (Constants.DEBUG) {
logger.debug("Error releasing connection", ignored);
}
}
}
}