01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import vicazh.hyperpool.stream.net.Stream;
05:
06: /**
07: * The set route service
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class SetRouteService extends Service implements
13: SetRouteServiceMBean {
14: private String address;
15:
16: public void setAddress(String address) {
17: this .address = address;
18: }
19:
20: public String getAddress() {
21: return address;
22: }
23:
24: public OutputStream get(OutputStream outputstream)
25: throws IOException {
26: Stream stream = (Stream) super .get(outputstream);
27: ((ClientStream) stream.outputstream).head("CONNECT", address,
28: "HTTP/1.0");
29: ((ClientStream) stream.outputstream).header();
30: stream.flush();
31: return stream;
32: }
33:
34: public Connection getConnection() {
35: return new SetRouteConnection(this );
36: }
37:
38: public void setAttribute(String name, Object value)
39: throws Exception {
40: if (name.equals(SetRouteServiceMBean.PATH))
41: setAddress((String) value);
42: super.setAttribute(name, value);
43: }
44: }
|