01: package vicazh.hyperpool.stream;
02:
03: import java.io.*;
04: import java.util.*;
05: import vicazh.hyperpool.Start;
06:
07: /**
08: * This class is the superclass of all stream services
09: *
10: * @author Victor Zhigunov
11: * @version 0.4.0
12: */
13: public class Service extends vicazh.hyperpool.Service implements
14: Element {
15: public OutputStream get(OutputStream outputstream)
16: throws IOException {
17: Connection connection = getConnection();
18: connection.setServer(outputstream);
19: connection.setClient(getElement() == null ? null
20: : ((Element) getElement()).get(connection.getServer()));
21: add(connection);
22: return connection.getClient();
23: }
24:
25: public Connection getConnection() {
26: return new Connection(this );
27: }
28:
29: transient private List<Connection> connections = new ArrayList<Connection>();
30:
31: public void add(Connection connection) {
32: connections.add(connection);
33: Start.logger.finest(getClass().getName() + ":connections.size:"
34: + connections.size());
35: }
36:
37: public void remove(Connection connection) {
38: connections.remove(connection);
39: Start.logger.finest(getClass().getName() + ":connections.size:"
40: + connections.size());
41: }
42:
43: public List<Connection> getConnections() {
44: return connections;
45: }
46: }
|