src/share/jaxws_classes/com/sun/xml/internal/ws/api/pipe/ClientTubeAssemblerContext.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, 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.pipe;
ohair@286 27
ohair@286 28 import com.sun.istack.internal.NotNull;
ohair@286 29 import com.sun.istack.internal.Nullable;
ohair@286 30 import com.sun.xml.internal.ws.addressing.W3CWsaClientTube;
ohair@286 31 import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionWsaClientTube;
ohair@286 32 import com.sun.xml.internal.ws.api.EndpointAddress;
ohair@286 33 import com.sun.xml.internal.ws.api.WSBinding;
ohair@286 34 import com.sun.xml.internal.ws.api.WSService;
ohair@286 35 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
ohair@286 36 import com.sun.xml.internal.ws.api.client.ClientPipelineHook;
ohair@286 37 import com.sun.xml.internal.ws.api.client.WSPortInfo;
ohair@286 38 import com.sun.xml.internal.ws.api.model.SEIModel;
ohair@286 39 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
ohair@286 40 import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
ohair@286 41 import com.sun.xml.internal.ws.api.server.Container;
ohair@286 42 import com.sun.xml.internal.ws.binding.BindingImpl;
ohair@286 43 import com.sun.xml.internal.ws.client.ClientSchemaValidationTube;
ohair@286 44 import com.sun.xml.internal.ws.developer.SchemaValidationFeature;
ohair@286 45 import com.sun.xml.internal.ws.developer.WSBindingProvider;
ohair@286 46 import com.sun.xml.internal.ws.handler.ClientLogicalHandlerTube;
ohair@286 47 import com.sun.xml.internal.ws.handler.ClientMessageHandlerTube;
ohair@286 48 import com.sun.xml.internal.ws.handler.ClientSOAPHandlerTube;
ohair@286 49 import com.sun.xml.internal.ws.handler.HandlerTube;
ohair@286 50 import com.sun.xml.internal.ws.protocol.soap.ClientMUTube;
ohair@286 51 import com.sun.xml.internal.ws.transport.DeferredTransportPipe;
ohair@286 52 import com.sun.xml.internal.ws.util.pipe.DumpTube;
ohair@286 53
ohair@286 54 import javax.xml.ws.soap.SOAPBinding;
ohair@286 55 import java.io.PrintStream;
ohair@286 56
ohair@286 57 /**
ohair@286 58 * Factory for well-known {@link Tube} implementations
ohair@286 59 * that the {@link TubelineAssembler} needs to use
ohair@286 60 * to satisfy JAX-WS requirements.
ohair@286 61 *
ohair@286 62 * @author Jitendra Kotamraju
ohair@286 63 */
ohair@286 64 public class ClientTubeAssemblerContext {
ohair@286 65
ohair@286 66 private final @NotNull EndpointAddress address;
ohair@286 67 private final @Nullable WSDLPort wsdlModel;
ohair@286 68 private final @Nullable SEIModel seiModel;
ohair@286 69 private final @Nullable Class sei;
ohair@286 70 private final @NotNull WSService rootOwner;
ohair@286 71 private final @NotNull WSBinding binding;
ohair@286 72 private final @NotNull Container container;
ohair@286 73 private @NotNull Codec codec;
ohair@286 74
ohair@286 75 //Nullable only to maintain comaptibility with old constructors of this class.
ohair@286 76 private final @Nullable WSBindingProvider bindingProvider;
ohair@286 77
ohair@286 78 /**
ohair@286 79 * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
ohair@286 80 * @deprecated
alanb@368 81 * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
ohair@286 82 */
ohair@286 83 public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel, @NotNull WSService rootOwner, @NotNull WSBinding binding) {
ohair@286 84 this(address, wsdlModel, rootOwner, binding, Container.NONE);
ohair@286 85 }
ohair@286 86
ohair@286 87 /**
ohair@286 88 * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
ohair@286 89 * @deprecated
alanb@368 90 * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
ohair@286 91 */
ohair@286 92 public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
ohair@286 93 @NotNull WSService rootOwner, @NotNull WSBinding binding,
ohair@286 94 @NotNull Container container) {
ohair@286 95 // WSBinding is actually BindingImpl
ohair@286 96 this(address, wsdlModel, rootOwner, binding, container, ((BindingImpl)binding).createCodec() );
ohair@286 97 }
ohair@286 98
ohair@286 99 /**
ohair@286 100 * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
ohair@286 101 * @deprecated
alanb@368 102 * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
ohair@286 103 */
ohair@286 104 public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
ohair@286 105 @NotNull WSService rootOwner, @NotNull WSBinding binding,
ohair@286 106 @NotNull Container container, Codec codec) {
ohair@286 107 this(address, wsdlModel, rootOwner, binding, container, codec, null, null);
ohair@286 108 }
ohair@286 109
ohair@286 110 /**
ohair@286 111 * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
ohair@286 112 * @deprecated
alanb@368 113 * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSService, WSBindingProvider, WSBinding, Container, Codec, SEIModel, Class)}
ohair@286 114 */
ohair@286 115 public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
ohair@286 116 @NotNull WSService rootOwner, @NotNull WSBinding binding,
ohair@286 117 @NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
ohair@286 118 this(address, wsdlModel, rootOwner, null/* no info on which port it is, so pass null*/, binding, container, codec, seiModel, sei);
ohair@286 119 }
ohair@286 120
ohair@286 121 /**
ohair@286 122 * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
ohair@286 123 *
ohair@286 124 * @since JAX-WS 2.2
ohair@286 125 */
ohair@286 126 public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
ohair@286 127 @NotNull WSBindingProvider bindingProvider, @NotNull WSBinding binding,
ohair@286 128 @NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
ohair@286 129 this(address, wsdlModel, (bindingProvider==null? null: bindingProvider.getPortInfo().getOwner()), bindingProvider, binding, container, codec, seiModel, sei);
ohair@286 130
ohair@286 131 }
ohair@286 132
ohair@286 133 //common constructor
ohair@286 134 //WSService is null, when ClientTubeAssemblerContext is created for sending non-anonymous responses.
ohair@286 135 private ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
ohair@286 136 @Nullable WSService rootOwner, @Nullable WSBindingProvider bindingProvider, @NotNull WSBinding binding,
ohair@286 137 @NotNull Container container, Codec codec, SEIModel seiModel, Class sei) {
ohair@286 138 this.address = address;
ohair@286 139 this.wsdlModel = wsdlModel;
ohair@286 140 this.rootOwner = rootOwner;
ohair@286 141 this.bindingProvider = bindingProvider;
ohair@286 142 this.binding = binding;
ohair@286 143 this.container = container;
ohair@286 144 this.codec = codec;
ohair@286 145 this.seiModel = seiModel;
ohair@286 146 this.sei = sei;
ohair@286 147 }
ohair@286 148
ohair@286 149 /**
ohair@286 150 * The endpoint address. Always non-null. This parameter is taken separately
ohair@286 151 * from {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort} (even though there's {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort#getAddress()})
ohair@286 152 * because sometimes WSDL is not available.
ohair@286 153 */
ohair@286 154 public @NotNull EndpointAddress getAddress() {
ohair@286 155 return address;
ohair@286 156 }
ohair@286 157
ohair@286 158 /**
ohair@286 159 * The created pipeline will be used to serve this port.
ohair@286 160 * Null if the service isn't associated with any port definition in WSDL,
ohair@286 161 * and otherwise non-null.
ohair@286 162 */
ohair@286 163 public @Nullable WSDLPort getWsdlModel() {
ohair@286 164 return wsdlModel;
ohair@286 165 }
ohair@286 166
ohair@286 167 /**
ohair@286 168 * The pipeline is created for this {@link com.sun.xml.internal.ws.api.WSService}.
ohair@286 169 * Always non-null. (To be precise, the newly created pipeline
ohair@286 170 * is owned by a proxy or a dispatch created from thsi {@link com.sun.xml.internal.ws.api.WSService}.)
ohair@286 171 */
ohair@286 172 public @NotNull WSService getService() {
ohair@286 173 return rootOwner;
ohair@286 174 }
ohair@286 175
ohair@286 176 /**
ohair@286 177 * The pipeline is created for this {@link com.sun.xml.internal.ws.api.client.WSPortInfo}.
ohair@286 178 * Nullable incase of backwards compatible usages of this class.
ohair@286 179 */
ohair@286 180 public @Nullable WSPortInfo getPortInfo() {
ohair@286 181 return bindingProvider == null? null: bindingProvider.getPortInfo();
ohair@286 182 }
ohair@286 183
ohair@286 184
ohair@286 185 /**
ohair@286 186 * The pipeline is created for this {@link WSBindingProvider}.
ohair@286 187 * Nullable incase of backwards compatible usages of this class.
ohair@286 188 */
ohair@286 189 public @Nullable WSBindingProvider getBindingProvider() {
ohair@286 190 return bindingProvider;
ohair@286 191 }
ohair@286 192
ohair@286 193 /**
ohair@286 194 * The binding of the new pipeline to be created.
ohair@286 195 */
ohair@286 196 public @NotNull WSBinding getBinding() {
ohair@286 197 return binding;
ohair@286 198 }
ohair@286 199
ohair@286 200 /**
ohair@286 201 * The created pipeline will use seiModel to get java concepts for the endpoint
ohair@286 202 *
ohair@286 203 * @return Null if the service doesn't have SEI model e.g. Dispatch,
ohair@286 204 * and otherwise non-null.
ohair@286 205 */
ohair@286 206 public @Nullable SEIModel getSEIModel() {
ohair@286 207 return seiModel;
ohair@286 208 }
ohair@286 209
ohair@286 210 /**
ohair@286 211 * The SEI class for the endpoint
ohair@286 212 *
ohair@286 213 * @return Null if the service doesn't have SEI model e.g. Dispatch,
ohair@286 214 * and otherwise non-null.
ohair@286 215 */
ohair@286 216 public @Nullable Class getSEI() {
ohair@286 217 return sei;
ohair@286 218 }
ohair@286 219
ohair@286 220 /**
ohair@286 221 * Returns the Container in which the client is running
ohair@286 222 *
ohair@286 223 * @return Container in which client is running
ohair@286 224 */
ohair@286 225 public Container getContainer() {
ohair@286 226 return container;
ohair@286 227 }
ohair@286 228
ohair@286 229 /**
ohair@286 230 * creates a {@link Tube} that dumps messages that pass through.
ohair@286 231 */
ohair@286 232 public Tube createDumpTube(String name, PrintStream out, Tube next) {
ohair@286 233 return new DumpTube(name, out, next);
ohair@286 234 }
ohair@286 235
ohair@286 236 /**
ohair@286 237 * Creates a {@link Tube} that adds container specific security
ohair@286 238 */
ohair@286 239 public @NotNull Tube createSecurityTube(@NotNull Tube next) {
ohair@286 240 ClientPipelineHook hook = container.getSPI(ClientPipelineHook.class);
ohair@286 241 if (hook != null) {
ohair@286 242 ClientPipeAssemblerContext ctxt = new ClientPipeAssemblerContext(address, wsdlModel,
ohair@286 243 rootOwner, binding, container);
ohair@286 244 return PipeAdapter.adapt(hook.createSecurityPipe(ctxt, PipeAdapter.adapt(next)));
ohair@286 245 }
ohair@286 246 return next;
ohair@286 247 }
ohair@286 248
ohair@286 249 /**
ohair@286 250 * Creates a {@link Tube} that invokes protocol and logical handlers.
ohair@286 251 */
ohair@286 252 public Tube createWsaTube(Tube next) {
ohair@286 253 if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
ohair@286 254 if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
ohair@286 255 return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
ohair@286 256 } else {
ohair@286 257 return new W3CWsaClientTube(wsdlModel, binding, next);
ohair@286 258 }
ohair@286 259 else
ohair@286 260 return next;
ohair@286 261 }
ohair@286 262
ohair@286 263 /**
ohair@286 264 * Creates a {@link Tube} that invokes protocol and logical handlers.
ohair@286 265 */
ohair@286 266 public Tube createHandlerTube(Tube next) {
ohair@286 267 HandlerTube cousinHandlerTube = null;
ohair@286 268 //XML/HTTP Binding can have only LogicalHandlerPipe
ohair@286 269 if (binding instanceof SOAPBinding) {
ohair@286 270 //Add MessageHandlerTube
ohair@286 271 HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
ohair@286 272 next = cousinHandlerTube = messageHandlerTube;
ohair@286 273
ohair@286 274 //Add SOAPHandlerTuber
ohair@286 275 HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
ohair@286 276 next = cousinHandlerTube = soapHandlerTube;
ohair@286 277 }
ohair@286 278 return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
ohair@286 279 }
ohair@286 280
ohair@286 281 /**
ohair@286 282 * Creates a {@link Tube} that performs SOAP mustUnderstand processing.
ohair@286 283 * This pipe should be before HandlerPipes.
ohair@286 284 */
ohair@286 285 public Tube createClientMUTube(Tube next) {
ohair@286 286 if(binding instanceof SOAPBinding)
ohair@286 287 return new ClientMUTube(binding,next);
ohair@286 288 else
ohair@286 289 return next;
ohair@286 290 }
ohair@286 291
ohair@286 292 /**
ohair@286 293 * creates a {@link Tube} that validates messages against schema
ohair@286 294 */
ohair@286 295 public Tube createValidationTube(Tube next) {
ohair@286 296 if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
ohair@286 297 return new ClientSchemaValidationTube(binding, wsdlModel, next);
ohair@286 298 else
ohair@286 299 return next;
ohair@286 300 }
ohair@286 301
ohair@286 302 /**
ohair@286 303 * Creates a transport pipe (for client), which becomes the terminal pipe.
ohair@286 304 */
ohair@286 305 public Tube createTransportTube() {
ohair@286 306 ClassLoader cl = Thread.currentThread().getContextClassLoader();
ohair@286 307
ohair@286 308 // The application may configure the endpoint address through request context
ohair@286 309 // using {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}. Let us
ohair@286 310 // defer the creation of actual transport until the service invocation,
ohair@286 311 // DeferredTransportPipe is used for this purpose.
ohair@286 312 return new DeferredTransportPipe(cl,this);
ohair@286 313 }
ohair@286 314
ohair@286 315 /**
ohair@286 316 * Gets the {@link Codec} that is set by {@link #setCodec} or the default codec
ohair@286 317 * based on the binding.
ohair@286 318 *
ohair@286 319 * @return codec to be used for web service requests
ohair@286 320 */
ohair@286 321 public @NotNull Codec getCodec() {
ohair@286 322 return codec;
ohair@286 323 }
ohair@286 324
ohair@286 325 /**
ohair@286 326 * Interception point to change {@link Codec} during {@link Tube}line assembly. The
ohair@286 327 * new codec will be used by jax-ws client runtime for encoding/decoding web service
ohair@286 328 * request/response messages. The new codec should be used by the transport tubes.
ohair@286 329 *
ohair@286 330 * <p>
ohair@286 331 * the codec should correctly implement {@link Codec#copy} since it is used while
ohair@286 332 * serving requests concurrently.
ohair@286 333 *
ohair@286 334 * @param codec codec to be used for web service requests
ohair@286 335 */
ohair@286 336 public void setCodec(@NotNull Codec codec) {
ohair@286 337 this.codec = codec;
ohair@286 338 }
ohair@286 339
ohair@286 340 }

mercurial