Debian Codegraph @

samples/transport/tcp/TCPTransport.java

raw
1 /*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
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 /**
29 *
30 * @author Rob Jellinghaus ([email protected])
31 * @author Doug Davis ([email protected])
32 * @author Glen Daniels ([email protected])
33 */
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 /**
53 * TCP properties
54 */
55 static public String HOST = "tcp.host";
56 static public String PORT = "tcp.port";
57
58 /**
59 * Set up any transport-specific derived properties in the message context.
60 * @param context the context to set up
61 * @param message the client service instance
62 * @param engine the engine containing the registries
63 */
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 // Do nothing here?
77 }
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 // kind of ugly... fake up a "http://host:port/" url to send down the chain
86 // ROBJ TODO: clean this up so we use TCP transport properties all the way down
87 // use serviceclient properties if any, otherwise use ours
88 /*
89 String url = "http://"+serv.get(HOST)+":"+serv.get(PORT);
90
91 log.debug( "TCPTransport set URL to '" + url + "'");
92 mc.setProperty(MessageContext.TRANS_URL, url);
93 */
94 }
95 }
96