01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import vicazh.hyperpool.Start;
05: import vicazh.hyperpool.stream.*;
06: import vicazh.hyperpool.stream.net.Stream;
07: import vicazh.hyperpool.stream.net.*;
08:
09: class MonitorConnection extends Connection {
10: MonitorConnection(Element element) {
11: super (element);
12: }
13:
14: protected Session getSession() {
15: return new MonitorSession(this );
16: }
17:
18: String client;
19:
20: public void setServer(OutputStream outputstream) throws IOException {
21: super .setServer(outputstream);
22: Socket socket = ((Stream) getServer()).getSocket();
23: client = socket == null ? Start.NAME : socket.getInetAddress()
24: .getCanonicalHostName().toLowerCase();
25: synchronized (element) {
26: ((vicazh.hyperpool.Element) element).sendAttribute(
27: MonitorServiceMBean.CLIENT, new MonitorItem(this ));
28: }
29: }
30:
31: public void remove(Session session) {
32: synchronized (element) {
33: if (!c)
34: ((vicazh.hyperpool.Element) element).sendAttribute(
35: MonitorServiceMBean.END, new MonitorItem(this ));
36: }
37: super .remove(session);
38: }
39:
40: private boolean c;
41:
42: public void close() {
43: super .close();
44: synchronized (element) {
45: ((vicazh.hyperpool.Element) element).sendAttribute(
46: MonitorServiceMBean.CLOSE, new MonitorItem(this ));
47: c = true;
48: }
49: }
50: }
|