Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.ws.binding; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.oracle.webservices.internal.api.message.MessageContextFactory; |
aoqi@0 | 29 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 30 | import com.sun.istack.internal.Nullable; |
aoqi@0 | 31 | import com.sun.xml.internal.ws.api.BindingID; |
aoqi@0 | 32 | import com.sun.xml.internal.ws.api.SOAPVersion; |
aoqi@0 | 33 | import com.sun.xml.internal.ws.api.WSBinding; |
aoqi@0 | 34 | import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
aoqi@0 | 35 | import com.sun.xml.internal.ws.api.pipe.Codec; |
aoqi@0 | 36 | import com.sun.xml.internal.ws.client.HandlerConfiguration; |
aoqi@0 | 37 | import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature; |
aoqi@0 | 38 | import com.sun.xml.internal.ws.developer.BindingTypeFeature; |
aoqi@0 | 39 | |
aoqi@0 | 40 | import javax.activation.CommandInfo; |
aoqi@0 | 41 | import javax.activation.CommandMap; |
aoqi@0 | 42 | import javax.activation.MailcapCommandMap; |
aoqi@0 | 43 | import javax.xml.namespace.QName; |
aoqi@0 | 44 | import javax.xml.ws.Service; |
aoqi@0 | 45 | import javax.xml.ws.WebServiceFeature; |
aoqi@0 | 46 | import javax.xml.ws.soap.AddressingFeature; |
aoqi@0 | 47 | import javax.xml.ws.handler.Handler; |
aoqi@0 | 48 | import java.util.Collections; |
aoqi@0 | 49 | import java.util.HashMap; |
aoqi@0 | 50 | import java.util.HashSet; |
aoqi@0 | 51 | import java.util.List; |
aoqi@0 | 52 | import java.util.Set; |
aoqi@0 | 53 | import java.util.Map; |
aoqi@0 | 54 | |
aoqi@0 | 55 | |
aoqi@0 | 56 | /** |
aoqi@0 | 57 | * Instances are created by the service, which then |
aoqi@0 | 58 | * sets the handler chain on the binding impl. |
aoqi@0 | 59 | * |
aoqi@0 | 60 | * <p> |
aoqi@0 | 61 | * This class is made abstract as we don't see a situation when |
aoqi@0 | 62 | * a BindingImpl has much meaning without binding id. |
aoqi@0 | 63 | * IOW, for a specific binding there will be a class |
aoqi@0 | 64 | * extending BindingImpl, for example SOAPBindingImpl. |
aoqi@0 | 65 | * |
aoqi@0 | 66 | * <p> |
aoqi@0 | 67 | * The spi Binding interface extends Binding. |
aoqi@0 | 68 | * |
aoqi@0 | 69 | * @author WS Development Team |
aoqi@0 | 70 | */ |
aoqi@0 | 71 | public abstract class BindingImpl implements WSBinding { |
aoqi@0 | 72 | |
aoqi@0 | 73 | protected static final WebServiceFeature[] EMPTY_FEATURES = new WebServiceFeature[0]; |
aoqi@0 | 74 | |
aoqi@0 | 75 | //This is reset when ever Binding.setHandlerChain() or SOAPBinding.setRoles() is called. |
aoqi@0 | 76 | private HandlerConfiguration handlerConfig; |
aoqi@0 | 77 | private final Set<QName> addedHeaders = new HashSet<QName>(); |
aoqi@0 | 78 | private final Set<QName> knownHeaders = new HashSet<QName>(); |
aoqi@0 | 79 | private final Set<QName> unmodKnownHeaders = Collections.unmodifiableSet(knownHeaders); |
aoqi@0 | 80 | private final BindingID bindingId; |
aoqi@0 | 81 | // Features that are set(enabled/disabled) on the binding |
aoqi@0 | 82 | protected final WebServiceFeatureList features; |
aoqi@0 | 83 | // Features that are set(enabled/disabled) on the binding or an operation |
aoqi@0 | 84 | protected final Map<QName, WebServiceFeatureList> operationFeatures = new HashMap<QName, WebServiceFeatureList>(); |
aoqi@0 | 85 | // Features that are set(enabled/disabled) on the binding, an operation or an input message |
aoqi@0 | 86 | protected final Map<QName, WebServiceFeatureList> inputMessageFeatures = new HashMap<QName, WebServiceFeatureList>(); |
aoqi@0 | 87 | // Features that are set(enabled/disabled) on the binding, an operation or an output message |
aoqi@0 | 88 | protected final Map<QName, WebServiceFeatureList> outputMessageFeatures = new HashMap<QName, WebServiceFeatureList>(); |
aoqi@0 | 89 | // Features that are set(enabled/disabled) on the binding, an operation or a fault message |
aoqi@0 | 90 | protected final Map<MessageKey, WebServiceFeatureList> faultMessageFeatures = new HashMap<MessageKey, WebServiceFeatureList>(); |
aoqi@0 | 91 | |
aoqi@0 | 92 | protected javax.xml.ws.Service.Mode serviceMode = javax.xml.ws.Service.Mode.PAYLOAD; |
aoqi@0 | 93 | |
aoqi@0 | 94 | protected MessageContextFactory messageContextFactory; |
aoqi@0 | 95 | |
aoqi@0 | 96 | protected BindingImpl(BindingID bindingId, WebServiceFeature ... features) { |
aoqi@0 | 97 | this.bindingId = bindingId; |
aoqi@0 | 98 | handlerConfig = new HandlerConfiguration(Collections.<String>emptySet(), Collections.<Handler>emptyList()); |
aoqi@0 | 99 | if (handlerConfig.getHandlerKnownHeaders() != null) |
aoqi@0 | 100 | knownHeaders.addAll(handlerConfig.getHandlerKnownHeaders()); |
aoqi@0 | 101 | this.features = new WebServiceFeatureList(features); |
aoqi@0 | 102 | this.features.validate(); |
aoqi@0 | 103 | } |
aoqi@0 | 104 | |
aoqi@0 | 105 | public |
aoqi@0 | 106 | @NotNull |
aoqi@0 | 107 | List<Handler> getHandlerChain() { |
aoqi@0 | 108 | return handlerConfig.getHandlerChain(); |
aoqi@0 | 109 | } |
aoqi@0 | 110 | |
aoqi@0 | 111 | public HandlerConfiguration getHandlerConfig() { |
aoqi@0 | 112 | return handlerConfig; |
aoqi@0 | 113 | } |
aoqi@0 | 114 | |
aoqi@0 | 115 | protected void setHandlerConfig(HandlerConfiguration handlerConfig) { |
aoqi@0 | 116 | this.handlerConfig = handlerConfig; |
aoqi@0 | 117 | knownHeaders.clear(); |
aoqi@0 | 118 | knownHeaders.addAll(addedHeaders); |
aoqi@0 | 119 | if (handlerConfig != null && handlerConfig.getHandlerKnownHeaders() != null) |
aoqi@0 | 120 | knownHeaders.addAll(handlerConfig.getHandlerKnownHeaders()); |
aoqi@0 | 121 | } |
aoqi@0 | 122 | |
aoqi@0 | 123 | public void setMode(@NotNull Service.Mode mode) { |
aoqi@0 | 124 | this.serviceMode = mode; |
aoqi@0 | 125 | } |
aoqi@0 | 126 | |
aoqi@0 | 127 | public Set<QName> getKnownHeaders() { |
aoqi@0 | 128 | return unmodKnownHeaders; |
aoqi@0 | 129 | } |
aoqi@0 | 130 | |
aoqi@0 | 131 | public boolean addKnownHeader(QName headerQName) { |
aoqi@0 | 132 | addedHeaders.add(headerQName); |
aoqi@0 | 133 | return knownHeaders.add(headerQName); |
aoqi@0 | 134 | } |
aoqi@0 | 135 | |
aoqi@0 | 136 | public |
aoqi@0 | 137 | @NotNull |
aoqi@0 | 138 | BindingID getBindingId() { |
aoqi@0 | 139 | return bindingId; |
aoqi@0 | 140 | } |
aoqi@0 | 141 | |
aoqi@0 | 142 | public final SOAPVersion getSOAPVersion() { |
aoqi@0 | 143 | return bindingId.getSOAPVersion(); |
aoqi@0 | 144 | } |
aoqi@0 | 145 | |
aoqi@0 | 146 | public AddressingVersion getAddressingVersion() { |
aoqi@0 | 147 | AddressingVersion addressingVersion; |
aoqi@0 | 148 | if (features.isEnabled(AddressingFeature.class)) |
aoqi@0 | 149 | addressingVersion = AddressingVersion.W3C; |
aoqi@0 | 150 | else if (features.isEnabled(MemberSubmissionAddressingFeature.class)) |
aoqi@0 | 151 | addressingVersion = AddressingVersion.MEMBER; |
aoqi@0 | 152 | else |
aoqi@0 | 153 | addressingVersion = null; |
aoqi@0 | 154 | return addressingVersion; |
aoqi@0 | 155 | } |
aoqi@0 | 156 | |
aoqi@0 | 157 | @NotNull |
aoqi@0 | 158 | public final Codec createCodec() { |
aoqi@0 | 159 | |
aoqi@0 | 160 | // initialization from here should cover most of cases; |
aoqi@0 | 161 | // if not, it would be necessary to call |
aoqi@0 | 162 | // BindingImpl.initializeJavaActivationHandlers() |
aoqi@0 | 163 | // explicitly by programmer |
aoqi@0 | 164 | initializeJavaActivationHandlers(); |
aoqi@0 | 165 | |
aoqi@0 | 166 | return bindingId.createEncoder(this); |
aoqi@0 | 167 | } |
aoqi@0 | 168 | |
aoqi@0 | 169 | public static void initializeJavaActivationHandlers() { |
aoqi@0 | 170 | // DataHandler.writeTo() may search for DCH. So adding some default ones. |
aoqi@0 | 171 | try { |
aoqi@0 | 172 | CommandMap map = CommandMap.getDefaultCommandMap(); |
aoqi@0 | 173 | if (map instanceof MailcapCommandMap) { |
aoqi@0 | 174 | MailcapCommandMap mailMap = (MailcapCommandMap) map; |
aoqi@0 | 175 | |
aoqi@0 | 176 | // registering our DCH since javamail's DCH doesn't handle |
aoqi@0 | 177 | if (!cmdMapInitialized(mailMap)) { |
aoqi@0 | 178 | mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); |
aoqi@0 | 179 | mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); |
aoqi@0 | 180 | mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); |
aoqi@0 | 181 | mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); |
aoqi@0 | 182 | } |
aoqi@0 | 183 | } |
aoqi@0 | 184 | } catch (Throwable t) { |
aoqi@0 | 185 | // ignore the exception. |
aoqi@0 | 186 | } |
aoqi@0 | 187 | } |
aoqi@0 | 188 | |
aoqi@0 | 189 | private static boolean cmdMapInitialized(MailcapCommandMap mailMap) { |
aoqi@0 | 190 | CommandInfo[] commands = mailMap.getAllCommands("text/xml"); |
aoqi@0 | 191 | if (commands == null || commands.length == 0) { |
aoqi@0 | 192 | return false; |
aoqi@0 | 193 | } |
aoqi@0 | 194 | |
aoqi@0 | 195 | // SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too; |
aoqi@0 | 196 | // see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers |
aoqi@0 | 197 | // so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here |
aoqi@0 | 198 | // is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl. |
aoqi@0 | 199 | // This is also reason for duplication of Handler's code by JAX-WS |
aoqi@0 | 200 | String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler"; |
aoqi@0 | 201 | String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler"; |
aoqi@0 | 202 | for (CommandInfo command : commands) { |
aoqi@0 | 203 | String commandClass = command.getCommandClass(); |
aoqi@0 | 204 | if (saajClassName.equals(commandClass) || |
aoqi@0 | 205 | jaxwsClassName.equals(commandClass)) { |
aoqi@0 | 206 | return true; |
aoqi@0 | 207 | } |
aoqi@0 | 208 | } |
aoqi@0 | 209 | return false; |
aoqi@0 | 210 | } |
aoqi@0 | 211 | |
aoqi@0 | 212 | public static BindingImpl create(@NotNull BindingID bindingId) { |
aoqi@0 | 213 | if (bindingId.equals(BindingID.XML_HTTP)) |
aoqi@0 | 214 | return new HTTPBindingImpl(); |
aoqi@0 | 215 | else |
aoqi@0 | 216 | return new SOAPBindingImpl(bindingId); |
aoqi@0 | 217 | } |
aoqi@0 | 218 | |
aoqi@0 | 219 | public static BindingImpl create(@NotNull BindingID bindingId, WebServiceFeature[] features) { |
aoqi@0 | 220 | // Override the BindingID from the features |
aoqi@0 | 221 | for(WebServiceFeature feature : features) { |
aoqi@0 | 222 | if (feature instanceof BindingTypeFeature) { |
aoqi@0 | 223 | BindingTypeFeature f = (BindingTypeFeature)feature; |
aoqi@0 | 224 | bindingId = BindingID.parse(f.getBindingId()); |
aoqi@0 | 225 | } |
aoqi@0 | 226 | } |
aoqi@0 | 227 | if (bindingId.equals(BindingID.XML_HTTP)) |
aoqi@0 | 228 | return new HTTPBindingImpl(features); |
aoqi@0 | 229 | else |
aoqi@0 | 230 | return new SOAPBindingImpl(bindingId, features); |
aoqi@0 | 231 | } |
aoqi@0 | 232 | |
aoqi@0 | 233 | public static WSBinding getDefaultBinding() { |
aoqi@0 | 234 | return new SOAPBindingImpl(BindingID.SOAP11_HTTP); |
aoqi@0 | 235 | } |
aoqi@0 | 236 | |
aoqi@0 | 237 | public String getBindingID() { |
aoqi@0 | 238 | return bindingId.toString(); |
aoqi@0 | 239 | } |
aoqi@0 | 240 | |
aoqi@0 | 241 | public @Nullable <F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType){ |
aoqi@0 | 242 | return features.get(featureType); |
aoqi@0 | 243 | } |
aoqi@0 | 244 | |
aoqi@0 | 245 | public @Nullable <F extends WebServiceFeature> F getOperationFeature(@NotNull Class<F> featureType, |
aoqi@0 | 246 | @NotNull final QName operationName) { |
aoqi@0 | 247 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 248 | return FeatureListUtil.mergeFeature(featureType, operationFeatureList, features); |
aoqi@0 | 249 | } |
aoqi@0 | 250 | |
aoqi@0 | 251 | public boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature){ |
aoqi@0 | 252 | return features.isEnabled(feature); |
aoqi@0 | 253 | } |
aoqi@0 | 254 | |
aoqi@0 | 255 | public boolean isOperationFeatureEnabled(@NotNull Class<? extends WebServiceFeature> featureType, |
aoqi@0 | 256 | @NotNull final QName operationName) { |
aoqi@0 | 257 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 258 | return FeatureListUtil.isFeatureEnabled(featureType, operationFeatureList, features); |
aoqi@0 | 259 | } |
aoqi@0 | 260 | |
aoqi@0 | 261 | @NotNull |
aoqi@0 | 262 | public WebServiceFeatureList getFeatures() { |
aoqi@0 | 263 | //TODO scchen convert BindingID to WebServiceFeature[] |
aoqi@0 | 264 | if(!isFeatureEnabled(com.oracle.webservices.internal.api.EnvelopeStyleFeature.class)) { |
aoqi@0 | 265 | WebServiceFeature[] f = { getSOAPVersion().toFeature() }; |
aoqi@0 | 266 | features.mergeFeatures(f, false); |
aoqi@0 | 267 | } |
aoqi@0 | 268 | return features; |
aoqi@0 | 269 | } |
aoqi@0 | 270 | |
aoqi@0 | 271 | public @NotNull WebServiceFeatureList getOperationFeatures(@NotNull final QName operationName) { |
aoqi@0 | 272 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 273 | return FeatureListUtil.mergeList(operationFeatureList, features); |
aoqi@0 | 274 | } |
aoqi@0 | 275 | |
aoqi@0 | 276 | public @NotNull WebServiceFeatureList getInputMessageFeatures(@NotNull final QName operationName) { |
aoqi@0 | 277 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 278 | final WebServiceFeatureList messageFeatureList = this.inputMessageFeatures.get(operationName); |
aoqi@0 | 279 | return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features); |
aoqi@0 | 280 | |
aoqi@0 | 281 | } |
aoqi@0 | 282 | |
aoqi@0 | 283 | public @NotNull WebServiceFeatureList getOutputMessageFeatures(@NotNull final QName operationName) { |
aoqi@0 | 284 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 285 | final WebServiceFeatureList messageFeatureList = this.outputMessageFeatures.get(operationName); |
aoqi@0 | 286 | return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features); |
aoqi@0 | 287 | } |
aoqi@0 | 288 | |
aoqi@0 | 289 | public @NotNull WebServiceFeatureList getFaultMessageFeatures(@NotNull final QName operationName, |
aoqi@0 | 290 | @NotNull final QName messageName) { |
aoqi@0 | 291 | final WebServiceFeatureList operationFeatureList = this.operationFeatures.get(operationName); |
aoqi@0 | 292 | final WebServiceFeatureList messageFeatureList = this.faultMessageFeatures.get( |
aoqi@0 | 293 | new MessageKey(operationName, messageName)); |
aoqi@0 | 294 | return FeatureListUtil.mergeList(operationFeatureList, messageFeatureList, features); |
aoqi@0 | 295 | } |
aoqi@0 | 296 | |
aoqi@0 | 297 | public void setOperationFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) { |
aoqi@0 | 298 | if (newFeatures != null) { |
aoqi@0 | 299 | WebServiceFeatureList featureList = operationFeatures.get(operationName); |
aoqi@0 | 300 | if (featureList == null) { |
aoqi@0 | 301 | featureList = new WebServiceFeatureList(); |
aoqi@0 | 302 | } |
aoqi@0 | 303 | for (WebServiceFeature f : newFeatures) { |
aoqi@0 | 304 | featureList.add(f); |
aoqi@0 | 305 | } |
aoqi@0 | 306 | operationFeatures.put(operationName, featureList); |
aoqi@0 | 307 | } |
aoqi@0 | 308 | } |
aoqi@0 | 309 | |
aoqi@0 | 310 | public void setInputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) { |
aoqi@0 | 311 | if (newFeatures != null) { |
aoqi@0 | 312 | WebServiceFeatureList featureList = inputMessageFeatures.get(operationName); |
aoqi@0 | 313 | if (featureList == null) { |
aoqi@0 | 314 | featureList = new WebServiceFeatureList(); |
aoqi@0 | 315 | } |
aoqi@0 | 316 | for (WebServiceFeature f : newFeatures) { |
aoqi@0 | 317 | featureList.add(f); |
aoqi@0 | 318 | } |
aoqi@0 | 319 | inputMessageFeatures.put(operationName, featureList); |
aoqi@0 | 320 | } |
aoqi@0 | 321 | } |
aoqi@0 | 322 | |
aoqi@0 | 323 | public void setOutputMessageFeatures(@NotNull final QName operationName, WebServiceFeature... newFeatures) { |
aoqi@0 | 324 | if (newFeatures != null) { |
aoqi@0 | 325 | WebServiceFeatureList featureList = outputMessageFeatures.get(operationName); |
aoqi@0 | 326 | if (featureList == null) { |
aoqi@0 | 327 | featureList = new WebServiceFeatureList(); |
aoqi@0 | 328 | } |
aoqi@0 | 329 | for (WebServiceFeature f : newFeatures) { |
aoqi@0 | 330 | featureList.add(f); |
aoqi@0 | 331 | } |
aoqi@0 | 332 | outputMessageFeatures.put(operationName, featureList); |
aoqi@0 | 333 | } |
aoqi@0 | 334 | } |
aoqi@0 | 335 | |
aoqi@0 | 336 | public void setFaultMessageFeatures(@NotNull final QName operationName, @NotNull final QName messageName, WebServiceFeature... newFeatures) { |
aoqi@0 | 337 | if (newFeatures != null) { |
aoqi@0 | 338 | final MessageKey key = new MessageKey(operationName, messageName); |
aoqi@0 | 339 | WebServiceFeatureList featureList = faultMessageFeatures.get(key); |
aoqi@0 | 340 | if (featureList == null) { |
aoqi@0 | 341 | featureList = new WebServiceFeatureList(); |
aoqi@0 | 342 | } |
aoqi@0 | 343 | for (WebServiceFeature f : newFeatures) { |
aoqi@0 | 344 | featureList.add(f); |
aoqi@0 | 345 | } |
aoqi@0 | 346 | faultMessageFeatures.put(key, featureList); |
aoqi@0 | 347 | } |
aoqi@0 | 348 | } |
aoqi@0 | 349 | |
aoqi@0 | 350 | public synchronized @NotNull com.oracle.webservices.internal.api.message.MessageContextFactory getMessageContextFactory () { |
aoqi@0 | 351 | if (messageContextFactory == null) { |
aoqi@0 | 352 | messageContextFactory = MessageContextFactory.createFactory(getFeatures().toArray()); |
aoqi@0 | 353 | } |
aoqi@0 | 354 | return messageContextFactory; |
aoqi@0 | 355 | } |
aoqi@0 | 356 | |
aoqi@0 | 357 | /** |
aoqi@0 | 358 | * Experimental: Identify messages based on the name of the message and the |
aoqi@0 | 359 | * operation that uses this message. |
aoqi@0 | 360 | */ |
aoqi@0 | 361 | protected static class MessageKey { |
aoqi@0 | 362 | |
aoqi@0 | 363 | final private QName operationName; |
aoqi@0 | 364 | final private QName messageName; |
aoqi@0 | 365 | |
aoqi@0 | 366 | public MessageKey(final QName operationName, final QName messageName) { |
aoqi@0 | 367 | this.operationName = operationName; |
aoqi@0 | 368 | this.messageName = messageName; |
aoqi@0 | 369 | } |
aoqi@0 | 370 | |
aoqi@0 | 371 | @Override |
aoqi@0 | 372 | public int hashCode() { |
aoqi@0 | 373 | final int hashFirst = this.operationName != null ? this.operationName.hashCode() : 0; |
aoqi@0 | 374 | final int hashSecond = this.messageName != null ? this.messageName.hashCode() : 0; |
aoqi@0 | 375 | |
aoqi@0 | 376 | return (hashFirst + hashSecond) * hashSecond + hashFirst; |
aoqi@0 | 377 | } |
aoqi@0 | 378 | |
aoqi@0 | 379 | @Override |
aoqi@0 | 380 | public boolean equals(Object obj) { |
aoqi@0 | 381 | if (obj == null) { |
aoqi@0 | 382 | return false; |
aoqi@0 | 383 | } |
aoqi@0 | 384 | if (getClass() != obj.getClass()) { |
aoqi@0 | 385 | return false; |
aoqi@0 | 386 | } |
aoqi@0 | 387 | final MessageKey other = (MessageKey) obj; |
aoqi@0 | 388 | if (this.operationName != other.operationName && (this.operationName == null || !this.operationName.equals(other.operationName))) { |
aoqi@0 | 389 | return false; |
aoqi@0 | 390 | } |
aoqi@0 | 391 | if (this.messageName != other.messageName && (this.messageName == null || !this.messageName.equals(other.messageName))) { |
aoqi@0 | 392 | return false; |
aoqi@0 | 393 | } |
aoqi@0 | 394 | return true; |
aoqi@0 | 395 | } |
aoqi@0 | 396 | |
aoqi@0 | 397 | @Override |
aoqi@0 | 398 | public String toString() { |
aoqi@0 | 399 | return "(" + this.operationName + ", " + this.messageName + ")"; |
aoqi@0 | 400 | } |
aoqi@0 | 401 | |
aoqi@0 | 402 | } |
aoqi@0 | 403 | |
aoqi@0 | 404 | } |