* Renamed Local*ChannelFactory to DefaultLocal*ChannelFactory

* Local*ChannelFactories are now interfaces
This commit is contained in:
Trustin Lee 2009-02-21 19:24:49 +00:00
parent b56bdd89dd
commit cd341609fa
7 changed files with 108 additions and 42 deletions

View File

@ -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.
}
}

View File

@ -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
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));

View File

@ -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() {

View File

@ -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());