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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
1
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
2 package fdl;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
3 import java.io.IOException;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
4 import java.nio.channels.ClosedChannelException;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
5 import java.nio.channels.SelectionKey;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
6 import java.nio.channels.ServerSocketChannel;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
7 import java.nio.channels.SocketChannel;
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
8
17
609b288f47f9 *** empty log message ***
kono
parents: 16
diff changeset
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
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
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
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
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
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
18 }
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
19
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
20 public void handle(SelectionKey key)
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
21 throws ClosedChannelException, IOException {
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
22 ServerSocketChannel serverChannel
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
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
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
28 // アクセプト処理
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
29 SocketChannel channel = serverChannel.accept();
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
30 channel.configureBlocking(false);
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
31 System.out.println("Server: accepted "+channel.socket());
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
32
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
33 tupleSpace.newUser();
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
34
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
35 // 入出力用のハンドラを生成し,アタッチする
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
36 // 監視する操作は読み込みのみ
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
37 channel.register(key.selector(),
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
38 SelectionKey.OP_READ,
22
56e015e8f5dc Testing TestLindaServer
kono
parents: 19
diff changeset
39 new IOHandler(tupleSpace,channel));
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
40 }
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
41
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
42 }