1 16 17 package samples.transport.tcp; 18 19 import org.apache.axis.AxisEngine; 20 import org.apache.axis.MessageContext; 21 import org.apache.axis.client.Call; 22 import org.apache.axis.client.Transport; 23 import org.apache.axis.components.logger.LogFactory; 24 import org.apache.commons.logging.Log; 25 26 import java.net.URL ; 27 28 34 public class TCPTransport extends Transport 35 { 36 static Log log = 37 LogFactory.getLog(TCPTransport.class.getName()); 38 39 private String host; 40 private String port; 41 42 public TCPTransport () { 43 transportName = "tcp"; 44 } 45 46 public TCPTransport (String host, String port) { 47 transportName = "tcp"; 48 this.host = host; 49 this.port = port; 50 } 51 52 55 static public String HOST = "tcp.host"; 56 static public String PORT = "tcp.port"; 57 58 64 public void setupMessageContextImpl(MessageContext mc, 65 Call call, 66 AxisEngine engine) 67 { 68 try { 69 String urlString = mc.getStrProp(MessageContext.TRANS_URL); 70 if (urlString != null) { 71 URL url = new URL (urlString); 72 host = url.getHost(); 73 port = new Integer (url.getPort()).toString(); 74 } 75 } catch (java.net.MalformedURLException e) { 76 } 78 79 if (host != null) mc.setProperty(HOST, host); 80 if (port != null) mc.setProperty(PORT, port); 81 82 log.debug( "Port = " + mc.getStrProp(PORT)); 83 log.debug( "Host = " + mc.getStrProp(HOST)); 84 85 94 } 95 } 96 97 | Popular Tags |