@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())); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
exchange.putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext); exchange.getConnection().putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext);
@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())); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@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())); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
exchange.putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext); exchange.getConnection().putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext);
if (negContext == null) { negContext = new NegotiationContext(); connection.putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext);
exchange.putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext); exchange.getConnection().putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext);
exchange.putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext); exchange.getConnection().putAttachment(NegotiationContext.ATTACHMENT_KEY, negContext);