this.exchange = exchange;
}
@Override
public void completed(final ClientConnection connection) {
final ServerConnection serverConnection = exchange.getConnection();
//we attach to the connection so it can be re-used
serverConnection.putAttachment(clientAttachmentKey, connection);
serverConnection.addCloseListener(new ServerConnection.CloseListener() {
@Override
public void closed(ServerConnection serverConnection) {
IoUtils.safeClose(connection);
}
});
connection.getCloseSetter().set(new ChannelListener<Channel>() {
@Override
public void handleEvent(Channel channel) {
serverConnection.removeAttachment(clientAttachmentKey);
}
});
callback.completed(exchange, new ProxyConnection(connection, uri.getPath() == null ? "/" : uri.getPath()));
}