annotate src/fdl/AcceptHandler.java @ 22:56e015e8f5dc

Testing TestLindaServer
author kono
date Tue, 19 Aug 2008 16:02:48 +0900
parents 0243987383b7
children fe338d497c72
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;
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
12
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
13 public AcceptHandler(TupleSpace tupleSpace) {
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
14 // 読みこんだデータを格納するためのリストの初期化
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
15 this.tupleSpace = tupleSpace;
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
16 }
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
17
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
18 public void handle(SelectionKey key)
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
19 throws ClosedChannelException, IOException {
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
20 ServerSocketChannel serverChannel
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
21 = (ServerSocketChannel)key.channel();
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
22
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
23 // アクセプト処理
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
24 SocketChannel channel = serverChannel.accept();
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
25 channel.configureBlocking(false);
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
26 System.out.println("Server: accepted "+channel.socket());
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
27
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
28 tupleSpace.newUser();
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
29
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
30 // 入出力用のハンドラを生成し,アタッチする
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
31 // 監視する操作は読み込みのみ
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
32 channel.register(key.selector(),
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
33 SelectionKey.OP_READ,
22
56e015e8f5dc Testing TestLindaServer
kono
parents: 19
diff changeset
34 new IOHandler(tupleSpace,channel));
3
ae7e0e92c651 *** empty log message ***
fuchita
parents: 0
diff changeset
35 }
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
36
0
083a0b5e12cc Apply Debug Interface version start
fuchita
parents:
diff changeset
37 }