src/share/jaxws_classes/com/sun/xml/internal/ws/server/sei/SEIInvokerTube.java

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
equal deleted inserted replaced
284:88b85470e72c 286:f50545b5e2f1
1 /*
2 * Copyright (c) 1997, 2011, 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 */
25
26 package com.sun.xml.internal.ws.server.sei;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.xml.internal.ws.api.SOAPVersion;
30 import com.sun.xml.internal.ws.api.WSBinding;
31 import com.sun.xml.internal.ws.api.databinding.EndpointCallBridge;
32 import com.sun.xml.internal.ws.api.message.Message;
33 import com.sun.xml.internal.ws.api.message.Packet;
34 import com.sun.xml.internal.ws.api.pipe.NextAction;
35 import com.sun.xml.internal.ws.api.server.Invoker;
36 import com.sun.xml.internal.ws.client.sei.MethodHandler;
37 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl;
38 import com.sun.xml.internal.ws.server.InvokerTube;
39 import com.sun.xml.internal.ws.resources.ServerMessages;
40 import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
41 import com.sun.xml.internal.ws.wsdl.DispatchException;
42 import com.sun.xml.internal.org.jvnet.ws.databinding.JavaCallInfo;
43 import java.util.List;
44 import java.lang.reflect.InvocationTargetException;
45 import java.text.MessageFormat;
46
47 /**
48 * This pipe is used to invoke SEI based endpoints.
49 *
50 * @author Jitendra Kotamraju
51 */
52 public class SEIInvokerTube extends InvokerTube {
53
54 /**
55 * For each method on the port interface we have
56 * a {@link MethodHandler} that processes it.
57 */
58 private final WSBinding binding;
59 private final AbstractSEIModelImpl model;
60
61 public SEIInvokerTube(AbstractSEIModelImpl model,Invoker invoker, WSBinding binding) {
62 super(invoker);
63 this.binding = binding;
64 this.model = model;
65 }
66
67 /**
68 * This binds the parameters for SEI endpoints and invokes the endpoint method. The
69 * return value, and response Holder arguments are used to create a new {@link Message}
70 * that traverses through the Pipeline to transport.
71 */
72 public @NotNull NextAction processRequest(@NotNull Packet req) {
73 JavaCallInfo call = model.getDatabinding().deserializeRequest(req);
74 if (call.getException() == null) {
75 try {
76 if (req.getMessage().isOneWay(model.getPort()) && req.transportBackChannel != null) {
77 req.transportBackChannel.close();
78 }
79 Object ret = getInvoker(req).invoke(req, call.getMethod(), call.getParameters());
80 call.setReturnValue(ret);
81 } catch (InvocationTargetException e) {
82 call.setException(e);
83 } catch (Exception e) {
84 call.setException(e);
85 }
86 } else if (call.getException() instanceof DispatchException) {
87 DispatchException e = (DispatchException)call.getException();
88 return doReturnWith(req.createServerResponse(e.fault, model.getPort(), null, binding));
89 }
90 Packet res = (Packet) model.getDatabinding().serializeResponse(call);
91 res = req.relateServerResponse(res, req.endpoint.getPort(), model, req.endpoint.getBinding());
92 assert res != null;
93 return doReturnWith(res);
94 }
95
96 public @NotNull NextAction processResponse(@NotNull Packet response) {
97 throw new IllegalStateException("InovkerPipe's processResponse shouldn't be called.");
98 }
99
100 public @NotNull NextAction processException(@NotNull Throwable t) {
101 throw new IllegalStateException("InovkerPipe's processException shouldn't be called.");
102 }
103
104 }

mercurial