123
|
1 package rep.channel;
|
|
2
|
|
3 import java.io.IOException;
|
137
|
4 import java.net.Socket;
|
136
|
5 import java.nio.ByteBuffer;
|
123
|
6 import java.nio.channels.ClosedChannelException;
|
|
7 import java.nio.channels.SelectableChannel;
|
|
8 import java.nio.channels.SelectionKey;
|
|
9 import java.nio.channels.Selector;
|
|
10 import java.nio.channels.SocketChannel;
|
140
|
11 import java.nio.channels.ServerSocketChannel;
|
123
|
12 import java.nio.channels.spi.SelectorProvider;
|
|
13
|
|
14 public class REPSocketChannel<P> extends SelectableChannel{
|
|
15
|
|
16 private SocketChannel sc;
|
|
17
|
|
18 public REPSocketChannel(SocketChannel channel) {
|
|
19 sc = channel;
|
|
20 }
|
|
21
|
|
22 @Override
|
|
23 public Object blockingLock() {
|
|
24 return sc.blockingLock();
|
|
25 }
|
|
26
|
|
27 @Override
|
|
28 public SelectableChannel configureBlocking(boolean block) throws IOException {
|
|
29 return sc.configureBlocking(block);
|
|
30 }
|
|
31
|
|
32 @Override
|
|
33 public boolean isBlocking() {
|
|
34 return sc.isBlocking();
|
|
35 }
|
|
36
|
|
37 @Override
|
|
38 public boolean isRegistered() {
|
|
39 return sc.isRegistered();
|
|
40 }
|
|
41
|
|
42 @Override
|
|
43 public SelectionKey keyFor(Selector sel) {
|
|
44 return sc.keyFor(sel);
|
|
45 }
|
|
46
|
|
47 @Override
|
|
48 public SelectorProvider provider() {
|
|
49 return sc.provider();
|
|
50 }
|
|
51
|
|
52 @Override
|
|
53 public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException {
|
|
54 return sc.register(sel, ops, att);
|
|
55 }
|
|
56
|
|
57 @Override
|
|
58 public int validOps() {
|
|
59 return sc.validOps();
|
|
60 }
|
|
61
|
|
62 @Override
|
|
63 protected void implCloseChannel() throws IOException {
|
|
64 sc.close();
|
|
65 }
|
136
|
66
|
|
67 public long read(ByteBuffer header) {
|
|
68 // TODO Auto-generated method stub
|
|
69 return 0;
|
|
70 }
|
|
71
|
|
72 public void write(ByteBuffer buffer) throws IOException {
|
|
73 // TODO Auto-generated method stub
|
|
74
|
|
75 }
|
|
76
|
|
77 public boolean finishConnect() {
|
|
78 // TODO Auto-generated method stub
|
|
79 return false;
|
|
80 }
|
137
|
81
|
|
82 public Socket socket() {
|
|
83 // TODO Auto-generated method stub
|
|
84 return null;
|
|
85 }
|
140
|
86
|
|
87 public REPSocketChannel<P> create() throws IOException {
|
|
88 if (REPServerSocketChannel.isSimulation) {
|
|
89 return new ChannelSimulator<P>(null);
|
|
90 } else {
|
|
91 return new REPSocketChannel<P>(SocketChannel.open());
|
|
92 }
|
|
93 }
|
123
|
94
|
|
95
|
|
96
|
|
97 } |