1 17 package org.openejb.client; 18 19 import java.util.Properties ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.OutputStream ; 23 import java.net.HttpURLConnection ; 24 import java.net.URL ; 25 26 29 public class HttpConnectionFactory implements ConnectionFactory { 30 31 public void init(Properties props) { 32 } 33 34 public Connection getConnection(ServerMetaData server) throws IOException { 35 return new HttpConnection(server); 36 } 37 38 public static class HttpConnection implements Connection { 39 40 private final ServerMetaData server; 41 private HttpURLConnection httpURLConnection; 42 43 public HttpConnection(ServerMetaData server) throws IOException { 44 this.server = server; 45 String host = "localhost"; 46 URL url = server.getLocation().toURL(); 49 httpURLConnection = (HttpURLConnection )url.openConnection(); 50 httpURLConnection.setRequestProperty("Content-Type","application/ejb"); 51 httpURLConnection.setDoOutput(true); 52 httpURLConnection.setRequestProperty("Content-Type","application/ejb"); 53 httpURLConnection.connect(); 54 } 55 56 public void close() throws IOException { 57 httpURLConnection.disconnect(); 58 } 59 60 public InputStream getInputStream() throws IOException { 61 return httpURLConnection.getInputStream(); 62 } 63 64 public OutputStream getOuputStream() throws IOException { 65 return httpURLConnection.getOutputStream(); 66 } 67 } 68 } 69 | Popular Tags |