diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java new file mode 100644 index 0000000000..6dffb90807 --- /dev/null +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalClientChannelFactory.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.netty.channel.local; + +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelSink; + +/** + * @author The Netty Project (netty-dev@lists.jboss.org) + * @author Andy Taylor (andy.taylor@jboss.org) + * @author Trustin Lee (tlee@redhat.com) + * @version $Rev$, $Date$ + */ +public class DefaultLocalClientChannelFactory implements LocalClientChannelFactory { + + private final ChannelSink sink; + + public DefaultLocalClientChannelFactory() { + sink = new LocalClientChannelSink(); + } + + public LocalChannel newChannel(ChannelPipeline pipeline) { + return new DefaultLocalChannel(null, this, pipeline, sink, null); + } + + public void releaseExternalResources() { + // No external resources. + } +} diff --git a/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java new file mode 100644 index 0000000000..869f7f54d4 --- /dev/null +++ b/src/main/java/org/jboss/netty/channel/local/DefaultLocalServerChannelFactory.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.netty.channel.local; + +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelSink; + +/** + * @author The Netty Project (netty-dev@lists.jboss.org) + * @author Andy Taylor (andy.taylor@jboss.org) + * @author Trustin Lee (tlee@redhat.com) + * @version $Rev$, $Date$ + */ +public class DefaultLocalServerChannelFactory implements LocalServerChannelFactory { + + private final ChannelSink sink = new LocalServerChannelSink(); + + public DefaultLocalServerChannelFactory() { + super(); + } + + public LocalServerChannel newChannel(ChannelPipeline pipeline) { + return new DefaultLocalServerChannel(this, pipeline, sink); + } + + public void releaseExternalResources() { + // Unused + } +} diff --git a/src/main/java/org/jboss/netty/channel/local/LocalClientChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/LocalClientChannelFactory.java index 4883c3aa4f..295fb3183f 100644 --- a/src/main/java/org/jboss/netty/channel/local/LocalClientChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/local/LocalClientChannelFactory.java @@ -23,27 +23,12 @@ package org.jboss.netty.channel.local; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelSink; /** * @author The Netty Project (netty-dev@lists.jboss.org) - * @author Andy Taylor (andy.taylor@jboss.org) * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ */ -public class LocalClientChannelFactory implements ChannelFactory { - - private final ChannelSink sink; - - public LocalClientChannelFactory() { - sink = new LocalClientChannelSink(); - } - - public LocalChannel newChannel(ChannelPipeline pipeline) { - return new DefaultLocalChannel(null, this, pipeline, sink, null); - } - - public void releaseExternalResources() { - // No external resources. - } +public interface LocalClientChannelFactory extends ChannelFactory { + LocalChannel newChannel(ChannelPipeline pipeline); } diff --git a/src/main/java/org/jboss/netty/channel/local/LocalServerChannelFactory.java b/src/main/java/org/jboss/netty/channel/local/LocalServerChannelFactory.java index e77b7014d7..e4f7baf0f4 100644 --- a/src/main/java/org/jboss/netty/channel/local/LocalServerChannelFactory.java +++ b/src/main/java/org/jboss/netty/channel/local/LocalServerChannelFactory.java @@ -23,27 +23,12 @@ package org.jboss.netty.channel.local; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.channel.ChannelSink; /** * @author The Netty Project (netty-dev@lists.jboss.org) - * @author Andy Taylor (andy.taylor@jboss.org) * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ */ -public class LocalServerChannelFactory implements ChannelFactory { - - private final ChannelSink sink = new LocalServerChannelSink(); - - public LocalServerChannelFactory() { - super(); - } - - public LocalServerChannel newChannel(ChannelPipeline pipeline) { - return new DefaultLocalServerChannel(this, pipeline, sink); - } - - public void releaseExternalResources() { - // Unused - } +public interface LocalServerChannelFactory extends ChannelFactory { + LocalServerChannel newChannel(ChannelPipeline pipeline); } diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingContextListener.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingContextListener.java index 36848da218..786bd33ceb 100644 --- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingContextListener.java +++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingContextListener.java @@ -26,7 +26,7 @@ import javax.servlet.ServletContextListener; import org.jboss.netty.bootstrap.ClientBootstrap; import org.jboss.netty.channel.ChannelFactory; -import org.jboss.netty.channel.local.LocalClientChannelFactory; +import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory; /** * A context listener that creates a client bootstrap that uses a local channel factory. The local channel factory should @@ -50,7 +50,7 @@ public class HttpTunnelingContextListener implements ServletContextListener { static final String BOOTSTRAP_PROP = "bootstrap"; - private final ChannelFactory factory = new LocalClientChannelFactory(); + private final ChannelFactory factory = new DefaultLocalClientChannelFactory(); public void contextInitialized(ServletContextEvent context) { context.getServletContext().setAttribute(BOOTSTRAP_PROP, new ClientBootstrap(factory)); diff --git a/src/main/java/org/jboss/netty/example/http/LocalTransportRegister.java b/src/main/java/org/jboss/netty/example/http/LocalTransportRegister.java index 8d39805248..cc8e384f44 100644 --- a/src/main/java/org/jboss/netty/example/http/LocalTransportRegister.java +++ b/src/main/java/org/jboss/netty/example/http/LocalTransportRegister.java @@ -24,8 +24,8 @@ package org.jboss.netty.example.http; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFactory; +import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory; import org.jboss.netty.channel.local.LocalAddress; -import org.jboss.netty.channel.local.LocalServerChannelFactory; import org.jboss.netty.example.echo.EchoHandler; /** @@ -42,7 +42,7 @@ import org.jboss.netty.example.echo.EchoHandler; */ public class LocalTransportRegister { - private final ChannelFactory factory = new LocalServerChannelFactory(); + private final ChannelFactory factory = new DefaultLocalServerChannelFactory(); private volatile Channel serverChannel; public void start() { diff --git a/src/main/java/org/jboss/netty/example/local/LocalExample.java b/src/main/java/org/jboss/netty/example/local/LocalExample.java index 93de373d4d..def000f6e8 100644 --- a/src/main/java/org/jboss/netty/example/local/LocalExample.java +++ b/src/main/java/org/jboss/netty/example/local/LocalExample.java @@ -33,9 +33,9 @@ import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipelineCoverage; import org.jboss.netty.channel.ChannelUpstreamHandler; +import org.jboss.netty.channel.local.DefaultLocalClientChannelFactory; +import org.jboss.netty.channel.local.DefaultLocalServerChannelFactory; import org.jboss.netty.channel.local.LocalAddress; -import org.jboss.netty.channel.local.LocalClientChannelFactory; -import org.jboss.netty.channel.local.LocalServerChannelFactory; import org.jboss.netty.example.echo.EchoHandler; import org.jboss.netty.handler.codec.string.StringDecoder; import org.jboss.netty.handler.codec.string.StringEncoder; @@ -47,14 +47,14 @@ import org.jboss.netty.handler.codec.string.StringEncoder; */ public class LocalExample { public static void main(String[] args) throws Exception { - ChannelFactory factory = new LocalServerChannelFactory(); + ChannelFactory factory = new DefaultLocalServerChannelFactory(); ServerBootstrap bootstrap = new ServerBootstrap(factory); EchoHandler handler = new EchoHandler(); LocalAddress socketAddress = new LocalAddress("1"); bootstrap.getPipeline().addLast("handler", handler); bootstrap.bind(socketAddress); - ChannelFactory channelFactory = new LocalClientChannelFactory(); + ChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); ClientBootstrap clientBootstrap = new ClientBootstrap(channelFactory); clientBootstrap.getPipeline().addLast("decoder", new StringDecoder()); clientBootstrap.getPipeline().addLast("encoder", new StringEncoder());