Package vicazh.hyperpool.stream.net.http

Source Code of vicazh.hyperpool.stream.net.http.TransService

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);
  }
}
TOP

Related Classes of vicazh.hyperpool.stream.net.http.TransService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.