01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import java.util.*;
05: import vicazh.hyperpool.Start;
06: import vicazh.hyperpool.stream.*;
07:
08: /**
09: * This class is the superclass of all http connections
10: *
11: * @author Victor Zhigunov
12: * @version 0.4.0
13: */
14: public class Connection extends vicazh.hyperpool.stream.net.Connection {
15: public Connection() {
16: }
17:
18: /**
19: * @param element
20: * parent element
21: */
22: public Connection(Element element) {
23: super (element);
24: }
25:
26: public void setClient(OutputStream outputstream) throws IOException {
27: Session session = (Session) sessions.get(sessions.size() - 1);
28: session.setClient(outputstream);
29: super .setClient((OutputStream) session.getClient());
30: }
31:
32: public void setServer(OutputStream outputstream) throws IOException {
33: Session session = getSession();
34: session.setServer(outputstream);
35: add(session);
36: super .setServer((OutputStream) session.getServer());
37: }
38:
39: private List<Session> sessions = new ArrayList<Session>();
40:
41: /**
42: * Add session
43: */
44: public void add(Session session) {
45: sessions.add(session);
46: Start.logger.finest(element.getClass().getName()
47: + ":sessions.size:" + sessions.size());
48: }
49:
50: /**
51: * Remove session
52: */
53: public void remove(Session session) {
54: sessions.remove(session);
55: Start.logger.finest(element.getClass().getName()
56: + ":sessions.size:" + sessions.size());
57: }
58:
59: /**
60: * Return connections session
61: *
62: * @return connections session
63: */
64: protected Session getSession() {
65: return new Session(this );
66: }
67:
68: /**
69: * Return connections sessions
70: *
71: * @return connections sessions
72: */
73: public List<Session> getSessions() {
74: return sessions;
75: }
76: }
|