125
|
1 package rep.channel;
|
|
2
|
|
3 import java.io.IOException;
|
143
|
4 import java.nio.channels.ClosedChannelException;
|
|
5 import java.nio.channels.SelectableChannel;
|
125
|
6 import java.nio.channels.SelectionKey;
|
|
7 import java.nio.channels.Selector;
|
|
8 import java.nio.channels.spi.AbstractSelector;
|
|
9 import java.nio.channels.spi.SelectorProvider;
|
|
10 import java.util.Set;
|
|
11
|
|
12 public class REPSelector extends Selector{
|
|
13
|
|
14 Selector selector;
|
|
15
|
|
16 public REPSelector(AbstractSelector selector) {
|
|
17 this.selector = selector;
|
|
18 }
|
|
19
|
143
|
20 public static REPSelector create() throws IOException{
|
125
|
21 if(REPServerSocketChannel.isSimulation){
|
|
22 return new SelectorSimulator();
|
|
23 }
|
|
24 return new REPSelector(SelectorProvider.provider().openSelector());
|
|
25 }
|
|
26
|
|
27 @Override
|
|
28 public void close() throws IOException {
|
|
29 selector.close();
|
|
30 }
|
|
31
|
|
32 @Override
|
|
33 public boolean isOpen() {
|
|
34 return selector.isOpen();
|
|
35 }
|
|
36
|
|
37 @Override
|
|
38 public Set<SelectionKey> keys() {
|
|
39 return selector.keys();
|
|
40 }
|
|
41
|
|
42 @Override
|
|
43 public SelectorProvider provider() {
|
|
44 return selector.provider();
|
|
45 }
|
|
46
|
|
47 @Override
|
|
48 public int select() throws IOException {
|
|
49 return selector.select();
|
|
50 }
|
|
51
|
|
52 @Override
|
|
53 public int select(long timeout) throws IOException {
|
|
54 return selector.select(timeout);
|
|
55 }
|
|
56
|
|
57 @Override
|
|
58 public int selectNow() throws IOException {
|
|
59 return selector.selectNow();
|
|
60 }
|
|
61
|
|
62 @Override
|
|
63 public Set<SelectionKey> selectedKeys() {
|
|
64 return selector.selectedKeys();
|
|
65 }
|
|
66
|
|
67 @Override
|
|
68 public Selector wakeup() {
|
|
69 return selector.wakeup();
|
|
70 }
|
|
71
|
143
|
72 public SelectionKey register(SelectableChannel ch, int ops, Object att){
|
|
73 return null;
|
|
74 }
|
|
75
|
|
76
|
125
|
77 }
|