[jboss-cvs] JBoss Messaging SVN: r4813 - trunk/src/main/org/jboss/messaging/core/remoting/impl/netty.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 18 04:55:18 EDT 2008
Author: trustin
Date: 2008-08-18 04:55:18 -0400 (Mon, 18 Aug 2008)
New Revision: 4813
Modified:
trunk/src/main/org/jboss/messaging/core/remoting/impl/netty/NettyAcceptor.java
Log:
Simplfied NettyAcceptor implementation
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/netty/NettyAcceptor.java 2008-08-18 08:54:56 UTC (rev 4812)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/netty/NettyAcceptor.java 2008-08-18 08:55:18 UTC (rev 4813)
@@ -43,7 +43,7 @@
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.ChildChannelStateEvent;
+import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
@@ -67,7 +67,6 @@
private ChannelFactory channelFactory;
private Channel serverChannel;
private ServerBootstrap bootstrap;
- private NettyChildChannelHandler childChannelHandler;
private final Configuration configuration;
@@ -97,8 +96,6 @@
workerExecutor = Executors.newCachedThreadPool();
channelFactory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);
bootstrap = new ServerBootstrap(channelFactory);
- childChannelHandler = new NettyChildChannelHandler();
- bootstrap.setParentHandler(childChannelHandler);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception
@@ -144,9 +141,6 @@
return;
}
- // remove the listener before disposing the acceptor
- // so that we're not notified when the sessions are destroyed
- serverChannel.getPipeline().remove(childChannelHandler);
serverChannel.close().awaitUninterruptibly();
bossExecutor.shutdown();
workerExecutor.shutdown();
@@ -159,6 +153,27 @@
private final class NettyHandler extends SimpleChannelHandler
{
@Override
+ public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
+ {
+ Connection tc = new NettyConnection(e.getChannel());
+ listener.connectionCreated(tc);
+ }
+
+ @Override
+ public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception
+ {
+ boolean notify;
+ synchronized (NettyAcceptor.this)
+ {
+ notify = channelFactory == null;
+ }
+
+ if (notify) {
+ listener.connectionDestroyed(e.getChannel().getId());
+ }
+ }
+
+ @Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
{
log.error(
@@ -180,24 +195,4 @@
handler.bufferReceived(e.getChannel().getId(), new ChannelBufferWrapper(buffer));
}
}
-
- @ChannelPipelineCoverage("one")
- private final class NettyChildChannelHandler extends SimpleChannelHandler
- {
-
- @Override
- public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception
- {
- Connection tc = new NettyConnection(e.getChildChannel());
- listener.connectionCreated(tc);
- ctx.sendUpstream(e);
- }
-
- @Override
- public void childChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception
- {
- listener.connectionDestroyed(e.getChildChannel().getId());
- ctx.sendUpstream(e);
- }
- }
}
More information about the jboss-cvs-commits
mailing list