* SecureChatServerHandler should use ChannelGroup where possible

* Moved MapBackedSet and its test class to org.jboss.netty.util becuase it's used only there
This commit is contained in:
Trustin Lee 2010-01-14 11:56:38 +00:00
parent be2991c586
commit 0dbea6f162
5 changed files with 8 additions and 11 deletions

View File

@ -16,8 +16,6 @@
package org.jboss.netty.example.securechat;
import java.net.InetAddress;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -31,8 +29,9 @@ import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.netty.util.internal.MapBackedSet;
/**
* Handles a server-side channel.
@ -48,8 +47,7 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
private static final Logger logger = Logger.getLogger(
SecureChatServerHandler.class.getName());
static final Set<Channel> channels =
new MapBackedSet<Channel>(new ConcurrentHashMap<Channel, Boolean>());
static final ChannelGroup channels = new DefaultChannelGroup();
@Override
public void handleUpstream(

View File

@ -31,7 +31,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
import org.jboss.netty.util.internal.MapBackedSet;
import org.jboss.netty.util.internal.ReusableIterator;
/**

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.jboss.netty.util.internal;
package org.jboss.netty.util;
import java.io.Serializable;
import java.util.AbstractSet;
@ -29,7 +29,7 @@ import java.util.Set;
*
* @version $Rev$, $Date$
*/
public class MapBackedSet<E> extends AbstractSet<E> implements Serializable {
final class MapBackedSet<E> extends AbstractSet<E> implements Serializable {
private static final long serialVersionUID = -6761513279741915432L;
@ -38,7 +38,7 @@ public class MapBackedSet<E> extends AbstractSet<E> implements Serializable {
/**
* Creates a new instance which wraps the specified {@code map}.
*/
public MapBackedSet(Map<E, Boolean> map) {
MapBackedSet(Map<E, Boolean> map) {
this.map = map;
}

View File

@ -25,7 +25,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import org.jboss.netty.util.internal.MapBackedSet;
/**
* A delegating {@link ExecutorService} with its own termination management.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.jboss.netty.util.internal;
package org.jboss.netty.util;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.jboss.netty.util.MapBackedSet;
import org.junit.Test;