本文整理汇总了Java中org.apache.http.conn.OperatedClientConnection类的典型用法代码示例。如果您正苦于以下问题:Java OperatedClientConnection类的具体用法?Java OperatedClientConnection怎么用?Java OperatedClientConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperatedClientConnection类属于org.apache.http.conn包,在下文中一共展示了OperatedClientConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSecureConnection
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
@Override
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
Args.notNull(conn, "Connection");
Args.notNull(target, "Target host");
Args.notNull(params, "Parameters");
Asserts.check(conn.isOpen(), "Connection must be open");
final SchemeRegistry registry = getSchemeRegistry(context);
final Scheme schm = registry.getScheme(target.getSchemeName());
Asserts.check(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory,
"Socket factory must implement SchemeLayeredSocketFactory");
final SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
final Socket sock = lsf.createLayeredSocket(
conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), params);
prepareSocket(sock, context, params);
conn.update(sock, target, lsf.isSecure(sock), params);
}
示例2: getConnection
import org.apache.http.conn.OperatedClientConnection; //导入依赖的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;
}
}
示例3: abortConnection
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
@Override
public void abortConnection() {
synchronized (this) {
if (this.poolEntry == null) {
return;
}
this.reusable = false;
final OperatedClientConnection conn = this.poolEntry.getConnection();
try {
conn.shutdown();
} catch (final IOException ignore) {
}
this.manager.releaseConnection(this, this.duration, TimeUnit.MILLISECONDS);
this.poolEntry = null;
}
}
示例4: updateSecureConnection
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
if (conn == null) {
throw new IllegalArgumentException("Connection may not be null");
}
if (target == null) {
throw new IllegalArgumentException("Target host may not be null");
}
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
if (!conn.isOpen()) {
throw new IllegalStateException("Connection must be open");
}
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
if (!(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory)) {
throw new IllegalArgumentException
("Target scheme (" + schm.getName() +
") must have layered socket factory.");
}
SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
Socket sock;
try {
sock = lsf.createLayeredSocket(
conn.getSocket(), target.getHostName(), target.getPort(), params);
} catch (ConnectException ex) {
throw new HttpHostConnectException(target, ex);
}
prepareSocket(sock, context, params);
conn.update(sock, target, lsf.isSecure(sock), params);
}
示例5: AbstractClientConnAdapter
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
/**
* Creates a new connection adapter.
* The adapter is initially <i>not</i>
* {@link #isMarkedReusable marked} as reusable.
*
* @param mgr the connection manager, or <code>null</code>
* @param conn the connection to wrap, or <code>null</code>
*/
protected AbstractClientConnAdapter(ClientConnectionManager mgr,
OperatedClientConnection conn) {
super();
connManager = mgr;
wrappedConnection = conn;
markedReusable = false;
released = false;
duration = Long.MAX_VALUE;
}
示例6: assertValid
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
/**
* Asserts that there is a valid wrapped connection to delegate to.
*
* @throws ConnectionShutdownException if there is no wrapped connection
* or connection has been aborted
*/
protected final void assertValid(
final OperatedClientConnection wrappedConn) throws ConnectionShutdownException {
if (isReleased() || wrappedConn == null) {
throw new ConnectionShutdownException();
}
}
示例7: isOpen
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public boolean isOpen() {
OperatedClientConnection conn = getWrappedConnection();
if (conn == null)
return false;
return conn.isOpen();
}
示例8: isStale
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public boolean isStale() {
if (isReleased())
return true;
OperatedClientConnection conn = getWrappedConnection();
if (conn == null)
return true;
return conn.isStale();
}
示例9: receiveResponseEntity
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public void receiveResponseEntity(HttpResponse response)
throws HttpException, IOException {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
unmarkReusable();
conn.receiveResponseEntity(response);
}
示例10: receiveResponseHeader
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public HttpResponse receiveResponseHeader()
throws HttpException, IOException {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
unmarkReusable();
return conn.receiveResponseHeader();
}
示例11: sendRequestEntity
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public void sendRequestEntity(HttpEntityEnclosingRequest request)
throws HttpException, IOException {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
unmarkReusable();
conn.sendRequestEntity(request);
}
示例12: sendRequestHeader
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public void sendRequestHeader(HttpRequest request)
throws HttpException, IOException {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
unmarkReusable();
conn.sendRequestHeader(request);
}
示例13: getSSLSession
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public SSLSession getSSLSession() {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
if (!isOpen())
return null;
SSLSession result = null;
Socket sock = conn.getSocket();
if (sock instanceof SSLSocket) {
result = ((SSLSocket)sock).getSession();
}
return result;
}
示例14: getAttribute
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public Object getAttribute(final String id) {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
if (conn instanceof HttpContext) {
return ((HttpContext) conn).getAttribute(id);
} else {
return null;
}
}
示例15: removeAttribute
import org.apache.http.conn.OperatedClientConnection; //导入依赖的package包/类
public Object removeAttribute(final String id) {
OperatedClientConnection conn = getWrappedConnection();
assertValid(conn);
if (conn instanceof HttpContext) {
return ((HttpContext) conn).removeAttribute(id);
} else {
return null;
}
}