本文整理汇总了Java中org.apache.http.nio.client.HttpAsyncClient类的典型用法代码示例。如果您正苦于以下问题:Java HttpAsyncClient类的具体用法?Java HttpAsyncClient怎么用?Java HttpAsyncClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpAsyncClient类属于org.apache.http.nio.client包,在下文中一共展示了HttpAsyncClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAsyncRequest
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
HttpAsyncClient asyncClient = getHttpAsyncClient();
startAsyncClient();
HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
postProcessHttpRequest(httpRequest);
HttpContext context = createHttpContext(httpMethod, uri);
if (context == null) {
context = HttpClientContext.create();
}
// Request configuration not set in the context
if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
// Use request configuration given by the user, when available
RequestConfig config = null;
if (httpRequest instanceof Configurable) {
config = ((Configurable) httpRequest).getConfig();
}
if (config == null) {
config = createRequestConfig(asyncClient);
}
if (config != null) {
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
}
}
return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:HttpComponentsAsyncClientHttpRequestFactory.java
示例2: AbstractRemoteOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
protected AbstractRemoteOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull OD operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset,
final int okStatusCode) {
this.host = host;
this.httpClient = httpClient;
this.resourceName = resourceName;
this.operationDeclaration = operationDeclaration;
this.serverProtocol = serverProtocol;
this.charset = charset;
this.okStatusCode = okStatusCode;
}
示例3: RemoteCustomOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteCustomOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull CustomOperationDeclaration operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset) {
super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
示例4: RemoteReadOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteReadOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull ReadOperationDeclaration operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset) {
super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
示例5: RemoteUpdateOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteUpdateOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull UpdateOperationDeclaration operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset) {
super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
示例6: RemoteDeleteOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteDeleteOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull DeleteOperationDeclaration operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset) {
super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.OK);
}
示例7: RemoteCreateOperationInvocation
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public RemoteCreateOperationInvocation(
final @NotNull HttpHost host,
final @NotNull HttpAsyncClient httpClient,
final @NotNull String resourceName,
final @NotNull CreateOperationDeclaration operationDeclaration,
final @NotNull ServerProtocol serverProtocol,
final @NotNull Charset charset) {
super(host, httpClient, resourceName, operationDeclaration, serverProtocol, charset, HttpStatusCode.CREATED);
}
示例8: run
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public void run() {
// To change body of implemented methods use File | Settings | File Templates.if (log.isDebugEnabled())
log.debug("URI=[{}] 의 웹 컨텐츠를 비동기 방식으로 다운로드 받아 캐시합니다.", url);
try {
String responseStr;
HttpAsyncClient httpClient = new DefaultHttpAsyncClient();
httpClient.start();
HttpGet request = new HttpGet(url);
Future<HttpResponse> future = httpClient.execute(request, null);
HttpResponse response = future.get();
responseStr = EntityUtils.toString(response.getEntity(), Charsets.UTF_8.toString());
httpClient.shutdown();
if (log.isDebugEnabled())
log.debug("URI=[{}]로부터 웹 컨텐츠를 다운로드 받았습니다. responseStr=[{}]",
url, StringTool.ellipsisChar(responseStr, 255));
ctx.getResponse().setCharacterEncoding("UTF-8");
PrintWriter writer = ctx.getResponse().getWriter();
writer.write(responseStr);
writer.close();
ctx.complete();
} catch (Exception ignored) {
throw new RuntimeException(ignored);
}
}
示例9: HttpComponentsAsyncClientHttpRequest
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
HttpComponentsAsyncClientHttpRequest(HttpAsyncClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
this.httpClient = httpClient;
this.httpRequest = httpRequest;
this.httpContext = httpContext;
}
示例10: createAsyncRequest
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
@Override
public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) throws IOException {
HttpAsyncClient asyncClient = getHttpAsyncClient();
startAsyncClient();
HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
postProcessHttpRequest(httpRequest);
HttpContext context = createHttpContext(httpMethod, uri);
if (context == null) {
context = HttpClientContext.create();
}
// Request configuration not set in the context
if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
// Use request configuration given by the user, when available
RequestConfig config = null;
if (httpRequest instanceof Configurable) {
config = ((Configurable) httpRequest).getConfig();
}
if (config == null) {
config = RequestConfig.DEFAULT;
}
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
}
return new HttpComponentsAsyncClientHttpRequest(asyncClient, httpRequest, context);
}
示例11: getProxyClientAsync
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
protected HttpAsyncClient getProxyClientAsync() {
return httpClient;
}
示例12: DefaultClient
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public DefaultClient(HttpAsyncClient client, ClientConfig config) {
this.client = client;
this.config = config;
}
示例13: getClient
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public HttpAsyncClient getClient() {
return client;
}
示例14: http
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public HttpAsyncClient http() {
return clnt;
}
示例15: AbstractClient
import org.apache.http.nio.client.HttpAsyncClient; //导入依赖的package包/类
public AbstractClient(String baseUri, HttpAsyncClient httpClient) throws URISyntaxException {
this(new URI(baseUri), httpClient);
}