Mercurial > hg > FederatedLinda
annotate src/fdl/AcceptHandler.java @ 35:fe338d497c72 meta-comdebug-wokred
FederatedLinda was static singleton. It does not work on Thread based test.
author | kono |
---|---|
date | Sun, 24 Aug 2008 19:07:28 +0900 |
parents | 56e015e8f5dc |
children | 046feb56a196 |
rev | line source |
---|---|
0 | 1 |
2 package fdl; | |
3 import java.io.IOException; | |
4 import java.nio.channels.ClosedChannelException; | |
5 import java.nio.channels.SelectionKey; | |
6 import java.nio.channels.ServerSocketChannel; | |
7 import java.nio.channels.SocketChannel; | |
8 | |
17 | 9 public class AcceptHandler implements TupleHandler { |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
10 |
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
11 public TupleSpace tupleSpace; |
35
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
12 public ServerSocketChannel ss; |
0 | 13 |
35
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
14 public AcceptHandler(ServerSocketChannel ss, TupleSpace tupleSpace) { |
0 | 15 // 読みこんだデータを格納するためのリストの初期化 |
35
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
16 this.tupleSpace = tupleSpace; |
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
17 this.ss = ss; |
0 | 18 } |
19 | |
20 public void handle(SelectionKey key) | |
21 throws ClosedChannelException, IOException { | |
22 ServerSocketChannel serverChannel | |
23 = (ServerSocketChannel)key.channel(); | |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
24 |
35
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
25 if (ss!=serverChannel) { |
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
26 System.err.println("Wrong server socket channel."); |
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
22
diff
changeset
|
27 } |
0 | 28 // アクセプト処理 |
29 SocketChannel channel = serverChannel.accept(); | |
30 channel.configureBlocking(false); | |
3 | 31 System.out.println("Server: accepted "+channel.socket()); |
32 | |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
33 tupleSpace.newUser(); |
0 | 34 |
35 // 入出力用のハンドラを生成し,アタッチする | |
36 // 監視する操作は読み込みのみ | |
37 channel.register(key.selector(), | |
38 SelectionKey.OP_READ, | |
22 | 39 new IOHandler(tupleSpace,channel)); |
3 | 40 } |
19
0243987383b7
Meta Protocol Engine and sample implementation of event logger.
kono
parents:
17
diff
changeset
|
41 |
0 | 42 } |