View Javadoc
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   */
25  
26  package com.sun.xml.internal.ws.client.dispatch;
27  
28  import com.sun.istack.internal.Nullable;
29  import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
30  import com.sun.xml.internal.ws.api.client.ThrowableInPacketCompletionFeature;
31  import com.sun.xml.internal.ws.api.client.WSPortInfo;
32  import com.sun.xml.internal.ws.api.message.Packet;
33  import com.sun.xml.internal.ws.api.pipe.Fiber;
34  import com.sun.xml.internal.ws.api.pipe.Tube;
35  import com.sun.xml.internal.ws.binding.BindingImpl;
36  import com.sun.xml.internal.ws.client.WSServiceDelegate;
37  
38  import javax.xml.namespace.QName;
39  import javax.xml.ws.Dispatch;
40  import javax.xml.ws.Service.Mode;
41  
42  /**
43   * {@link Dispatch} implementation for {@link Packet}.
44   *
45   * @since 2.2.6
46   */
47  public class PacketDispatch extends DispatchImpl<Packet> {
48      private final boolean isDeliverThrowableInPacket;
49  
50      @Deprecated
51      public PacketDispatch(QName port, WSServiceDelegate owner, Tube pipe, BindingImpl binding, @Nullable WSEndpointReference epr) {
52          super(port, Mode.MESSAGE, owner, pipe, binding, epr);
53          isDeliverThrowableInPacket = calculateIsDeliverThrowableInPacket(binding);
54      }
55  
56  
57      public PacketDispatch(WSPortInfo portInfo, Tube pipe, BindingImpl binding, WSEndpointReference epr) {
58          this(portInfo, pipe, binding, epr, true);
59      }
60  
61      public PacketDispatch(WSPortInfo portInfo, Tube pipe, BindingImpl binding, WSEndpointReference epr, boolean allowFaultResponseMsg) {
62          super(portInfo, Mode.MESSAGE, pipe, binding, epr, allowFaultResponseMsg);
63          isDeliverThrowableInPacket = calculateIsDeliverThrowableInPacket(binding);
64      }
65  
66      public PacketDispatch(WSPortInfo portInfo, BindingImpl binding, WSEndpointReference epr) {
67          super(portInfo, Mode.MESSAGE, binding, epr, true);
68          isDeliverThrowableInPacket = calculateIsDeliverThrowableInPacket(binding);
69      }
70  
71      private boolean calculateIsDeliverThrowableInPacket(BindingImpl binding) {
72          return binding.isFeatureEnabled(ThrowableInPacketCompletionFeature.class);
73      }
74  
75      @Override
76      protected void configureFiber(Fiber fiber) {
77          fiber.setDeliverThrowableInPacket(isDeliverThrowableInPacket);
78      }
79  
80      @Override
81      Packet toReturnValue(Packet response) {
82          return response;
83      }
84  
85      @Override
86      Packet createPacket(Packet request) {
87          return request;
88      }
89  
90  
91  }