From b6ff3a4cad6fdce371cb2e35dea2fe3a1cc9bb27 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sun, 12 Apr 2009 06:26:28 +0000 Subject: [PATCH] Added container support for OioDatagramChannelFactory --- .../netty/container/guice/NettyModule.java | 10 ++++ .../OioDatagramChannelFactoryProvider.java | 48 +++++++++++++++++++ .../container/osgi/NettyBundleActivator.java | 6 +++ src/main/resources/META-INF/jboss-beans.xml | 12 +++++ .../jboss/netty/container/spring/beans.xml | 8 ++++ 5 files changed, 84 insertions(+) create mode 100644 src/main/java/org/jboss/netty/container/guice/OioDatagramChannelFactoryProvider.java diff --git a/src/main/java/org/jboss/netty/container/guice/NettyModule.java b/src/main/java/org/jboss/netty/container/guice/NettyModule.java index a957a68085..94da6cc524 100644 --- a/src/main/java/org/jboss/netty/container/guice/NettyModule.java +++ b/src/main/java/org/jboss/netty/container/guice/NettyModule.java @@ -27,10 +27,12 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.jboss.netty.channel.socket.ClientSocketChannelFactory; +import org.jboss.netty.channel.socket.DatagramChannelFactory; import org.jboss.netty.channel.socket.ServerSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory; +import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory; import org.jboss.netty.util.internal.ExecutorUtil; import org.jboss.netty.util.internal.UnterminatableExecutor; @@ -72,6 +74,10 @@ public class NettyModule extends AbstractModule { toProvider(NioServerSocketChannelFactoryProvider.class). in(Scopes.SINGLETON); + bind(DatagramChannelFactory.class). + toProvider(OioDatagramChannelFactoryProvider.class). + in(Scopes.SINGLETON); + bind(NioClientSocketChannelFactory.class). toProvider(NioClientSocketChannelFactoryProvider.class). in(Scopes.SINGLETON); @@ -87,5 +93,9 @@ public class NettyModule extends AbstractModule { bind(OioServerSocketChannelFactory.class). toProvider(OioServerSocketChannelFactoryProvider.class). in(Scopes.SINGLETON); + + bind(OioDatagramChannelFactory.class). + toProvider(OioDatagramChannelFactoryProvider.class). + in(Scopes.SINGLETON); } } diff --git a/src/main/java/org/jboss/netty/container/guice/OioDatagramChannelFactoryProvider.java b/src/main/java/org/jboss/netty/container/guice/OioDatagramChannelFactoryProvider.java new file mode 100644 index 0000000000..1a81f3a559 --- /dev/null +++ b/src/main/java/org/jboss/netty/container/guice/OioDatagramChannelFactoryProvider.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * + * Copyright 2009, Red Hat Middleware LLC, and individual contributors + * by the @author tags. 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.container.guice; + +import java.util.concurrent.Executor; + +import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; + +import com.google.inject.Inject; + +/** + * @author The Netty Project (netty-dev@lists.jboss.org) + * @author Trustin Lee (tlee@redhat.com) + * @version $Rev$, $Date$ + */ +public class OioDatagramChannelFactoryProvider extends + AbstractChannelFactoryProvider { + + @Inject + public OioDatagramChannelFactoryProvider( + @ChannelFactoryResource Executor executor) { + super(executor); + } + + public OioDatagramChannelFactory get() { + return new OioDatagramChannelFactory(executor); + } +} diff --git a/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java b/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java index 45ca29524c..9caa67add0 100644 --- a/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java +++ b/src/main/java/org/jboss/netty/container/osgi/NettyBundleActivator.java @@ -30,10 +30,12 @@ import java.util.concurrent.Executors; import org.jboss.netty.channel.ChannelFactory; import org.jboss.netty.channel.socket.ClientSocketChannelFactory; +import org.jboss.netty.channel.socket.DatagramChannelFactory; import org.jboss.netty.channel.socket.ServerSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory; +import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory; import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory; import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.logging.OsgiLoggerFactory; @@ -70,6 +72,10 @@ public class NettyBundleActivator implements BundleActivator { register(ctx, new NioServerSocketChannelFactory(executor, executor), ServerSocketChannelFactory.class); + // ... except for the datagram transport. + register(ctx, + new OioDatagramChannelFactory(executor), + DatagramChannelFactory.class); register(ctx, new OioClientSocketChannelFactory(executor)); register(ctx, new OioServerSocketChannelFactory(executor, executor)); diff --git a/src/main/resources/META-INF/jboss-beans.xml b/src/main/resources/META-INF/jboss-beans.xml index 3881929830..a0b23cc4ad 100644 --- a/src/main/resources/META-INF/jboss-beans.xml +++ b/src/main/resources/META-INF/jboss-beans.xml @@ -89,4 +89,16 @@ + + + org.jboss.netty.channel.socket.DatagramChannelFactory + org.jboss.netty.internal.ChannelFactoryExecutor + + + + + + \ No newline at end of file diff --git a/src/main/resources/org/jboss/netty/container/spring/beans.xml b/src/main/resources/org/jboss/netty/container/spring/beans.xml index e168d89638..e2e1e93596 100644 --- a/src/main/resources/org/jboss/netty/container/spring/beans.xml +++ b/src/main/resources/org/jboss/netty/container/spring/beans.xml @@ -60,8 +60,16 @@ + + + + +