SetRouteService.java :  » Net » hyperpool-0.4.0 » vicazh » hyperpool » stream » net » http » Java Open Source

Java Open Source » Net » hyperpool 0.4.0 
hyperpool 0.4.0 » vicazh » hyperpool » stream » net » http » SetRouteService.java
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);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.