![]() |
![]() |
selenium-server-standalone-2.42.2oid operationComplete(ChannelFuture f) { this$0.realChannel.close().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { val$future.setSuccess(); } else { val$future.setFailure(f.getCause()); } this$0.setClosed(); } }); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannel.7 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelException; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.channel.socket.SocketChannel; import org.jboss.netty.handler.codec.http.HttpChunk; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; final class HttpTunnelingClientSocketChannel$ServletChannelHandler extends SimpleChannelUpstreamHandler { private volatile boolean readingChunks; final SocketChannel virtualChannel = this$0; HttpTunnelingClientSocketChannel$ServletChannelHandler(HttpTunnelingClientSocketChannel paramHttpTunnelingClientSocketChannel) {} public void channelBound(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelBound(virtualChannel, (SocketAddress)e.getValue()); } public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (!readingChunks) { HttpResponse res = (HttpResponse)e.getMessage(); if (res.getStatus().getCode() != HttpResponseStatus.OK.getCode()) { throw new ChannelException("Unexpected HTTP response status: " + res.getStatus()); } if (res.isChunked()) { readingChunks = true; } else { ChannelBuffer content = res.getContent(); if (content.readable()) { Channels.fireMessageReceived(this$0, content); } this$0.closeReal(Channels.succeededFuture(virtualChannel)); } } else { HttpChunk chunk = (HttpChunk)e.getMessage(); if (!chunk.isLast()) { Channels.fireMessageReceived(this$0, chunk.getContent()); } else { readingChunks = false; this$0.closeReal(Channels.succeededFuture(virtualChannel)); } } } public void channelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelInterestChanged(virtualChannel); } public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelDisconnected(virtualChannel); } public void channelUnbound(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelUnbound(virtualChannel); } public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelClosed(virtualChannel); } public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channels.fireExceptionCaught(virtualChannel, e.getCause()); this$0.realChannel.close(); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannel.ServletChannelHandler * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.channels.NotYetConnectedException; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.AbstractChannel; import org.jboss.netty.channel.ChannelException; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelSink; import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.DefaultChannelPipeline; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.channel.socket.ClientSocketChannelFactory; import org.jboss.netty.channel.socket.SocketChannel; import org.jboss.netty.handler.codec.http.DefaultHttpChunk; import org.jboss.netty.handler.codec.http.DefaultHttpRequest; import org.jboss.netty.handler.codec.http.HttpChunk; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpRequestEncoder; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseDecoder; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.ssl.SslHandler; class HttpTunnelingClientSocketChannel extends AbstractChannel implements SocketChannel { final HttpTunnelingSocketChannelConfig config; volatile boolean requestHeaderWritten; final Object interestOpsLock = new Object(); final SocketChannel realChannel; private final ServletChannelHandler handler = new ServletChannelHandler(); HttpTunnelingClientSocketChannel(ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, ClientSocketChannelFactory clientSocketChannelFactory) { super(null, factory, pipeline, sink); config = new HttpTunnelingSocketChannelConfig(this); DefaultChannelPipeline channelPipeline = new DefaultChannelPipeline(); channelPipeline.addLast("decoder", new HttpResponseDecoder()); channelPipeline.addLast("encoder", new HttpRequestEncoder()); channelPipeline.addLast("handler", handler); realChannel = clientSocketChannelFactory.newChannel(channelPipeline); Channels.fireChannelOpen(this); } public HttpTunnelingSocketChannelConfig getConfig() { return config; } public InetSocketAddress getLocalAddress() { return realChannel.getLocalAddress(); } public InetSocketAddress getRemoteAddress() { return realChannel.getRemoteAddress(); } public boolean isBound() { return realChannel.isBound(); } public boolean isConnected() { return realChannel.isConnected(); } public int getInterestOps() { return realChannel.getInterestOps(); } public boolean isWritable() { return realChannel.isWritable(); } protected boolean setClosed() { return super.setClosed(); } public ChannelFuture write(Object message, SocketAddress remoteAddress) { if ((remoteAddress == null) || (remoteAddress.equals(getRemoteAddress()))) { return super.write(message, null); } return getUnsupportedOperationFuture(); } void bindReal(SocketAddress localAddress, final ChannelFuture future) { realChannel.bind(localAddress).addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); } else { future.setFailure(f.getCause()); } } }); } void connectReal(final SocketAddress remoteAddress, final ChannelFuture future) { final SocketChannel virtualChannel = this; realChannel.connect(remoteAddress).addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { String serverName = config.getServerName(); int serverPort = ((InetSocketAddress)remoteAddress).getPort(); String serverPath = config.getServerPath(); if (f.isSuccess()) { SSLContext sslContext = config.getSslContext(); ChannelFuture sslHandshakeFuture = null; if (sslContext != null) { SSLEngine engine; SSLEngine engine; if (serverName != null) { engine = sslContext.createSSLEngine(serverName, serverPort); } else { engine = sslContext.createSSLEngine(); } engine.setUseClientMode(true); engine.setEnableSessionCreation(config.isEnableSslSessionCreation()); String[] enabledCipherSuites = config.getEnabledSslCipherSuites(); if (enabledCipherSuites != null) { engine.setEnabledCipherSuites(enabledCipherSuites); } String[] enabledProtocols = config.getEnabledSslProtocols(); if (enabledProtocols != null) { engine.setEnabledProtocols(enabledProtocols); } SslHandler sslHandler = new SslHandler(engine); realChannel.getPipeline().addFirst("ssl", sslHandler); sslHandshakeFuture = sslHandler.handshake(); } final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, serverPath); if (serverName != null) { req.setHeader("Host", serverName); } req.setHeader("Content-Type", "application/octet-stream"); req.setHeader("Transfer-Encoding", "chunked"); req.setHeader("Content-Transfer-Encoding", "binary"); req.setHeader("User-Agent", HttpTunnelingClientSocketChannel.class.getName()); if (sslHandshakeFuture == null) { realChannel.write(req); requestHeaderWritten = true; future.setSuccess(); Channels.fireChannelConnected(virtualChannel, remoteAddress); } else { sslHandshakeFuture.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { realChannel.write(req); requestHeaderWritten = true; val$future.setSuccess(); Channels.fireChannelConnected(val$virtualChannel, val$remoteAddress); } else { val$future.setFailure(f.getCause()); Channels.fireExceptionCaught(val$virtualChannel, f.getCause()); } } }); } } else { future.setFailure(f.getCause()); Channels.fireExceptionCaught(virtualChannel, f.getCause()); } } }); } void writeReal(ChannelBuffer a, final ChannelFuture future) { if (!requestHeaderWritten) { throw new NotYetConnectedException(); } final int size = a.readableBytes(); ChannelFuture f; ChannelFuture f; if (size == 0) { f = realChannel.write(ChannelBuffers.EMPTY_BUFFER); } else { f = realChannel.write(new DefaultHttpChunk(a)); } f.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); if (size != 0) { Channels.fireWriteComplete(HttpTunnelingClientSocketChannel.this, size); } } else { future.setFailure(f.getCause()); } } }); } private ChannelFuture writeLastChunk() { if (!requestHeaderWritten) { return Channels.failedFuture(this, new NotYetConnectedException()); } return realChannel.write(HttpChunk.LAST_CHUNK); } void setInterestOpsReal(int interestOps, final ChannelFuture future) { realChannel.setInterestOps(interestOps).addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { future.setSuccess(); } else { future.setFailure(f.getCause()); } } }); } void disconnectReal(final ChannelFuture future) { writeLastChunk().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { realChannel.disconnect().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { val$future.setSuccess(); } else { val$future.setFailure(f.getCause()); } } }); } }); } void unbindReal(final ChannelFuture future) { writeLastChunk().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { realChannel.unbind().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { val$future.setSuccess(); } else { val$future.setFailure(f.getCause()); } } }); } }); } void closeReal(final ChannelFuture future) { writeLastChunk().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { realChannel.close().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture f) { if (f.isSuccess()) { val$future.setSuccess(); } else { val$future.setFailure(f.getCause()); } setClosed(); } }); } }); } final class ServletChannelHandler extends SimpleChannelUpstreamHandler { private volatile boolean readingChunks; final SocketChannel virtualChannel = HttpTunnelingClientSocketChannel.this; ServletChannelHandler() {} public void channelBound(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelBound(virtualChannel, (SocketAddress)e.getValue()); } public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (!readingChunks) { HttpResponse res = (HttpResponse)e.getMessage(); if (res.getStatus().getCode() != HttpResponseStatus.OK.getCode()) { throw new ChannelException("Unexpected HTTP response status: " + res.getStatus()); } if (res.isChunked()) { readingChunks = true; } else { ChannelBuffer content = res.getContent(); if (content.readable()) { Channels.fireMessageReceived(HttpTunnelingClientSocketChannel.this, content); } closeReal(Channels.succeededFuture(virtualChannel)); } } else { HttpChunk chunk = (HttpChunk)e.getMessage(); if (!chunk.isLast()) { Channels.fireMessageReceived(HttpTunnelingClientSocketChannel.this, chunk.getContent()); } else { readingChunks = false; closeReal(Channels.succeededFuture(virtualChannel)); } } } public void channelInterestChanged(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelInterestChanged(virtualChannel); } public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelDisconnected(virtualChannel); } public void channelUnbound(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelUnbound(virtualChannel); } public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { Channels.fireChannelClosed(virtualChannel); } public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channels.fireExceptionCaught(virtualChannel, e.getCause()); realChannel.close(); } } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannel * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelSink; import org.jboss.netty.channel.socket.ClientSocketChannelFactory; import org.jboss.netty.channel.socket.SocketChannel; public class HttpTunnelingClientSocketChannelFactory implements ClientSocketChannelFactory { private final ChannelSink sink = new HttpTunnelingClientSocketPipelineSink(); private final ClientSocketChannelFactory clientSocketChannelFactory; public HttpTunnelingClientSocketChannelFactory(ClientSocketChannelFactory clientSocketChannelFactory) { this.clientSocketChannelFactory = clientSocketChannelFactory; } public SocketChannel newChannel(ChannelPipeline pipeline) { return new HttpTunnelingClientSocketChannel(this, pipeline, sink, clientSocketChannelFactory); } public void releaseExternalResources() { clientSocketChannelFactory.releaseExternalResources(); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannelFactory * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; class HttpTunnelingClientSocketPipelineSink$1 {} /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketPipelineSink.1 * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.AbstractChannelSink; import org.jboss.netty.channel.ChannelEvent; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelState; import org.jboss.netty.channel.ChannelStateEvent; import org.jboss.netty.channel.MessageEvent; final class HttpTunnelingClientSocketPipelineSink extends AbstractChannelSink { public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) throws Exception { HttpTunnelingClientSocketChannel channel = (HttpTunnelingClientSocketChannel)e.getChannel(); ChannelFuture future = e.getFuture(); if ((e instanceof ChannelStateEvent)) { ChannelStateEvent stateEvent = (ChannelStateEvent)e; ChannelState state = stateEvent.getState(); Object value = stateEvent.getValue(); switch (state) { case OPEN: if (Boolean.FALSE.equals(value)) { channel.closeReal(future); } break; case BOUND: if (value != null) { channel.bindReal((SocketAddress)value, future); } else { channel.unbindReal(future); } break; case CONNECTED: if (value != null) { channel.connectReal((SocketAddress)value, future); } else { channel.closeReal(future); } break; case INTEREST_OPS: channel.setInterestOpsReal(((Integer)value).intValue(), future); } } else if ((e instanceof MessageEvent)) { channel.writeReal((ChannelBuffer)((MessageEvent)e).getMessage(), future); } } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketPipelineSink * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import javax.servlet.ServletOutputStream; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.logging.InternalLogger; final class HttpTunnelingServlet$OutboundConnectionHandler extends SimpleChannelUpstreamHandler { private final ServletOutputStream out; public HttpTunnelingServlet$OutboundConnectionHandler(ServletOutputStream out) { this.out = out; } public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { ChannelBuffer buffer = (ChannelBuffer)e.getMessage(); synchronized (this) { buffer.readBytes(out, buffer.readableBytes()); out.flush(); } } public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (HttpTunnelingServlet.logger.isWarnEnabled()) { HttpTunnelingServlet.logger.warn("Unexpected exception while HTTP tunneling", e.getCause()); } e.getChannel().close(); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingServlet.OutboundConnectionHandler * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import java.io.EOFException; import java.io.IOException; import java.io.PushbackInputStream; import java.net.SocketAddress; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.ExceptionEvent; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory; import org.jboss.netty.channel.local.LocalAddress; import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLoggerFactory; public class HttpTunnelingServlet extends HttpServlet { private static final long serialVersionUID = 4259910275899756070L; private static final String ENDPOINT = "endpoint"; static final InternalLogger logger = InternalLoggerFactory.getInstance(HttpTunnelingServlet.class); private volatile SocketAddress remoteAddress; private volatile ChannelFactory channelFactory; public void init() throws ServletException { ServletConfig config = getServletConfig(); String endpoint = config.getInitParameter("endpoint"); if (endpoint == null) { throw new ServletException("init-param 'endpoint' must be specified."); } try { remoteAddress = parseEndpoint(endpoint.trim()); } catch (ServletException e) { throw e; } catch (Exception e) { throw new ServletException("Failed to parse an endpoint.", e); } try { channelFactory = createChannelFactory(remoteAddress); } catch (ServletException e) { throw e; } catch (Exception e) { throw new ServletException("Failed to create a channel factory.", e); } } protected SocketAddress parseEndpoint(String endpoint) throws Exception { if (endpoint.startsWith("local:")) { return new LocalAddress(endpoint.substring(6).trim()); } throw new ServletException("Invalid or unknown endpoint: " + endpoint); } protected ChannelFactory createChannelFactory(SocketAddress remoteAddress) throws Exception { if ((remoteAddress instanceof LocalAddress)) { return new DefaultLocalClientChannelFactory(); } throw new ServletException("Unsupported remote address type: " + remoteAddress.getClass().getName()); } public void destroy() { try { destroyChannelFactory(channelFactory); } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn("Failed to destroy a channel factory.", e); } } } protected void destroyChannelFactory(ChannelFactory factory) throws Exception { factory.releaseExternalResources(); } protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (!"POST".equalsIgnoreCase(req.getMethod())) { if (logger.isWarnEnabled()) { logger.warn("Unallowed method: " + req.getMethod()); } res.sendError(405); return; } ChannelPipeline pipeline = Channels.pipeline(); ServletOutputStream out = res.getOutputStream(); OutboundConnectionHandler handler = new OutboundConnectionHandler(out); pipeline.addLast("handler", handler); Channel channel = channelFactory.newChannel(pipeline); ChannelFuture future = channel.connect(remoteAddress).awaitUninterruptibly(); if (!future.isSuccess()) { if (logger.isWarnEnabled()) { Throwable cause = future.getCause(); logger.warn("Endpoint unavailable: " + cause.getMessage(), cause); } res.sendError(503); return; } ChannelFuture lastWriteFuture = null; try { res.setStatus(200); res.setHeader("Content-Type", "application/octet-stream"); res.setHeader("Content-Transfer-Encoding", "binary"); out.flush(); PushbackInputStream in = new PushbackInputStream(req.getInputStream()); while (channel.isConnected()) { ChannelBuffer buffer; try { buffer = read(in); } catch (EOFException e) { break; } if (buffer == null) { break; } lastWriteFuture = channel.write(buffer); } } finally { if (lastWriteFuture == null) { channel.close(); } else { lastWriteFuture.addListener(ChannelFutureListener.CLOSE); } } } private static ChannelBuffer read(PushbackInputStream in) throws IOException { int bytesToRead = in.available(); int readBytes; if (bytesToRead > 0) { byte[] buf = new byte[bytesToRead]; readBytes = in.read(buf); } else { int readBytes; if (bytesToRead == 0) { int b = in.read(); if ((b < 0) || (in.available() < 0)) { return null; } in.unread(b); bytesToRead = in.available(); byte[] buf = new byte[bytesToRead]; readBytes = in.read(buf); } else { return null; } } int readBytes; byte[] buf; assert (readBytes > 0); ChannelBuffer buffer; ChannelBuffer buffer; if (readBytes == buf.length) { buffer = ChannelBuffers.wrappedBuffer(buf); } else { buffer = ChannelBuffers.wrappedBuffer(buf, 0, readBytes); } return buffer; } private static final class OutboundConnectionHandler extends SimpleChannelUpstreamHandler { private final ServletOutputStream out; public OutboundConnectionHandler(ServletOutputStream out) { this.out = out; } public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { ChannelBuffer buffer = (ChannelBuffer)e.getMessage(); synchronized (this) { buffer.readBytes(out, buffer.readableBytes()); out.flush(); } } public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (HttpTunnelingServlet.logger.isWarnEnabled()) { HttpTunnelingServlet.logger.warn("Unexpected exception while HTTP tunneling", e.getCause()); } e.getChannel().close(); } } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingServlet * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.http; import java.util.Map; import java.util.Map.Entry; import javax.net.ssl.SSLContext; import org.jboss.netty.buffer.ChannelBufferFactory; import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.socket.SocketChannel; import org.jboss.netty.channel.socket.SocketChannelConfig; import org.jboss.netty.util.internal.ConversionUtil; public final class HttpTunnelingSocketChannelConfig implements SocketChannelConfig { private final HttpTunnelingClientSocketChannel channel; private volatile String serverName; private volatile String serverPath = "/netty-tunnel"; private volatile SSLContext sslContext; private volatile String[] enabledSslCipherSuites; private volatile String[] enabledSslProtocols; private volatile boolean enableSslSessionCreation = true; HttpTunnelingSocketChannelConfig(HttpTunnelingClientSocketChannel channel) { this.channel = channel; } public String getServerName() { return serverName; } public void setServerName(String serverName) { this.serverName = serverName; } public String getServerPath() { return serverPath; } public void setServerPath(String serverPath) { if (serverPath == null) { throw new NullPointerException("serverPath"); } this.serverPath = serverPath; } public SSLContext getSslContext() { return sslContext; } public void setSslContext(SSLContext sslContext) { this.sslContext = sslContext; } public String[] getEnabledSslCipherSuites() { String[] suites = enabledSslCipherSuites; if (suites == null) { return null; } return (String[])suites.clone(); } public void setEnabledSslCipherSuites(String[] suites) { if (suites == null) { enabledSslCipherSuites = null; } else { enabledSslCipherSuites = ((String[])suites.clone()); } } public String[] getEnabledSslProtocols() { String[] protocols = enabledSslProtocols; if (protocols == null) { return null; } return (String[])protocols.clone(); } public void setEnabledSslProtocols(String[] protocols) { if (protocols == null) { enabledSslProtocols = null; } else { enabledSslProtocols = ((String[])protocols.clone()); } } public boolean isEnableSslSessionCreation() { return enableSslSessionCreation; } public void setEnableSslSessionCreation(boolean flag) { enableSslSessionCreation = flag; } public void setOptions(Map<String, Object> options) { for (Map.Entry<String, Object> e : options.entrySet()) { setOption((String)e.getKey(), e.getValue()); } } public boolean setOption(String key, Object value) { if (channel.realChannel.getConfig().setOption(key, value)) { return true; } if (key.equals("serverName")) { setServerName(String.valueOf(value)); } else if (key.equals("serverPath")) { setServerPath(String.valueOf(value)); } else if (key.equals("sslContext")) { setSslContext((SSLContext)value); } else if (key.equals("enabledSslCipherSuites")) { setEnabledSslCipherSuites(ConversionUtil.toStringArray(value)); } else if (key.equals("enabledSslProtocols")) { setEnabledSslProtocols(ConversionUtil.toStringArray(value)); } else if (key.equals("enableSslSessionCreation")) { setEnableSslSessionCreation(ConversionUtil.toBoolean(value)); } else { return false; } return true; } public int getReceiveBufferSize() { return channel.realChannel.getConfig().getReceiveBufferSize(); } public int getSendBufferSize() { return channel.realChannel.getConfig().getSendBufferSize(); } public int getSoLinger() { return channel.realChannel.getConfig().getSoLinger(); } public int getTrafficClass() { return channel.realChannel.getConfig().getTrafficClass(); } public boolean isKeepAlive() { return channel.realChannel.getConfig().isKeepAlive(); } public boolean isReuseAddress() { return channel.realChannel.getConfig().isReuseAddress(); } public boolean isTcpNoDelay() { return channel.realChannel.getConfig().isTcpNoDelay(); } public void setKeepAlive(boolean keepAlive) { channel.realChannel.getConfig().setKeepAlive(keepAlive); } public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) { channel.realChannel.getConfig().setPerformancePreferences(connectionTime, latency, bandwidth); } public void setReceiveBufferSize(int receiveBufferSize) { channel.realChannel.getConfig().setReceiveBufferSize(receiveBufferSize); } public void setReuseAddress(boolean reuseAddress) { channel.realChannel.getConfig().setReuseAddress(reuseAddress); } public void setSendBufferSize(int sendBufferSize) { channel.realChannel.getConfig().setSendBufferSize(sendBufferSize); } public void setSoLinger(int soLinger) { channel.realChannel.getConfig().setSoLinger(soLinger); } public void setTcpNoDelay(boolean tcpNoDelay) { channel.realChannel.getConfig().setTcpNoDelay(tcpNoDelay); } public void setTrafficClass(int trafficClass) { channel.realChannel.getConfig().setTrafficClass(trafficClass); } public ChannelBufferFactory getBufferFactory() { return channel.realChannel.getConfig().getBufferFactory(); } public int getConnectTimeoutMillis() { return channel.realChannel.getConfig().getConnectTimeoutMillis(); } public ChannelPipelineFactory getPipelineFactory() { return channel.realChannel.getConfig().getPipelineFactory(); } public void setBufferFactory(ChannelBufferFactory bufferFactory) { channel.realChannel.getConfig().setBufferFactory(bufferFactory); } public void setConnectTimeoutMillis(int connectTimeoutMillis) { channel.realChannel.getConfig().setConnectTimeoutMillis(connectTimeoutMillis); } public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) { channel.realChannel.getConfig().setPipelineFactory(pipelineFactory); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.http.HttpTunnelingSocketChannelConfig * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.nio; import java.util.Collection; import java.util.Iterator; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.util.internal.ThreadLocalBoolean; final class AbstractNioChannel$WriteRequestQueue implements Queue<MessageEvent> { private final ThreadLocalBoolean notifying = new ThreadLocalBoolean(); private final Queue<MessageEvent> queue; public AbstractNioChannel$WriteRequestQueue(AbstractNioChannel paramAbstractNioChannel) { queue = new ConcurrentLinkedQueue(); } public MessageEvent remove() { return (MessageEvent)queue.remove(); } public MessageEvent element() { return (MessageEvent)queue.element(); } public MessageEvent peek() { return (MessageEvent)queue.peek(); } public int size() { return queue.size(); } public boolean isEmpty() { return queue.isEmpty(); } public Iterator<MessageEvent> iterator() { return queue.iterator(); } public Object[] toArray() { return queue.toArray(); } public <T> T[] toArray(T[] a) { return queue.toArray(a); } public boolean containsAll(Collection<?> c) { return queue.containsAll(c); } public boolean addAll(Collection<? extends MessageEvent> c) { return queue.addAll(c); } public boolean removeAll(Collection<?> c) { return queue.removeAll(c); } public boolean retainAll(Collection<?> c) { return queue.retainAll(c); } public void clear() { queue.clear(); } public boolean add(MessageEvent e) { return queue.add(e); } public boolean remove(Object o) { return queue.remove(o); } public boolean contains(Object o) { return queue.contains(o); } public boolean offer(MessageEvent e) { boolean success = queue.offer(e); assert (success); int messageSize = getMessageSize(e); int newWriteBufferSize = this$0.writeBufferSize.addAndGet(messageSize); int highWaterMark = this$0.getConfig().getWriteBufferHighWaterMark(); if ((newWriteBufferSize >= highWaterMark) && (newWriteBufferSize - messageSize < highWaterMark)) { this$0.highWaterMarkCounter.incrementAndGet(); if (!((Boolean)notifying.get()).booleanValue()) { notifying.set(Boolean.TRUE); Channels.fireChannelInterestChanged(this$0); notifying.set(Boolean.FALSE); } } return true; } public MessageEvent poll() { MessageEvent e = (MessageEvent)queue.poll(); if (e != null) { int messageSize = getMessageSize(e); int newWriteBufferSize = this$0.writeBufferSize.addAndGet(-messageSize); int lowWaterMark = this$0.getConfig().getWriteBufferLowWaterMark(); if (((newWriteBufferSize == 0) || (newWriteBufferSize < lowWaterMark)) && (newWriteBufferSize + messageSize >= lowWaterMark)) { this$0.highWaterMarkCounter.decrementAndGet(); if ((this$0.isConnected()) && (!((Boolean)notifying.get()).booleanValue())) { notifying.set(Boolean.TRUE); Channels.fireChannelInterestChanged(this$0); notifying.set(Boolean.FALSE); } } } return e; } private int getMessageSize(MessageEvent e) { Object m = e.getMessage(); if ((m instanceof ChannelBuffer)) { return ((ChannelBuffer)m).readableBytes(); } return 0; } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.nio.AbstractNioChannel.WriteRequestQueue * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.nio; import java.util.concurrent.atomic.AtomicBoolean; final class AbstractNioChannel$WriteTask implements Runnable { AbstractNioChannel$WriteTask(AbstractNioChannel paramAbstractNioChannel) {} public void run() { this$0.writeTaskInTaskQueue.set(false); this$0.worker.writeFromTaskLoop(this$0); } } /* Location: * Qualified Name: org.jboss.netty.channel.socket.nio.AbstractNioChannel.WriteTask * Java Class Version: 5 (49.0) * JD-Core Version: 0.7.1 */ package org.jboss.netty.channel.socket.nio; import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.SelectableChannel; import java.nio.channels.WritableByteChannel; import java.util.Collection; import java.util.Iterator; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.AbstractChannel; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.chann Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|