Package vicazh.hyperpool.stream.net.http

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

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

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

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.