01: package vicazh.hyperpool.stream;
02:
03: import java.io.*;
04: import vicazh.hyperpool.*;
05:
06: /**
07: * The container service
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class ContainerService extends Service {
13: public OutputStream get(OutputStream outputstream)
14: throws IOException {
15: Connection connection = getConnection();
16: connection.setServer(outputstream);
17: connection.setClient(internal.get(connection.getServer()));
18: add(connection);
19: return connection.getClient();
20: }
21:
22: private Selector internal;
23:
24: public Selector getInternal() {
25: return internal;
26: }
27:
28: public void setInternal(Selector internal) {
29: this .internal = internal;
30: }
31:
32: private Service external;
33:
34: public Service getExternal() {
35: return external;
36: }
37:
38: public void setExternal(Service external) {
39: this .external = external;
40: }
41:
42: public void start() throws Exception {
43: external.start();
44: internal.start();
45: }
46:
47: public void stop() throws Exception {
48: external.stop();
49: internal.stop();
50: }
51:
52: public void setElement(ElementMBean element) {
53: if (external != null)
54: external.setElement(element);
55: super .setElement(element);
56: }
57:
58: public int getID() {
59: return external.getID();
60: }
61: }
|