KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > webservice > server > JBossRPCInvocation


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.webservice.server;
8
9 import org.jboss.axis.MessageContext;
10 import org.jboss.axis.description.OperationDesc;
11 import org.jboss.axis.description.ParameterDesc;
12 import org.jboss.axis.description.ServiceDesc;
13 import org.jboss.axis.message.SOAPEnvelopeAxisImpl;
14 import org.jboss.axis.providers.java.RPCInvocation;
15 import org.jboss.axis.providers.java.RPCProvider;
16 import org.jboss.logging.Logger;
17 import org.jboss.webservice.PortComponentInfo;
18 import org.jboss.webservice.deployment.OperationDescription;
19 import org.jboss.webservice.deployment.ServiceDescription;
20
21 import javax.xml.namespace.QName JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 /**
26  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
27  */

28 public class JBossRPCInvocation extends RPCInvocation
29 {
30    private Logger log = Logger.getLogger(JBossRPCInvocation.class);
31
32    public JBossRPCInvocation(RPCProvider rpcProvider, MessageContext messageContext, SOAPEnvelopeAxisImpl soapEnvelopeDirty, SOAPEnvelopeAxisImpl soapEnvelopeDirty1, Object JavaDoc o)
33    {
34       super(rpcProvider, messageContext, soapEnvelopeDirty, soapEnvelopeDirty1, o);
35    }
36
37    public JBossRPCInvocation(RPCInvocation rpcInvocation)
38    {
39       super(rpcInvocation);
40    }
41
42    public OperationDesc getOperation(ServiceDesc serviceDesc, QName JavaDoc qname)
43    {
44       OperationDesc op = null;
45       op = serviceDesc.getOperationByElementQName(qname);
46
47       RPCProvider provider = getProvider();
48
49       if (provider instanceof InvokerProvider)
50       {
51          PortComponentInfo pcInfo = ((InvokerProvider)provider).getPortComponentInfo();
52          ServiceDescription svcDesc = pcInfo.getServiceDescription();
53          OperationDescription custOp = svcDesc.getOperation(qname.getLocalPart());
54          if (custOp != null)
55          {
56             String JavaDoc opName = custOp.getJavaName();
57             QName JavaDoc returnName = custOp.getReturnQName();
58             QName JavaDoc returnType = custOp.getReturnType();
59
60             op.setName(opName);
61             op.setReturnQName(returnName);
62             op.setReturnType(returnType);
63
64             // set parameters if there are any
65
Iterator JavaDoc itr = custOp.getParameters();
66             ArrayList JavaDoc paramList = new ArrayList JavaDoc();
67
68             while (itr.hasNext())
69             {
70                OperationDescription.Parameter param = (OperationDescription.Parameter)itr.next();
71                // no namespace uri for param name
72
QName JavaDoc paramName = new QName JavaDoc("", param.getName());
73                QName JavaDoc paramType = param.getType();
74                String JavaDoc mode = param.getMode();
75                ParameterDesc paramDesc = new ParameterDesc(paramName, convertMode(mode), paramType);
76                paramList.add(paramDesc);
77             }
78
79             if (paramList.size() > 0)
80             {
81                op.setParameters(paramList);
82             }
83             // no faults in Operation currently
84
}
85       }
86
87       return op;
88    }
89
90    private byte convertMode(String JavaDoc mode)
91    {
92       if ("INOUT".equals(mode))
93       {
94          return ParameterDesc.INOUT;
95       }
96       else if ("OUT".equals(mode))
97       {
98          return ParameterDesc.OUT;
99       }
100       else
101       {
102          return ParameterDesc.IN;
103       }
104    }
105
106 }
107
Popular Tags