annotate rep/channel/REPSocketChannel.java @ 125:9faacdd6c9cb

*** empty log message ***
author pin
date Wed, 27 Aug 2008 17:54:47 +0900
parents 5b1a0574b406
children a4e2bceb9713
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
123
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
1 package rep.channel;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
2
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
3 import java.io.IOException;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
4 import java.nio.channels.ClosedChannelException;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
5 import java.nio.channels.SelectableChannel;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
6 import java.nio.channels.SelectionKey;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
7 import java.nio.channels.Selector;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
8 import java.nio.channels.SocketChannel;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
9 import java.nio.channels.spi.SelectorProvider;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
10
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
11 public class REPSocketChannel<P> extends SelectableChannel{
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
12
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
13 private SocketChannel sc;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
14
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
15 public REPSocketChannel(SocketChannel channel) {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
16 sc = channel;
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
17 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
18
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
19 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
20 public Object blockingLock() {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
21 return sc.blockingLock();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
22 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
23
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
24 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
25 public SelectableChannel configureBlocking(boolean block) throws IOException {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
26 return sc.configureBlocking(block);
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
27 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
28
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
29 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
30 public boolean isBlocking() {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
31 return sc.isBlocking();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
32 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
33
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
34 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
35 public boolean isRegistered() {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
36 return sc.isRegistered();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
37 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
38
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
39 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
40 public SelectionKey keyFor(Selector sel) {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
41 return sc.keyFor(sel);
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
42 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
43
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
44 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
45 public SelectorProvider provider() {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
46 return sc.provider();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
47 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
48
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
49 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
50 public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
51 return sc.register(sel, ops, att);
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
52 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
53
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
54 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
55 public int validOps() {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
56 return sc.validOps();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
57 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
58
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
59 @Override
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
60 protected void implCloseChannel() throws IOException {
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
61 sc.close();
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
62 }
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
63
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
64
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
65
5b1a0574b406 *** empty log message ***
pin
parents:
diff changeset
66 }