Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
ohair@286 | 1 | /* |
ohair@286 | 2 | * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package com.sun.xml.internal.ws.api; |
ohair@286 | 27 | |
ohair@286 | 28 | import com.sun.istack.internal.NotNull; |
ohair@286 | 29 | import com.sun.xml.internal.ws.api.message.Message; |
ohair@286 | 30 | import com.sun.xml.internal.ws.api.pipe.Codec; |
ohair@286 | 31 | import com.sun.xml.internal.ws.api.pipe.Tube; |
ohair@286 | 32 | import com.sun.xml.internal.ws.binding.BindingImpl; |
ohair@286 | 33 | import com.sun.xml.internal.ws.binding.SOAPBindingImpl; |
ohair@286 | 34 | import com.sun.xml.internal.ws.binding.WebServiceFeatureList; |
ohair@286 | 35 | import com.sun.xml.internal.ws.encoding.SOAPBindingCodec; |
ohair@286 | 36 | import com.sun.xml.internal.ws.encoding.XMLHTTPBindingCodec; |
ohair@286 | 37 | import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants; |
ohair@286 | 38 | import com.sun.xml.internal.ws.encoding.soap.streaming.SOAP12NamespaceConstants; |
ohair@286 | 39 | import com.sun.xml.internal.ws.util.ServiceFinder; |
ohair@286 | 40 | import com.sun.xml.internal.ws.developer.JAXWSProperties; |
ohair@286 | 41 | import static com.sun.xml.internal.ws.binding.WebServiceFeatureList.toFeatureArray; |
ohair@286 | 42 | |
ohair@286 | 43 | import javax.xml.ws.BindingType; |
ohair@286 | 44 | import javax.xml.ws.WebServiceException; |
ohair@286 | 45 | import javax.xml.ws.WebServiceFeature; |
ohair@286 | 46 | import javax.xml.ws.handler.Handler; |
ohair@286 | 47 | import javax.xml.ws.http.HTTPBinding; |
ohair@286 | 48 | import javax.xml.ws.soap.MTOMFeature; |
ohair@286 | 49 | import javax.xml.ws.soap.SOAPBinding; |
ohair@286 | 50 | |
ohair@286 | 51 | import java.io.UnsupportedEncodingException; |
ohair@286 | 52 | import java.net.URL; |
ohair@286 | 53 | import java.net.URLDecoder; |
ohair@286 | 54 | import java.util.HashMap; |
ohair@286 | 55 | import java.util.Map; |
ohair@286 | 56 | |
ohair@286 | 57 | /** |
ohair@286 | 58 | * Parsed binding ID string. |
ohair@286 | 59 | * |
ohair@286 | 60 | * <p> |
ohair@286 | 61 | * {@link BindingID} is an immutable object that represents a binding ID, |
ohair@286 | 62 | * much like how {@link URL} is a representation of an URL. |
ohair@286 | 63 | * Like {@link URL}, this class offers a bunch of methods that let you |
ohair@286 | 64 | * query various traits/properties of a binding ID. |
ohair@286 | 65 | * |
ohair@286 | 66 | * <p> |
ohair@286 | 67 | * {@link BindingID} is extensible; one can plug in a parser from |
ohair@286 | 68 | * {@link String} to {@link BindingID} to interpret binding IDs that |
ohair@286 | 69 | * the JAX-WS RI does no a-priori knowledge of. |
ohair@286 | 70 | * Technologies such as Tango uses this to make the JAX-WS RI understand |
ohair@286 | 71 | * binding IDs defined in their world. |
ohair@286 | 72 | * |
ohair@286 | 73 | * Such technologies are free to extend this class and expose more characterstics. |
ohair@286 | 74 | * |
ohair@286 | 75 | * <p> |
ohair@286 | 76 | * Even though this class defines a few well known constants, {@link BindingID} |
ohair@286 | 77 | * instances do not necessarily have singleton semantics. Use {@link #equals(Object)} |
ohair@286 | 78 | * for the comparison. |
ohair@286 | 79 | * |
ohair@286 | 80 | * <h3>{@link BindingID} and {@link WSBinding}</h3> |
ohair@286 | 81 | * <p> |
ohair@286 | 82 | * {@link WSBinding} is mutable and represents a particular "use" of a {@link BindingID}. |
ohair@286 | 83 | * As such, it has state like a list of {@link Handler}s, which are inherently local |
ohair@286 | 84 | * to a particular usage. For example, if you have two proxies, you need two instances. |
ohair@286 | 85 | * |
ohair@286 | 86 | * {@link BindingID}, OTOH, is immutable and thus the single instance |
ohair@286 | 87 | * that represents "SOAP1.2/HTTP" can be shared and reused by all proxies in the same VM. |
ohair@286 | 88 | * |
ohair@286 | 89 | * @author Kohsuke Kawaguchi |
ohair@286 | 90 | */ |
ohair@286 | 91 | public abstract class BindingID { |
ohair@286 | 92 | |
ohair@286 | 93 | /** |
ohair@286 | 94 | * Creates an instance of {@link WSBinding} (which is conceptually an "use" |
ohair@286 | 95 | * of {@link BindingID}) from a {@link BindingID}. |
ohair@286 | 96 | * |
ohair@286 | 97 | * @return |
ohair@286 | 98 | * Always a new instance. |
ohair@286 | 99 | */ |
ohair@286 | 100 | public final @NotNull WSBinding createBinding() { |
ohair@286 | 101 | return BindingImpl.create(this); |
ohair@286 | 102 | } |
ohair@286 | 103 | |
ohair@286 | 104 | /** |
ohair@286 | 105 | * Returns wsdl:binding@transport attribute. Sub classes |
ohair@286 | 106 | * are expected to override this method to provide their transport |
ohair@286 | 107 | * attribute. |
ohair@286 | 108 | * |
ohair@286 | 109 | * @return wsdl:binding@transport attribute |
ohair@286 | 110 | * @since JAX-WS RI 2.1.6 |
ohair@286 | 111 | */ |
ohair@286 | 112 | public @NotNull String getTransport() { |
ohair@286 | 113 | return SOAPNamespaceConstants.TRANSPORT_HTTP; |
ohair@286 | 114 | } |
ohair@286 | 115 | |
ohair@286 | 116 | public final @NotNull WSBinding createBinding(WebServiceFeature... features) { |
ohair@286 | 117 | return BindingImpl.create(this, features); |
ohair@286 | 118 | } |
ohair@286 | 119 | |
ohair@286 | 120 | public final @NotNull WSBinding createBinding(WSFeatureList features) { |
ohair@286 | 121 | return createBinding(features.toArray()); |
ohair@286 | 122 | } |
ohair@286 | 123 | |
ohair@286 | 124 | /** |
ohair@286 | 125 | * Gets the SOAP version of this binding. |
ohair@286 | 126 | * |
ohair@286 | 127 | * TODO: clarify what to do with XML/HTTP binding |
ohair@286 | 128 | * |
ohair@286 | 129 | * @return |
ohair@286 | 130 | * If the binding is using SOAP, this method returns |
ohair@286 | 131 | * a {@link SOAPVersion} constant. |
ohair@286 | 132 | * |
ohair@286 | 133 | * If the binding is not based on SOAP, this method |
ohair@286 | 134 | * returns null. See {@link Message} for how a non-SOAP |
ohair@286 | 135 | * binding shall be handled by {@link Tube}s. |
ohair@286 | 136 | */ |
ohair@286 | 137 | public abstract SOAPVersion getSOAPVersion(); |
ohair@286 | 138 | |
ohair@286 | 139 | /** |
ohair@286 | 140 | * Creates a new {@link Codec} for this binding. |
ohair@286 | 141 | * |
ohair@286 | 142 | * @param binding |
ohair@286 | 143 | * Ocassionally some aspects of binding can be overridden by |
ohair@286 | 144 | * {@link WSBinding} at runtime by users, so some {@link Codec}s |
ohair@286 | 145 | * need to have access to {@link WSBinding} that it's working for. |
ohair@286 | 146 | */ |
ohair@286 | 147 | public abstract @NotNull Codec createEncoder(@NotNull WSBinding binding); |
ohair@286 | 148 | |
ohair@286 | 149 | /** |
ohair@286 | 150 | * Gets the binding ID, which uniquely identifies the binding. |
ohair@286 | 151 | * |
ohair@286 | 152 | * <p> |
ohair@286 | 153 | * The relevant specs define the binding IDs and what they mean. |
ohair@286 | 154 | * The ID is used in many places to identify the kind of binding |
ohair@286 | 155 | * (such as SOAP1.1, SOAP1.2, REST, ...) |
ohair@286 | 156 | * |
ohair@286 | 157 | * @return |
ohair@286 | 158 | * Always non-null same value. |
ohair@286 | 159 | */ |
ohair@286 | 160 | public abstract String toString(); |
ohair@286 | 161 | |
ohair@286 | 162 | /** |
ohair@286 | 163 | * Returna a new {@link WebServiceFeatureList} instance |
ohair@286 | 164 | * that represents the features that are built into this binding ID. |
ohair@286 | 165 | * |
ohair@286 | 166 | * <p> |
ohair@286 | 167 | * For example, {@link BindingID} for |
ohair@286 | 168 | * <tt>"{@value SOAPBinding#SOAP11HTTP_MTOM_BINDING}"</tt> |
ohair@286 | 169 | * would always return a list that has {@link MTOMFeature} enabled. |
ohair@286 | 170 | */ |
ohair@286 | 171 | public WebServiceFeatureList createBuiltinFeatureList() { |
ohair@286 | 172 | return new WebServiceFeatureList(); |
ohair@286 | 173 | } |
ohair@286 | 174 | |
ohair@286 | 175 | /** |
ohair@286 | 176 | * Returns true if this binding can generate WSDL. |
ohair@286 | 177 | * |
ohair@286 | 178 | * <p> |
ohair@286 | 179 | * For e.g.: SOAP 1.1 and "XSOAP 1.2" is supposed to return true |
ohair@286 | 180 | * from this method. For SOAP1.2, there is no standard WSDL, so the |
ohair@286 | 181 | * runtime is not generating one and it expects the WSDL is packaged. |
ohair@286 | 182 | * |
ohair@286 | 183 | */ |
ohair@286 | 184 | public boolean canGenerateWSDL() { |
ohair@286 | 185 | return false; |
ohair@286 | 186 | } |
ohair@286 | 187 | |
ohair@286 | 188 | /** |
ohair@286 | 189 | * Returns a parameter of this binding ID. |
ohair@286 | 190 | * |
ohair@286 | 191 | * <p> |
ohair@286 | 192 | * Some binding ID, such as those for SOAP/HTTP, uses the URL |
ohair@286 | 193 | * query syntax (like <tt>?mtom=true</tt>) to control |
ohair@286 | 194 | * the optional part of the binding. This method obtains |
ohair@286 | 195 | * the value for such optional parts. |
ohair@286 | 196 | * |
ohair@286 | 197 | * <p> |
ohair@286 | 198 | * For implementors of the derived classes, if your binding ID |
ohair@286 | 199 | * does not define such optional parts (such as the XML/HTTP binding ID), |
ohair@286 | 200 | * then you should simply return the specified default value |
ohair@286 | 201 | * (which is what this implementation does.) |
ohair@286 | 202 | * |
ohair@286 | 203 | * @param parameterName |
ohair@286 | 204 | * The parameter name, such as "mtom" in the above example. |
ohair@286 | 205 | * @param defaultValue |
ohair@286 | 206 | * If this binding ID doesn't have the specified parameter explicitly, |
ohair@286 | 207 | * this value will be returned. |
ohair@286 | 208 | * |
ohair@286 | 209 | * @return |
ohair@286 | 210 | * the value of the parameter, if it's present (such as "true" |
ohair@286 | 211 | * in the above example.) If not present, this method returns |
ohair@286 | 212 | * the {@code defaultValue}. |
ohair@286 | 213 | */ |
ohair@286 | 214 | public String getParameter(String parameterName, String defaultValue) { |
ohair@286 | 215 | return defaultValue; |
ohair@286 | 216 | } |
ohair@286 | 217 | |
ohair@286 | 218 | /** |
ohair@286 | 219 | * Compares the equality based on {@link #toString()}. |
ohair@286 | 220 | */ |
ohair@286 | 221 | public boolean equals(Object obj) { |
ohair@286 | 222 | if(!(obj instanceof BindingID)) |
ohair@286 | 223 | return false; |
ohair@286 | 224 | return toString().equals(obj.toString()); |
ohair@286 | 225 | } |
ohair@286 | 226 | |
ohair@286 | 227 | public int hashCode() { |
ohair@286 | 228 | return toString().hashCode(); |
ohair@286 | 229 | } |
ohair@286 | 230 | |
ohair@286 | 231 | /** |
ohair@286 | 232 | * Parses a binding ID string into a {@link BindingID} object. |
ohair@286 | 233 | * |
ohair@286 | 234 | * <p> |
ohair@286 | 235 | * This method first checks for a few known values and then delegate |
ohair@286 | 236 | * the parsing to {@link BindingIDFactory}. |
ohair@286 | 237 | * |
ohair@286 | 238 | * <p> |
ohair@286 | 239 | * If parsing succeeds this method returns a value. Otherwise |
ohair@286 | 240 | * throws {@link WebServiceException}. |
ohair@286 | 241 | * |
ohair@286 | 242 | * @throws WebServiceException |
ohair@286 | 243 | * If the binding ID is not understood. |
ohair@286 | 244 | */ |
ohair@286 | 245 | public static @NotNull BindingID parse(String lexical) { |
ohair@286 | 246 | if(lexical.equals(XML_HTTP.toString())) |
ohair@286 | 247 | return XML_HTTP; |
ohair@286 | 248 | if(lexical.equals(REST_HTTP.toString())) |
ohair@286 | 249 | return REST_HTTP; |
ohair@286 | 250 | if(belongsTo(lexical,SOAP11_HTTP.toString())) |
ohair@286 | 251 | return customize(lexical,SOAP11_HTTP); |
ohair@286 | 252 | if(belongsTo(lexical,SOAP12_HTTP.toString())) |
ohair@286 | 253 | return customize(lexical,SOAP12_HTTP); |
ohair@286 | 254 | if(belongsTo(lexical,SOAPBindingImpl.X_SOAP12HTTP_BINDING)) |
ohair@286 | 255 | return customize(lexical,X_SOAP12_HTTP); |
ohair@286 | 256 | |
ohair@286 | 257 | // OK, it's none of the values JAX-WS understands. |
ohair@286 | 258 | for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) { |
ohair@286 | 259 | BindingID r = f.parse(lexical); |
ohair@286 | 260 | if(r!=null) |
ohair@286 | 261 | return r; |
ohair@286 | 262 | } |
ohair@286 | 263 | |
ohair@286 | 264 | // nobody understood this value |
ohair@286 | 265 | throw new WebServiceException("Wrong binding ID: "+lexical); |
ohair@286 | 266 | } |
ohair@286 | 267 | |
ohair@286 | 268 | private static boolean belongsTo(String lexical, String id) { |
ohair@286 | 269 | return lexical.equals(id) || lexical.startsWith(id+'?'); |
ohair@286 | 270 | } |
ohair@286 | 271 | |
ohair@286 | 272 | /** |
ohair@286 | 273 | * Parses parameter portion and returns appropriately populated {@link SOAPHTTPImpl} |
ohair@286 | 274 | */ |
ohair@286 | 275 | private static SOAPHTTPImpl customize(String lexical, SOAPHTTPImpl base) { |
ohair@286 | 276 | if(lexical.equals(base.toString())) |
ohair@286 | 277 | return base; |
ohair@286 | 278 | |
ohair@286 | 279 | // otherwise we must have query parameter |
ohair@286 | 280 | // we assume the spec won't define any tricky parameters that require |
ohair@286 | 281 | // complicated handling (such as %HH or non-ASCII char), so this parser |
ohair@286 | 282 | // is quite simple-minded. |
ohair@286 | 283 | SOAPHTTPImpl r = new SOAPHTTPImpl(base.getSOAPVersion(), lexical, base.canGenerateWSDL()); |
ohair@286 | 284 | try { |
ohair@286 | 285 | // With X_SOAP12_HTTP, base != lexical and lexical does n't have any query string |
ohair@286 | 286 | if(lexical.indexOf('?') == -1) { |
ohair@286 | 287 | return r; |
ohair@286 | 288 | } |
ohair@286 | 289 | String query = URLDecoder.decode(lexical.substring(lexical.indexOf('?')+1),"UTF-8"); |
ohair@286 | 290 | for( String token : query.split("&") ) { |
ohair@286 | 291 | int idx = token.indexOf('='); |
ohair@286 | 292 | if(idx<0) |
ohair@286 | 293 | throw new WebServiceException("Malformed binding ID (no '=' in "+token+")"); |
ohair@286 | 294 | r.parameters.put(token.substring(0,idx),token.substring(idx+1)); |
ohair@286 | 295 | } |
ohair@286 | 296 | } catch (UnsupportedEncodingException e) { |
ohair@286 | 297 | throw new AssertionError(e); // UTF-8 is supported everywhere |
ohair@286 | 298 | } |
ohair@286 | 299 | |
ohair@286 | 300 | return r; |
ohair@286 | 301 | } |
ohair@286 | 302 | |
ohair@286 | 303 | |
ohair@286 | 304 | /** |
ohair@286 | 305 | * Figures out the binding from {@link BindingType} annotation. |
ohair@286 | 306 | * |
ohair@286 | 307 | * @return |
ohair@286 | 308 | * default to {@link BindingID#SOAP11_HTTP}, if no such annotation is present. |
ohair@286 | 309 | * @see #parse(String) |
ohair@286 | 310 | */ |
ohair@286 | 311 | public static @NotNull BindingID parse(Class<?> implClass) { |
ohair@286 | 312 | BindingType bindingType = implClass.getAnnotation(BindingType.class); |
ohair@286 | 313 | if (bindingType != null) { |
ohair@286 | 314 | String bindingId = bindingType.value(); |
ohair@286 | 315 | if (bindingId.length() > 0) { |
ohair@286 | 316 | return BindingID.parse(bindingId); |
ohair@286 | 317 | } |
ohair@286 | 318 | } |
ohair@286 | 319 | return SOAP11_HTTP; |
ohair@286 | 320 | } |
ohair@286 | 321 | |
ohair@286 | 322 | /** |
ohair@286 | 323 | * Constant that represents implementation specific SOAP1.2/HTTP which is |
ohair@286 | 324 | * used to generate non-standard WSDLs |
ohair@286 | 325 | */ |
ohair@286 | 326 | public static final SOAPHTTPImpl X_SOAP12_HTTP = new SOAPHTTPImpl( |
ohair@286 | 327 | SOAPVersion.SOAP_12, SOAPBindingImpl.X_SOAP12HTTP_BINDING, true); |
ohair@286 | 328 | |
ohair@286 | 329 | /** |
ohair@286 | 330 | * Constant that represents SOAP1.2/HTTP. |
ohair@286 | 331 | */ |
ohair@286 | 332 | public static final SOAPHTTPImpl SOAP12_HTTP = new SOAPHTTPImpl( |
ohair@286 | 333 | SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_BINDING, true); |
ohair@286 | 334 | /** |
ohair@286 | 335 | * Constant that represents SOAP1.1/HTTP. |
ohair@286 | 336 | */ |
ohair@286 | 337 | public static final SOAPHTTPImpl SOAP11_HTTP = new SOAPHTTPImpl( |
ohair@286 | 338 | SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_BINDING, true); |
ohair@286 | 339 | |
ohair@286 | 340 | /** |
ohair@286 | 341 | * Constant that represents SOAP1.2/HTTP. |
ohair@286 | 342 | */ |
ohair@286 | 343 | public static final SOAPHTTPImpl SOAP12_HTTP_MTOM = new SOAPHTTPImpl( |
ohair@286 | 344 | SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_MTOM_BINDING, true, true); |
ohair@286 | 345 | /** |
ohair@286 | 346 | * Constant that represents SOAP1.1/HTTP. |
ohair@286 | 347 | */ |
ohair@286 | 348 | public static final SOAPHTTPImpl SOAP11_HTTP_MTOM = new SOAPHTTPImpl( |
ohair@286 | 349 | SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_MTOM_BINDING, true, true); |
ohair@286 | 350 | |
ohair@286 | 351 | |
ohair@286 | 352 | /** |
ohair@286 | 353 | * Constant that represents REST. |
ohair@286 | 354 | */ |
ohair@286 | 355 | public static final BindingID XML_HTTP = new Impl(SOAPVersion.SOAP_11, HTTPBinding.HTTP_BINDING,false) { |
ohair@286 | 356 | public Codec createEncoder(WSBinding binding) { |
ohair@286 | 357 | return new XMLHTTPBindingCodec(binding.getFeatures()); |
ohair@286 | 358 | } |
ohair@286 | 359 | }; |
ohair@286 | 360 | |
ohair@286 | 361 | /** |
ohair@286 | 362 | * Constant that represents REST. |
ohair@286 | 363 | */ |
ohair@286 | 364 | private static final BindingID REST_HTTP = new Impl(SOAPVersion.SOAP_11, JAXWSProperties.REST_BINDING,true) { |
ohair@286 | 365 | public Codec createEncoder(WSBinding binding) { |
ohair@286 | 366 | return new XMLHTTPBindingCodec(binding.getFeatures()); |
ohair@286 | 367 | } |
ohair@286 | 368 | }; |
ohair@286 | 369 | |
ohair@286 | 370 | private static abstract class Impl extends BindingID { |
ohair@286 | 371 | final SOAPVersion version; |
ohair@286 | 372 | private final String lexical; |
ohair@286 | 373 | private final boolean canGenerateWSDL; |
ohair@286 | 374 | |
ohair@286 | 375 | public Impl(SOAPVersion version, String lexical, boolean canGenerateWSDL) { |
ohair@286 | 376 | this.version = version; |
ohair@286 | 377 | this.lexical = lexical; |
ohair@286 | 378 | this.canGenerateWSDL = canGenerateWSDL; |
ohair@286 | 379 | } |
ohair@286 | 380 | |
ohair@286 | 381 | public SOAPVersion getSOAPVersion() { |
ohair@286 | 382 | return version; |
ohair@286 | 383 | } |
ohair@286 | 384 | |
ohair@286 | 385 | public String toString() { |
ohair@286 | 386 | return lexical; |
ohair@286 | 387 | } |
ohair@286 | 388 | |
ohair@286 | 389 | @Deprecated |
ohair@286 | 390 | public boolean canGenerateWSDL() { |
ohair@286 | 391 | return canGenerateWSDL; |
ohair@286 | 392 | } |
ohair@286 | 393 | } |
ohair@286 | 394 | |
ohair@286 | 395 | /** |
ohair@286 | 396 | * Internal implementation for SOAP/HTTP. |
ohair@286 | 397 | */ |
ohair@286 | 398 | private static final class SOAPHTTPImpl extends Impl implements Cloneable { |
ohair@286 | 399 | /*final*/ Map<String,String> parameters = new HashMap<String,String>(); |
ohair@286 | 400 | |
ohair@286 | 401 | static final String MTOM_PARAM = "mtom"; |
ohair@286 | 402 | Boolean mtomSetting = null; |
ohair@286 | 403 | |
ohair@286 | 404 | public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL) { |
ohair@286 | 405 | super(version, lexical, canGenerateWSDL); |
ohair@286 | 406 | } |
ohair@286 | 407 | |
ohair@286 | 408 | public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL, |
ohair@286 | 409 | boolean mtomEnabled) { |
ohair@286 | 410 | this(version, lexical, canGenerateWSDL); |
ohair@286 | 411 | String mtomStr = mtomEnabled ? "true" : "false"; |
ohair@286 | 412 | parameters.put(MTOM_PARAM, mtomStr); |
ohair@286 | 413 | mtomSetting = mtomEnabled; |
ohair@286 | 414 | } |
ohair@286 | 415 | |
ohair@286 | 416 | public @NotNull Codec createEncoder(WSBinding binding) { |
ohair@286 | 417 | return new SOAPBindingCodec(binding.getFeatures()); |
ohair@286 | 418 | } |
ohair@286 | 419 | |
ohair@286 | 420 | private Boolean isMTOMEnabled() { |
ohair@286 | 421 | String mtom = parameters.get(MTOM_PARAM); |
ohair@286 | 422 | return mtom==null?null:Boolean.valueOf(mtom); |
ohair@286 | 423 | } |
ohair@286 | 424 | |
ohair@286 | 425 | public WebServiceFeatureList createBuiltinFeatureList() { |
ohair@286 | 426 | WebServiceFeatureList r=super.createBuiltinFeatureList(); |
ohair@286 | 427 | Boolean mtom = isMTOMEnabled(); |
ohair@286 | 428 | if(mtom != null) |
ohair@286 | 429 | r.add(new MTOMFeature(mtom)); |
ohair@286 | 430 | return r; |
ohair@286 | 431 | } |
ohair@286 | 432 | |
ohair@286 | 433 | public String getParameter(String parameterName, String defaultValue) { |
ohair@286 | 434 | if (parameters.get(parameterName) == null) |
ohair@286 | 435 | return super.getParameter(parameterName, defaultValue); |
ohair@286 | 436 | return parameters.get(parameterName); |
ohair@286 | 437 | } |
ohair@286 | 438 | } |
ohair@286 | 439 | } |