1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.channel.local;
17
18 import java.util.concurrent.ConcurrentHashMap;
19 import java.util.concurrent.ConcurrentMap;
20
21 import org.jboss.netty.channel.Channel;
22
23
24
25 final class LocalChannelRegistry {
26
27 private static final ConcurrentMap<LocalAddress, Channel> map =
28 new ConcurrentHashMap<LocalAddress, Channel>();
29
30 static boolean isRegistered(LocalAddress address) {
31 return map.containsKey(address);
32 }
33
34 static Channel getChannel(LocalAddress address) {
35 return map.get(address);
36 }
37
38 static boolean register(LocalAddress address, Channel channel) {
39 return map.putIfAbsent(address, channel) == null;
40 }
41
42 static boolean unregister(LocalAddress address) {
43 return map.remove(address) != null;
44 }
45
46 private LocalChannelRegistry() {
47
48 }
49 }