30 import java.io.OutputStream; |
30 import java.io.OutputStream; |
31 import java.lang.reflect.Method; |
31 import java.lang.reflect.Method; |
32 import java.util.HashMap; |
32 import java.util.HashMap; |
33 import java.util.Map; |
33 import java.util.Map; |
34 |
34 |
35 import javax.xml.namespace.QName; |
|
36 import javax.xml.ws.WebServiceFeature; |
35 import javax.xml.ws.WebServiceFeature; |
37 |
36 |
38 import com.sun.xml.internal.org.jvnet.ws.message.MessageContext; |
37 import com.oracle.webservices.internal.api.databinding.JavaCallInfo; |
39 |
38 import com.oracle.webservices.internal.api.message.MessageContext; |
40 import com.sun.xml.internal.ws.api.databinding.EndpointCallBridge; |
39 import com.sun.xml.internal.ws.api.databinding.EndpointCallBridge; |
41 import com.sun.xml.internal.ws.api.databinding.JavaCallInfo; |
|
42 import com.sun.xml.internal.ws.api.databinding.WSDLGenInfo; |
40 import com.sun.xml.internal.ws.api.databinding.WSDLGenInfo; |
43 import com.sun.xml.internal.ws.api.databinding.Databinding; |
41 import com.sun.xml.internal.ws.api.databinding.Databinding; |
44 import com.sun.xml.internal.ws.api.databinding.DatabindingConfig; |
42 import com.sun.xml.internal.ws.api.databinding.DatabindingConfig; |
45 import com.sun.xml.internal.ws.api.databinding.ClientCallBridge; |
43 import com.sun.xml.internal.ws.api.databinding.ClientCallBridge; |
46 import com.sun.xml.internal.ws.api.message.Message; |
44 import com.sun.xml.internal.ws.api.message.Message; |
|
45 import com.sun.xml.internal.ws.api.message.MessageContextFactory; |
47 import com.sun.xml.internal.ws.api.message.Packet; |
46 import com.sun.xml.internal.ws.api.message.Packet; |
48 import com.sun.xml.internal.ws.api.model.MEP; |
47 import com.sun.xml.internal.ws.api.model.MEP; |
49 import com.sun.xml.internal.ws.api.model.SEIModel; |
48 import com.sun.xml.internal.ws.api.model.SEIModel; |
|
49 import com.sun.xml.internal.ws.api.model.WSDLOperationMapping; |
50 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
50 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
51 import com.sun.xml.internal.ws.api.pipe.Codec; |
51 import com.sun.xml.internal.ws.api.pipe.Codec; |
52 import com.sun.xml.internal.ws.api.pipe.ContentType; |
52 import com.sun.xml.internal.ws.api.pipe.ContentType; |
53 import com.sun.xml.internal.ws.binding.BindingImpl; |
53 import com.sun.xml.internal.ws.binding.BindingImpl; |
54 import com.sun.xml.internal.ws.client.sei.StubAsyncHandler; |
54 import com.sun.xml.internal.ws.client.sei.StubAsyncHandler; |
55 import com.sun.xml.internal.ws.client.sei.StubHandler; |
55 import com.sun.xml.internal.ws.client.sei.StubHandler; |
56 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl; |
56 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl; |
57 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
57 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
58 import com.sun.xml.internal.ws.model.RuntimeModeler; |
58 import com.sun.xml.internal.ws.model.RuntimeModeler; |
59 import com.sun.xml.internal.ws.server.sei.TieHandler; |
59 import com.sun.xml.internal.ws.server.sei.TieHandler; |
60 import com.sun.xml.internal.ws.util.QNameMap; |
|
61 import com.sun.xml.internal.ws.wsdl.ActionBasedOperationSignature; |
60 import com.sun.xml.internal.ws.wsdl.ActionBasedOperationSignature; |
62 import com.sun.xml.internal.ws.wsdl.DispatchException; |
61 import com.sun.xml.internal.ws.wsdl.DispatchException; |
63 import com.sun.xml.internal.ws.wsdl.OperationDispatcher; |
62 import com.sun.xml.internal.ws.wsdl.OperationDispatcher; |
64 |
63 |
65 /** |
64 /** |
66 * WsRuntimeImpl is the databinding processor built on SEIModel |
65 * WsRuntimeImpl is the databinding processor built on SEIModel |
67 * |
66 * |
68 * @author shih-chang.chen@oracle.com |
67 * @author shih-chang.chen@oracle.com |
69 */ |
68 */ |
70 public class DatabindingImpl implements Databinding, com.sun.xml.internal.org.jvnet.ws.databinding.Databinding { |
69 public class DatabindingImpl implements Databinding { |
71 |
70 |
72 AbstractSEIModelImpl seiModel; |
71 AbstractSEIModelImpl seiModel; |
73 Map<Method, StubHandler> stubHandlers; |
72 Map<Method, StubHandler> stubHandlers; |
74 QNameMap<TieHandler> wsdlOpMap = new QNameMap<TieHandler>(); |
73 // QNameMap<TieHandler> wsdlOpMap = new QNameMap<TieHandler>(); |
|
74 Map<JavaMethodImpl, TieHandler> wsdlOpMap = new HashMap<JavaMethodImpl, TieHandler>(); |
75 Map<Method, TieHandler> tieHandlers = new HashMap<Method, TieHandler>(); |
75 Map<Method, TieHandler> tieHandlers = new HashMap<Method, TieHandler>(); |
76 OperationDispatcher operationDispatcher; |
76 OperationDispatcher operationDispatcher; |
77 OperationDispatcher operationDispatcherNoWsdl; |
77 OperationDispatcher operationDispatcherNoWsdl; |
78 boolean clientConfig = false; |
78 boolean clientConfig = false; |
79 Codec codec; |
79 Codec codec; |
|
80 MessageContextFactory packetFactory = null; |
80 |
81 |
81 public DatabindingImpl(DatabindingProviderImpl p, DatabindingConfig config) { |
82 public DatabindingImpl(DatabindingProviderImpl p, DatabindingConfig config) { |
82 RuntimeModeler modeler = new RuntimeModeler(config); |
83 RuntimeModeler modeler = new RuntimeModeler(config); |
83 modeler.setClassLoader(config.getClassLoader()); |
84 modeler.setClassLoader(config.getClassLoader()); |
84 seiModel = modeler.buildRuntimeModel(); |
85 seiModel = modeler.buildRuntimeModel(); |
85 WSDLPort wsdlport = config.getWsdlPort(); |
86 WSDLPort wsdlport = config.getWsdlPort(); |
|
87 packetFactory = new MessageContextFactory(seiModel.getWSBinding().getFeatures()); |
86 clientConfig = isClientConfig(config); |
88 clientConfig = isClientConfig(config); |
87 if ( clientConfig ) initStubHandlers(); |
89 if ( clientConfig ) initStubHandlers(); |
88 seiModel.setDatabinding(this); |
90 seiModel.setDatabinding(this); |
89 if (wsdlport != null) freeze(wsdlport); |
91 if (wsdlport != null) freeze(wsdlport); |
90 if (operationDispatcher == null) operationDispatcherNoWsdl = new OperationDispatcher(null, seiModel.getWSBinding(), seiModel); |
92 if (operationDispatcher == null) operationDispatcherNoWsdl = new OperationDispatcher(null, seiModel.getWSBinding(), seiModel); |
91 // if(!clientConfig) { |
93 // if(!clientConfig) { |
92 for(JavaMethodImpl jm: seiModel.getJavaMethods()) if (!jm.isAsync()) { |
94 for(JavaMethodImpl jm: seiModel.getJavaMethods()) if (!jm.isAsync()) { |
93 TieHandler th = new TieHandler(jm, seiModel.getWSBinding()); |
95 TieHandler th = new TieHandler(jm, seiModel.getWSBinding(), packetFactory); |
94 wsdlOpMap.put(jm.getOperationQName(), th); |
96 wsdlOpMap.put(jm, th); |
95 tieHandlers.put(th.getMethod(), th); |
97 tieHandlers.put(th.getMethod(), th); |
96 } |
98 } |
97 // } |
99 // } |
98 } |
100 } |
99 |
101 |
119 Map<ActionBasedOperationSignature, JavaMethodImpl> syncs = new HashMap<ActionBasedOperationSignature, JavaMethodImpl>(); |
121 Map<ActionBasedOperationSignature, JavaMethodImpl> syncs = new HashMap<ActionBasedOperationSignature, JavaMethodImpl>(); |
120 // fill in methodHandlers. |
122 // fill in methodHandlers. |
121 // first fill in sychronized versions |
123 // first fill in sychronized versions |
122 for (JavaMethodImpl m : seiModel.getJavaMethods()) { |
124 for (JavaMethodImpl m : seiModel.getJavaMethods()) { |
123 if (!m.getMEP().isAsync) { |
125 if (!m.getMEP().isAsync) { |
124 StubHandler handler = new StubHandler(m); |
126 StubHandler handler = new StubHandler(m, packetFactory); |
125 syncs.put(m.getOperationSignature(), m); |
127 syncs.put(m.getOperationSignature(), m); |
126 stubHandlers.put(m.getMethod(), handler); |
128 stubHandlers.put(m.getMethod(), handler); |
127 } |
129 } |
128 } |
130 } |
129 for (JavaMethodImpl jm : seiModel.getJavaMethods()) { |
131 for (JavaMethodImpl jm : seiModel.getJavaMethods()) { |
130 JavaMethodImpl sync = syncs.get(jm.getOperationSignature()); |
132 JavaMethodImpl sync = syncs.get(jm.getOperationSignature()); |
131 if (jm.getMEP() == MEP.ASYNC_CALLBACK || jm.getMEP() == MEP.ASYNC_POLL) { |
133 if (jm.getMEP() == MEP.ASYNC_CALLBACK || jm.getMEP() == MEP.ASYNC_POLL) { |
132 Method m = jm.getMethod(); |
134 Method m = jm.getMethod(); |
133 StubAsyncHandler handler = new StubAsyncHandler(jm, sync); |
135 StubAsyncHandler handler = new StubAsyncHandler(jm, sync, packetFactory); |
134 stubHandlers.put(m, handler); |
136 stubHandlers.put(m, handler); |
135 } |
137 } |
136 } |
138 } |
137 } |
139 } |
138 |
140 |
139 public QName resolveOperationQName(Packet req) throws DispatchException { |
141 public JavaMethodImpl resolveJavaMethod(Packet req) throws DispatchException { |
140 return (operationDispatcher != null)? |
142 WSDLOperationMapping m = req.getWSDLOperationMapping(); |
141 operationDispatcher.getWSDLOperationQName(req): |
143 if (m == null) m = (operationDispatcher != null) ? |
142 operationDispatcherNoWsdl.getWSDLOperationQName(req); |
144 operationDispatcher.getWSDLOperationMapping(req): |
|
145 operationDispatcherNoWsdl.getWSDLOperationMapping(req); |
|
146 return (JavaMethodImpl) m.getJavaMethod(); |
143 } |
147 } |
144 |
148 |
145 public JavaCallInfo deserializeRequest(Packet req) { |
149 public JavaCallInfo deserializeRequest(Packet req) { |
146 JavaCallInfo call = new JavaCallInfo(); |
150 com.sun.xml.internal.ws.api.databinding.JavaCallInfo call = new com.sun.xml.internal.ws.api.databinding.JavaCallInfo(); |
147 try { |
151 try { |
148 QName wsdlOp = resolveOperationQName(req); |
152 JavaMethodImpl wsdlOp = resolveJavaMethod(req); |
149 TieHandler tie = wsdlOpMap.get(wsdlOp); |
153 TieHandler tie = wsdlOpMap.get(wsdlOp); |
150 call.setMethod(tie.getMethod()); |
154 call.setMethod(tie.getMethod()); |
151 Object[] args = tie.readRequest(req.getMessage()); |
155 Object[] args = tie.readRequest(req.getMessage()); |
152 call.setParameters(args); |
156 call.setParameters(args); |
153 } catch (DispatchException e) { |
157 } catch (DispatchException e) { |
226 |
233 |
227 public void decode( InputStream in, String ct, Packet p ) throws IOException{ |
234 public void decode( InputStream in, String ct, Packet p ) throws IOException{ |
228 getCodec().decode(in, ct, p); |
235 getCodec().decode(in, ct, p); |
229 } |
236 } |
230 |
237 |
231 public com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo createJavaCallInfo(Method method, Object[] args) { |
238 public com.oracle.webservices.internal.api.databinding.JavaCallInfo createJavaCallInfo(Method method, Object[] args) { |
232 return new JavaCallInfo(method, args); |
239 return new com.sun.xml.internal.ws.api.databinding.JavaCallInfo(method, args); |
233 } |
240 } |
234 |
241 |
235 public MessageContext serializeRequest(com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo call) { |
242 public com.oracle.webservices.internal.api.databinding.JavaCallInfo deserializeResponse( |
236 return serializeRequest((JavaCallInfo)call); |
243 MessageContext message, com.oracle.webservices.internal.api.databinding.JavaCallInfo call) { |
237 } |
|
238 |
|
239 public com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo deserializeResponse( |
|
240 MessageContext message, com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo call) { |
|
241 return deserializeResponse((Packet)message, (JavaCallInfo)call); |
244 return deserializeResponse((Packet)message, (JavaCallInfo)call); |
242 } |
245 } |
243 |
246 |
244 public com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo deserializeRequest(MessageContext message) { |
247 public com.oracle.webservices.internal.api.databinding.JavaCallInfo deserializeRequest(MessageContext message) { |
245 return deserializeRequest((Packet)message); |
248 return deserializeRequest((Packet)message); |
246 } |
249 } |
247 |
250 |
248 public MessageContext serializeResponse(com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo call) { |
251 public MessageContextFactory getMessageContextFactory() { |
249 return serializeResponse((JavaCallInfo)call); |
252 return packetFactory; |
250 } |
253 } |
251 } |
254 } |