* 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:
parent
be2991c586
commit
0dbea6f162
@ -16,8 +16,6 @@
|
|||||||
package org.jboss.netty.example.securechat;
|
package org.jboss.netty.example.securechat;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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.ExceptionEvent;
|
||||||
import org.jboss.netty.channel.MessageEvent;
|
import org.jboss.netty.channel.MessageEvent;
|
||||||
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
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.handler.ssl.SslHandler;
|
||||||
import org.jboss.netty.util.internal.MapBackedSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a server-side channel.
|
* Handles a server-side channel.
|
||||||
@ -48,8 +47,7 @@ public class SecureChatServerHandler extends SimpleChannelUpstreamHandler {
|
|||||||
private static final Logger logger = Logger.getLogger(
|
private static final Logger logger = Logger.getLogger(
|
||||||
SecureChatServerHandler.class.getName());
|
SecureChatServerHandler.class.getName());
|
||||||
|
|
||||||
static final Set<Channel> channels =
|
static final ChannelGroup channels = new DefaultChannelGroup();
|
||||||
new MapBackedSet<Channel>(new ConcurrentHashMap<Channel, Boolean>());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpstream(
|
public void handleUpstream(
|
||||||
|
@ -31,7 +31,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import org.jboss.netty.logging.InternalLogger;
|
import org.jboss.netty.logging.InternalLogger;
|
||||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||||
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
|
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
|
||||||
import org.jboss.netty.util.internal.MapBackedSet;
|
|
||||||
import org.jboss.netty.util.internal.ReusableIterator;
|
import org.jboss.netty.util.internal.ReusableIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* License for the specific language governing permissions and limitations
|
* License for the specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jboss.netty.util.internal;
|
package org.jboss.netty.util;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.AbstractSet;
|
import java.util.AbstractSet;
|
||||||
@ -29,7 +29,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @version $Rev$, $Date$
|
* @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;
|
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}.
|
* Creates a new instance which wraps the specified {@code map}.
|
||||||
*/
|
*/
|
||||||
public MapBackedSet(Map<E, Boolean> map) {
|
MapBackedSet(Map<E, Boolean> map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,6 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jboss.netty.util.internal.MapBackedSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A delegating {@link ExecutorService} with its own termination management.
|
* A delegating {@link ExecutorService} with its own termination management.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* License for the specific language governing permissions and limitations
|
* License for the specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jboss.netty.util.internal;
|
package org.jboss.netty.util;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*;
|
import static org.easymock.EasyMock.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@ -22,6 +22,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jboss.netty.util.MapBackedSet;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user