package vicazh.hyperpool.stream.net.http;
import java.io.*;
import vicazh.hyperpool.stream.net.Stream;
/**
* The set route service
*
* @author Victor Zhigunov
* @version 0.4.0
*/
public class SetRouteService extends Service implements SetRouteServiceMBean {
private String address;
public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
public OutputStream get(OutputStream outputstream) throws IOException {
Stream stream = (Stream) super.get(outputstream);
((ClientStream) stream.outputstream).head("CONNECT", address,
"HTTP/1.0");
((ClientStream) stream.outputstream).header();
stream.flush();
return stream;
}
public Connection getConnection() {
return new SetRouteConnection(this);
}
public void setAttribute(String name, Object value) throws Exception {
if (name.equals(SetRouteServiceMBean.PATH))
setAddress((String) value);
super.setAttribute(name, value);
}
}