Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
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.handler;
28 import com.sun.xml.internal.ws.api.WSBinding;
29 import com.sun.xml.internal.ws.api.message.Packet;
30 import com.sun.xml.internal.ws.api.pipe.TubeCloner;
31 import com.sun.xml.internal.ws.api.pipe.Tube;
32 import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl;
33 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
34 import com.sun.xml.internal.ws.api.model.SEIModel;
35 import com.sun.xml.internal.ws.binding.BindingImpl;
36 import com.sun.xml.internal.ws.model.AbstractSEIModelImpl;
37 import com.sun.xml.internal.ws.spi.db.BindingContext;
39 import javax.xml.ws.handler.LogicalHandler;
40 import javax.xml.ws.handler.MessageContext;
41 import javax.xml.ws.handler.Handler;
42 import javax.xml.ws.WebServiceException;
43 import java.util.List;
44 import java.util.ArrayList;
46 /**
47 *
48 * @author WS Development Team
49 */
50 public class ClientLogicalHandlerTube extends HandlerTube {
52 private SEIModel seiModel;
54 /**
55 * Creates a new instance of LogicalHandlerTube
56 */
57 public ClientLogicalHandlerTube(WSBinding binding, SEIModel seiModel, WSDLPort port, Tube next) {
58 super(next, port, binding);
59 this.seiModel = seiModel;
60 }
62 /**
63 * This constructor is used on client-side where, SOAPHandlerTube is created
64 * first and then a LogicalHandlerTube is created with a handler to that
65 * SOAPHandlerTube.
66 * With this handle, LogicalHandlerTube can call
67 * SOAPHandlerTube.closeHandlers()
68 */
69 public ClientLogicalHandlerTube(WSBinding binding, SEIModel seiModel, Tube next, HandlerTube cousinTube) {
70 super(next, cousinTube, binding);
71 this.seiModel = seiModel;
72 }
74 /**
75 * Copy constructor for {@link com.sun.xml.internal.ws.api.pipe.Tube#copy(com.sun.xml.internal.ws.api.pipe.TubeCloner)}.
76 */
78 private ClientLogicalHandlerTube(ClientLogicalHandlerTube that, TubeCloner cloner) {
79 super(that, cloner);
80 this.seiModel = that.seiModel;
81 }
83 //should be overridden by DriverHandlerTubes
84 @Override
85 protected void initiateClosing(MessageContext mc) {
86 close(mc);
87 super.initiateClosing(mc);
88 }
90 public AbstractFilterTubeImpl copy(TubeCloner cloner) {
91 return new ClientLogicalHandlerTube(this, cloner);
92 }
94 void setUpProcessor() {
95 if (handlers == null) {
96 // Take a snapshot, User may change chain after invocation, Same chain
97 // should be used for the entire MEP
98 handlers = new ArrayList<Handler>();
99 WSBinding binding = getBinding();
100 List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers();
101 if (!logicalSnapShot.isEmpty()) {
102 handlers.addAll(logicalSnapShot);
103 if (binding.getSOAPVersion() == null) {
104 processor = new XMLHandlerProcessor(this, binding,
105 handlers);
106 } else {
107 processor = new SOAPHandlerProcessor(true, this, binding,
108 handlers);
109 }
110 }
111 }
112 }
115 MessageUpdatableContext getContext(Packet packet) {
116 return new LogicalMessageContextImpl(getBinding(), getBindingContext(), packet);
117 }
119 private BindingContext getBindingContext() {
120 return (seiModel!= null && seiModel instanceof AbstractSEIModelImpl) ?
121 ((AbstractSEIModelImpl)seiModel).getBindingContext() : null;
122 }
124 boolean callHandlersOnRequest(MessageUpdatableContext context, boolean isOneWay) {
126 boolean handlerResult;
127 try {
129 //CLIENT-SIDE
130 handlerResult = processor.callHandlersRequest(HandlerProcessor.Direction.OUTBOUND, context, !isOneWay);
131 } catch (WebServiceException wse) {
132 remedyActionTaken = true;
133 //no rewrapping
134 throw wse;
135 } catch (RuntimeException re) {
136 remedyActionTaken = true;
138 throw new WebServiceException(re);
140 }
141 if (!handlerResult) {
142 remedyActionTaken = true;
143 }
144 return handlerResult;
145 }
147 void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
148 try {
150 //CLIENT-SIDE
151 processor.callHandlersResponse(HandlerProcessor.Direction.INBOUND, context, handleFault);
153 } catch (WebServiceException wse) {
154 //no rewrapping
155 throw wse;
156 } catch (RuntimeException re) {
158 throw new WebServiceException(re);
160 }
161 }
162 void closeHandlers(MessageContext mc) {
163 closeClientsideHandlers(mc);
165 }
166 }