package vicazh.hyperpool.stream.net.http;
import java.io.*;
import vicazh.hyperpool.stream.net.Stream;
/**
* The trans service
*
* @author Victor Zhigunov
* @version 0.4.0
*/
public class TransService extends Service implements TransServiceMBean,
Serializable {
private String host;
public void setHost(String host) {
this.host = host;
}
public String getHost() {
return host;
}
private int port;
public void setPort(int port) {
this.port = port;
}
public int getPort() {
return port;
}
public OutputStream get(OutputStream outputstream) throws IOException {
Stream stream = (Stream) super.get(outputstream);
((ClientStream) stream.outputstream).head("CONNECT", host + ':' + port,
"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(TransServiceMBean.OPTIONS)) {
setPort(((TransService) value).getPort());
setHost(((TransService) value).getHost());
}
super.setAttribute(name, value);
}
}