* Added LocalAcceptedChannel and LocalClientChannel to distinguish two channel types easily

* Less visibility
This commit is contained in:
Trustin Lee 2009-02-09 08:19:30 +00:00
parent 198fbe3e7e
commit ddf8cad09c
5 changed files with 84 additions and 3 deletions

View File

@ -0,0 +1,40 @@
/*
* 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.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 Trustin Lee (tlee@redhat.com)
* @version $Rev$, $Date$
*/
class LocalAcceptedChannel extends LocalChannel {
LocalAcceptedChannel(LocalServerChannel parent, ChannelFactory factory,
ChannelPipeline pipeline, ChannelSink sink,
LocalChannel pairedChannel) {
super(parent, factory, pipeline, sink, pairedChannel);
}
}

View File

@ -41,7 +41,7 @@ import org.jboss.netty.util.LinkedTransferQueue;
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* @author Trustin Lee (tlee@redhat.com)
*/
public class LocalChannel extends AbstractChannel {
class LocalChannel extends AbstractChannel {
private final ThreadLocal<Boolean> delivering = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {

View File

@ -0,0 +1,40 @@
/*
* 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.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 Trustin Lee (tlee@redhat.com)
* @version $Rev$, $Date$
*/
class LocalClientChannel extends LocalChannel {
LocalClientChannel(ChannelFactory factory,
ChannelPipeline pipeline, ChannelSink sink,
LocalChannel pairedChannel) {
super(null, factory, pipeline, sink, pairedChannel);
}
}

View File

@ -39,7 +39,7 @@ public class LocalClientChannelFactory implements ChannelFactory {
}
public Channel newChannel(ChannelPipeline pipeline) {
return new LocalChannel(null, this, pipeline, sink, null);
return new LocalClientChannel(this, pipeline, sink, null);
}
public void releaseExternalResources() {

View File

@ -129,7 +129,8 @@ final class LocalClientChannelSink extends AbstractChannelSink {
}
future.setSuccess();
LocalChannel acceptedChannel = new LocalChannel(serverChannel, serverChannel.getFactory(), pipeline, this, channel);
LocalChannel acceptedChannel = new LocalAcceptedChannel(
serverChannel, serverChannel.getFactory(), pipeline, this, channel);
channel.pairedChannel = acceptedChannel;
bind(channel, succeededFuture(channel), LocalAddress.newEphemeralInstance());