Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.ws.client.sei;
28 import com.oracle.webservices.internal.api.databinding.JavaCallInfo;
29 import com.sun.xml.internal.ws.api.message.Message;
30 import com.sun.xml.internal.ws.api.message.Packet;
31 import com.sun.xml.internal.ws.client.RequestContext;
32 import com.sun.xml.internal.ws.client.ResponseContextReceiver;
33 import com.sun.xml.internal.ws.encoding.soap.DeserializationException;
34 import com.sun.xml.internal.ws.message.jaxb.JAXBMessage;
36 import javax.xml.bind.JAXBException;
37 import javax.xml.stream.XMLStreamException;
38 import javax.xml.ws.Holder;
40 import java.lang.reflect.Method;
42 /**
43 * {@link MethodHandler} that handles synchronous method invocations.
44 *
45 * <p>
46 * This class mainly performs the following two tasks:
47 * <ol>
48 * <li>Accepts Object[] that represents arguments for a Java method,
49 * and creates {@link JAXBMessage} that represents a request message.
50 * <li>Takes a {@link Message] that represents a response,
51 * and extracts the return value (and updates {@link Holder}s.)
52 * </ol>
53 *
54 * <h2>Creating {@link JAXBMessage}</h2>
55 * <p>
56 * At the construction time, we prepare {@link BodyBuilder} and {@link MessageFiller}s
57 * that know how to move arguments into a {@link Message}.
58 * Some arguments go to the payload, some go to headers, still others go to attachments.
59 *
60 * @author Kohsuke Kawaguchi
61 */
62 final class SyncMethodHandler extends MethodHandler {
63 // private ResponseBuilder responseBuilder;
65 SyncMethodHandler(SEIStub owner, Method m) {
66 super(owner, m);
67 // responseBuilder = buildResponseBuilder(method, ValueSetterFactory.SYNC);
68 }
70 // SyncMethodHandler(SEIStub owner, JavaMethodImpl method) {
71 // super(owner, method);
72 // responseBuilder = buildResponseBuilder(method, ValueSetterFactory.SYNC);
73 // }
75 Object invoke(Object proxy, Object[] args) throws Throwable {
76 return invoke(proxy,args,owner.requestContext,owner);
77 }
79 /**
80 * Invokes synchronously, but with the given {@link RequestContext}
81 * and {@link ResponseContextReceiver}.
82 *
83 * @param rc
84 * This {@link RequestContext} is used for invoking this method.
85 * We take this as a separate parameter because of the async invocation
86 * handling, which requires a separate copy.
87 */
88 Object invoke(Object proxy, Object[] args, RequestContext rc, ResponseContextReceiver receiver) throws Throwable {
89 JavaCallInfo call = owner.databinding.createJavaCallInfo(method, args);
90 // Packet req = new Packet(createRequestMessage(args));
91 Packet req = (Packet) owner.databinding.serializeRequest(call);
92 // process the message
93 Packet reply = owner.doProcess(req,rc,receiver);
95 Message msg = reply.getMessage();
96 if(msg ==null)
97 // no reply. must have been one-way
98 return null;
100 try {
101 // return dbHandler.readResponse(reply, call).getReturnValue();
102 call = owner.databinding.deserializeResponse(reply, call);
103 if (call.getException() != null) {
104 throw call.getException();
105 } else {
106 return call.getReturnValue();
107 }
108 // if(msg.isFault()) {
109 // SOAPFaultBuilder faultBuilder = SOAPFaultBuilder.create(msg);
110 // throw faultBuilder.createException(checkedExceptions);
111 // } else {
112 // return responseBuilder.readResponse(msg,args);
113 // }
114 } catch (JAXBException e) {
115 throw new DeserializationException("failed.to.read.response",e);
116 } catch (XMLStreamException e) {
117 throw new DeserializationException("failed.to.read.response",e);
118 } finally {
119 if (reply.transportBackChannel != null)
120 reply.transportBackChannel.close();
121 }
122 }
124 ValueGetterFactory getValueGetterFactory() {
125 return ValueGetterFactory.SYNC;
126 }
128 }