From 2627751a444bb2948fd141e832696ed5b84420b5 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 12 Mar 2009 06:24:26 +0000 Subject: [PATCH] Anonymous class to nested class --- .../http/HttpTunnelingSessionListener.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingSessionListener.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingSessionListener.java index 89425f968b..71d03b4c3a 100644 --- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingSessionListener.java +++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingSessionListener.java @@ -22,8 +22,8 @@ package org.jboss.netty.channel.socket.http; import static org.jboss.netty.channel.Channels.*; -import static org.jboss.netty.channel.socket.http.HttpTunnelingServlet.*; import static org.jboss.netty.channel.socket.http.HttpTunnelingContextListener.*; +import static org.jboss.netty.channel.socket.http.HttpTunnelingServlet.*; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; @@ -55,13 +55,7 @@ public class HttpTunnelingSessionListener implements HttpSessionListener, Channe } final HttpTunnelingChannelHandler handler = new HttpTunnelingChannelHandler(streaming, session, (Long) session.getServletContext().getAttribute(RECONNECT_PROP)); session.setAttribute(HANDLER_PROP, handler); - bootstrap.setPipelineFactory(new ChannelPipelineFactory() { - public ChannelPipeline getPipeline() throws Exception { - ChannelPipeline pipeline = pipeline(); - pipeline.addLast(HttpTunnelingSessionListener.class.getName(), handler); - return pipeline; - } - }); + bootstrap.setPipelineFactory(new HttpTunnelingChannelPipelineFactory(handler)); ChannelFuture future = bootstrap.connect(new LocalAddress((String) session.getServletContext().getAttribute(SERVER_CHANNEL_PROP))); future.awaitUninterruptibly(); final Channel ch = future.getChannel(); @@ -74,4 +68,24 @@ public class HttpTunnelingSessionListener implements HttpSessionListener, Channe channel.close(); } } + + /** + * @author The Netty Project (netty-dev@lists.jboss.org) + * @author Trustin Lee (tlee@redhat.com) + * @version $Rev$, $Date$ + */ + private static final class HttpTunnelingChannelPipelineFactory implements ChannelPipelineFactory { + + private final HttpTunnelingChannelHandler handler; + + HttpTunnelingChannelPipelineFactory(HttpTunnelingChannelHandler handler) { + this.handler = handler; + } + + public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = pipeline(); + pipeline.addLast(HttpTunnelingSessionListener.class.getName(), handler); + return pipeline; + } + } }