01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import vicazh.hyperpool.stream.net.Stream;
05:
06: /**
07: * The trans service
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class TransService extends Service implements TransServiceMBean,
13: Serializable {
14: private String host;
15:
16: public void setHost(String host) {
17: this .host = host;
18: }
19:
20: public String getHost() {
21: return host;
22: }
23:
24: private int port;
25:
26: public void setPort(int port) {
27: this .port = port;
28: }
29:
30: public int getPort() {
31: return port;
32: }
33:
34: public OutputStream get(OutputStream outputstream)
35: throws IOException {
36: Stream stream = (Stream) super .get(outputstream);
37: ((ClientStream) stream.outputstream).head("CONNECT", host + ':'
38: + port, "HTTP/1.0");
39: ((ClientStream) stream.outputstream).header();
40: stream.flush();
41: return stream;
42: }
43:
44: public Connection getConnection() {
45: return new SetRouteConnection(this );
46: }
47:
48: public void setAttribute(String name, Object value)
49: throws Exception {
50: if (name.equals(TransServiceMBean.OPTIONS)) {
51: setPort(((TransService) value).getPort());
52: setHost(((TransService) value).getHost());
53: }
54: super.setAttribute(name, value);
55: }
56: }
|