KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > connector > soap > SOAPConnectorService


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ioc.connector.soap;
8
9 import java.rmi.RemoteException JavaDoc;
10
11 import org.jfox.ioc.connector.AbstractConnectorRemote;
12 import org.jfox.ioc.connector.ConnectorRemote;
13 import org.jfox.ioc.connector.Invocation;
14 import org.jfox.ioc.connector.ServerNode;
15
16 /**
17  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
18  */

19
20 public class SOAPConnectorService extends AbstractConnectorRemote implements ConnectorRemote{
21     // web server 的机器名和ip
22
private String JavaDoc httpHost = "localhost";
23     // web server 的 port
24
private int httpPort = 8080;
25     // 用来处理 xmlrpc 请求的 proxy servlet,需要在启动 web server 的时候配置
26
private String JavaDoc servletName = "xmlrpc/RPC2";
27 // private transient XmlRpcHandler client;
28
private SOAPConnectorRemote soapBinder = null;
29
30     public String JavaDoc getProtocol() throws RemoteException JavaDoc {
31         return "SOAP";
32     }
33
34     public String JavaDoc getHttpHost() {
35         return httpHost;
36     }
37
38     public int getHttpPort() {
39         return httpPort;
40     }
41
42     public String JavaDoc getServletName() {
43         return servletName;
44     }
45
46     public void setHttpHost(String JavaDoc httpHost) {
47         this.httpHost = httpHost;
48     }
49
50     public void setHttpPort(int httpPort) {
51         this.httpPort = httpPort;
52     }
53
54     protected void doStart() throws Exception JavaDoc {
55         logger.info("soap url: " + getSoapURL());
56         ServerNode.THE_NODE.registerConnector(getProtocol(),soapBinder);
57     }
58
59     protected void doStop() throws Exception JavaDoc {
60         ServerNode.THE_NODE.unregisterConnector(getProtocol());
61     }
62
63     protected void doInit() throws Exception JavaDoc {
64         soapBinder = new SOAPConnectorRemote(getSoapURL());
65     }
66
67     protected void doDestroy() throws Exception JavaDoc {
68         soapBinder = null;
69     }
70
71     public String JavaDoc getSoapURL() {
72         return "http://" + httpHost + ":" + httpPort + "/" + servletName;
73     }
74
75     /**
76      * 这个方法实际不会调用到,因为客户端得到的是 SOAPConnectorRemote
77      *
78      * @param invocation
79      * @return
80      * @throws java.rmi.RemoteException
81      */

82     public Object JavaDoc invoke(Invocation invocation) throws RemoteException JavaDoc {
83         return soapBinder.invoke(invocation);
84 /*
85     Vector params = new Vector(1);
86     params.add(marshelledObject(invocation));
87     try {
88       // handler 可以为任何字符串
89       return client.execute("xmlrpc",params);
90     }
91     catch(Exception e) {
92       throw new RemoteException(e.getMessage(),e);
93     }
94 */

95     }
96
97     public static void main(String JavaDoc[] args) {
98
99     }
100
101 }
Popular Tags