本文整理汇总了Java中io.undertow.client.ClientCallback类的典型用法代码示例。如果您正苦于以下问题:Java ClientCallback类的具体用法?Java ClientCallback怎么用?Java ClientCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientCallback类属于io.undertow.client包,在下文中一共展示了ClientCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: connect
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
ChannelListener<StreamConnection> openListener = new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection connection) {
handleConnected(connection, listener, uri, ssl, bufferPool, options);
}
};
IoFuture.Notifier<StreamConnection, Object> notifier = new IoFuture.Notifier<StreamConnection, Object>() {
@Override
public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) {
if (ioFuture.getStatus() == IoFuture.Status.FAILED) {
listener.failed(ioFuture.getException());
}
}
};
if(bindAddress == null) {
worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null);
} else {
worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AjpClientProvider.java
示例2: connect
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
if (uri.getScheme().equals("https")) {
if (ssl == null) {
listener.failed(UndertowMessages.MESSAGES.sslWasNull());
return;
}
if (bindAddress == null) {
ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
} else {
ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
}
} else {
if (bindAddress == null) {
worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
} else {
worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HttpClientProvider.java
示例3: handleConnected
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private void handleConnected(final StreamConnection connection, final ClientCallback<ClientConnection> listener, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
if (options.get(UndertowOptions.ENABLE_SPDY, false) && connection instanceof SslConnection && SpdyClientProvider.isEnabled()) {
try {
SpdyClientProvider.handlePotentialSpdyConnection(connection, listener, bufferPool, options, new ChannelListener<SslConnection>() {
@Override
public void handleEvent(SslConnection channel) {
listener.completed(new HttpClientConnection(connection, options, bufferPool));
}
});
} catch (Exception e) {
listener.failed(new IOException(e));
}
} else {
listener.completed(new HttpClientConnection(connection, options, bufferPool));
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HttpClientProvider.java
示例4: sendRequest
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void sendRequest(final ClientRequest request, final ClientCallback<ClientExchange> clientCallback) {
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED | CLOSE_REQ | CLOSED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.invalidConnectionState());
return;
}
final AjpClientExchange AjpClientExchange = new AjpClientExchange(clientCallback, request, this);
if (currentRequest == null) {
initiateRequest(AjpClientExchange);
} else {
pendingQueue.add(AjpClientExchange);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AjpClientConnection.java
示例5: AjpClientExchange
import io.undertow.client.ClientCallback; //导入依赖的package包/类
public AjpClientExchange(ClientCallback<ClientExchange> readyCallback, ClientRequest request, AjpClientConnection clientConnection) {
this.readyCallback = readyCallback;
this.request = request;
this.clientConnection = clientConnection;
boolean reqContinue = false;
if (request.getRequestHeaders().contains(Headers.EXPECT)) {
for (String header : request.getRequestHeaders().get(Headers.EXPECT)) {
if (header.equals("100-continue")) {
reqContinue = true;
}
}
}
this.requiresContinue = reqContinue;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AjpClientExchange.java
示例6: setResponseListener
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void setResponseListener(ClientCallback<ClientExchange> listener) {
this.responseCallback = listener;
if (listener != null) {
if (failedReason != null) {
listener.failed(failedReason);
} else if (response != null) {
listener.completed(this);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AjpClientExchange.java
示例7: sendRequest
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void sendRequest(final ClientRequest request, final ClientCallback<ClientExchange> clientCallback) {
count++;
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED | CLOSE_REQ | CLOSED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.invalidConnectionState());
return;
}
final HttpClientExchange httpClientExchange = new HttpClientExchange(clientCallback, request, this);
if (currentRequest == null) {
initiateRequest(httpClientExchange);
} else {
pendingQueue.add(httpClientExchange);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:HttpClientConnection.java
示例8: HttpClientExchange
import io.undertow.client.ClientCallback; //导入依赖的package包/类
public HttpClientExchange(ClientCallback<ClientExchange> readyCallback, ClientRequest request, HttpClientConnection clientConnection) {
this.readyCallback = readyCallback;
this.request = request;
this.clientConnection = clientConnection;
boolean reqContinue = false;
if (request.getRequestHeaders().contains(Headers.EXPECT)) {
for (String header : request.getRequestHeaders().get(Headers.EXPECT)) {
if (header.equals("100-continue")) {
reqContinue = true;
}
}
}
this.requiresContinue = reqContinue;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:HttpClientExchange.java
示例9: createNotifier
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private IoFuture.Notifier<StreamConnection, Object> createNotifier(final ClientCallback<ClientConnection> listener) {
return new IoFuture.Notifier<StreamConnection, Object>() {
@Override
public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) {
if (ioFuture.getStatus() == IoFuture.Status.FAILED) {
listener.failed(ioFuture.getException());
}
}
};
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:HttpClientProvider.java
示例10: createOpenListener
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
return new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection connection) {
handleConnected(connection, listener, bufferPool, options);
}
};
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HttpClientProvider.java
示例11: setResponseListener
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void setResponseListener(ClientCallback<ClientExchange> responseListener) {
this.responseListener = responseListener;
if (responseListener != null) {
if (failedReason != null) {
responseListener.failed(failedReason);
} else if (clientResponse != null) {
responseListener.completed(this);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:SpdyClientExchange.java
示例12: connect
import io.undertow.client.ClientCallback; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
if(uri.getScheme().equals("spdy-plain")) {
if(bindAddress == null) {
worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
} else {
worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
}
return;
}
if(ALPN_PUT_METHOD == null) {
listener.failed(UndertowMessages.MESSAGES.jettyNPNNotAvailable());
return;
}
if (ssl == null) {
listener.failed(UndertowMessages.MESSAGES.sslWasNull());
return;
}
if(bindAddress == null) {
ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
} else {
ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SpdyClientProvider.java
示例13: createOpenListener
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private ChannelListener<StreamConnection> createOpenListener(final ClientCallback<ClientConnection> listener, final URI uri, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
return new ChannelListener<StreamConnection>() {
@Override
public void handleEvent(StreamConnection connection) {
handleConnected(connection, listener, uri, ssl, bufferPool, options);
}
};
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SpdyClientProvider.java
示例14: handleConnected
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private void handleConnected(StreamConnection connection, final ClientCallback<ClientConnection> listener, URI uri, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
if(connection instanceof SslConnection) {
handlePotentialSpdyConnection(connection, listener, bufferPool, options, new ChannelListener<SslConnection>() {
@Override
public void handleEvent(SslConnection channel) {
listener.failed(UndertowMessages.MESSAGES.spdyNotSupported());
}
});
} else {
listener.completed(createSpdyChannel(connection, bufferPool));
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SpdyClientProvider.java
示例15: openConnection
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private void openConnection(final HttpServerExchange exchange, final ProxyCallback<ProxyConnection> callback, final HostThreadData data, final boolean exclusive) {
if (!exclusive) {
data.connections++;
}
client.connect(new ClientCallback<ClientConnection>() {
@Override
public void completed(final ClientConnection result) {
final ConnectionHolder connectionHolder = new ConnectionHolder(result);
if (!exclusive) {
result.getCloseSetter().set(new ChannelListener<ClientConnection>() {
@Override
public void handleEvent(ClientConnection channel) {
handleClosedConnection(data, connectionHolder);
}
});
}
connectionReady(connectionHolder, callback, exchange, exclusive);
}
@Override
public void failed(IOException e) {
if (!exclusive) {
data.connections--;
}
UndertowLogger.REQUEST_LOGGER.debug("Failed to connect", e);
if (!connectionPoolManager.handleError()) {
redistributeQueued(getData());
scheduleFailedHostRetry(exchange);
}
callback.failed(exchange);
}
}, bindAddress, getUri(), exchange.getIoThread(), ssl, exchange.getConnection().getBufferPool(), options);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ProxyConnectionPool.java
示例16: executeReceiveRequest
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private void executeReceiveRequest(final TransportRequest transportRequest,
final URI url, final HttpHeaders headers, final XhrClientSockJsSession session,
final SettableListenableFuture<WebSocketSession> connectFuture) {
if (logger.isTraceEnabled()) {
logger.trace("Starting XHR receive request for " + url);
}
ClientCallback<ClientConnection> clientCallback = new ClientCallback<ClientConnection>() {
@Override
public void completed(ClientConnection connection) {
ClientRequest request = new ClientRequest().setMethod(Methods.POST).setPath(url.getPath());
HttpString headerName = HttpString.tryFromString(HttpHeaders.HOST);
request.getRequestHeaders().add(headerName, url.getHost());
addHttpHeaders(request, headers);
HttpHeaders httpHeaders = transportRequest.getHttpRequestHeaders();
connection.sendRequest(request, createReceiveCallback(transportRequest,
url, httpHeaders, session, connectFuture));
}
@Override
public void failed(IOException ex) {
throw new SockJsTransportFailureException("Failed to execute request to " + url, ex);
}
};
this.undertowBufferSupport.httpClientConnect(this.httpClient, clientCallback, url, worker, this.optionMap);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:UndertowXhrTransport.java
示例17: UndertowXnioBufferSupport
import io.undertow.client.ClientCallback; //导入依赖的package包/类
public UndertowXnioBufferSupport() {
this.xnioBufferPool = new org.xnio.ByteBufferSlicePool(1048, 1048);
this.httpClientConnectCallbackMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
ClientCallback.class, URI.class, XnioWorker.class, Pool.class, OptionMap.class);
this.httpClientConnectMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
URI.class, XnioWorker.class, Pool.class, OptionMap.class);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:UndertowXhrTransport.java
示例18: Undertow13BufferSupport
import io.undertow.client.ClientCallback; //导入依赖的package包/类
public Undertow13BufferSupport() {
this.undertowBufferPool = new DefaultByteBufferPool(false, 1024, -1, 2);
this.httpClientConnectCallbackMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
ClientCallback.class, URI.class, XnioWorker.class, ByteBufferPool.class, OptionMap.class);
this.httpClientConnectMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
URI.class, XnioWorker.class, ByteBufferPool.class, OptionMap.class);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:UndertowXhrTransport.java
示例19: handleConnected
import io.undertow.client.ClientCallback; //导入依赖的package包/类
private void handleConnected(StreamConnection connection, ClientCallback<ClientConnection> listener, URI uri, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
listener.completed(new AjpClientConnection(new AjpClientChannel(connection, bufferPool) , options, bufferPool));
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:AjpClientProvider.java
示例20: scheduleFailedHostRetry
import io.undertow.client.ClientCallback; //导入依赖的package包/类
/**
* If a host fails we periodically retry
*
* @param exchange The server exchange
*/
private void scheduleFailedHostRetry(final HttpServerExchange exchange) {
final int retry = connectionPoolManager.getProblemServerRetry();
// only schedule a retry task if the node is not available
if (retry > 0 && !connectionPoolManager.isAvailable()) {
exchange.getIoThread().executeAfter(new Runnable() {
@Override
public void run() {
if (closed) {
return;
}
UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Attempting to reconnect to failed host %s", getUri());
client.connect(new ClientCallback<ClientConnection>() {
@Override
public void completed(ClientConnection result) {
UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Connected to previously failed host %s, returning to service", getUri());
if (connectionPoolManager.clearError()) {
// In case the node is available now, return the connection
final ConnectionHolder connectionHolder = new ConnectionHolder(result);
final HostThreadData data = getData();
result.getCloseSetter().set(new ChannelListener<ClientConnection>() {
@Override
public void handleEvent(ClientConnection channel) {
handleClosedConnection(data, connectionHolder);
}
});
data.connections++;
returnConnection(connectionHolder);
} else {
// Otherwise reschedule the retry task
scheduleFailedHostRetry(exchange);
}
}
@Override
public void failed(IOException e) {
UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Failed to reconnect to failed host %s", getUri());
connectionPoolManager.handleError();
scheduleFailedHostRetry(exchange);
}
}, bindAddress, getUri(), exchange.getIoThread(), ssl, exchange.getConnection().getBufferPool(), options);
}
}, retry, TimeUnit.SECONDS);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:ProxyConnectionPool.java
注:本文中的io.undertow.client.ClientCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论