325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.ws.api.pipe;
325N/A
325N/Aimport com.sun.istack.internal.NotNull;
325N/Aimport com.sun.istack.internal.Nullable;
325N/Aimport com.sun.xml.internal.ws.addressing.W3CWsaClientTube;
325N/Aimport com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionWsaClientTube;
325N/Aimport com.sun.xml.internal.ws.api.EndpointAddress;
325N/Aimport com.sun.xml.internal.ws.api.WSBinding;
325N/Aimport com.sun.xml.internal.ws.api.WSService;
325N/Aimport com.sun.xml.internal.ws.api.addressing.AddressingVersion;
325N/Aimport com.sun.xml.internal.ws.api.client.ClientPipelineHook;
325N/Aimport com.sun.xml.internal.ws.api.client.WSPortInfo;
325N/Aimport com.sun.xml.internal.ws.api.model.SEIModel;
325N/Aimport com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
325N/Aimport com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter;
325N/Aimport com.sun.xml.internal.ws.api.server.Container;
325N/Aimport com.sun.xml.internal.ws.binding.BindingImpl;
325N/Aimport com.sun.xml.internal.ws.client.ClientSchemaValidationTube;
325N/Aimport com.sun.xml.internal.ws.developer.SchemaValidationFeature;
325N/Aimport com.sun.xml.internal.ws.developer.WSBindingProvider;
325N/Aimport com.sun.xml.internal.ws.handler.ClientLogicalHandlerTube;
325N/Aimport com.sun.xml.internal.ws.handler.ClientMessageHandlerTube;
325N/Aimport com.sun.xml.internal.ws.handler.ClientSOAPHandlerTube;
325N/Aimport com.sun.xml.internal.ws.handler.HandlerTube;
325N/Aimport com.sun.xml.internal.ws.protocol.soap.ClientMUTube;
325N/Aimport com.sun.xml.internal.ws.transport.DeferredTransportPipe;
325N/Aimport com.sun.xml.internal.ws.util.pipe.DumpTube;
325N/A
325N/Aimport javax.xml.ws.soap.SOAPBinding;
325N/Aimport java.io.PrintStream;
325N/A
325N/A/**
325N/A * Factory for well-known {@link Tube} implementations
325N/A * that the {@link TubelineAssembler} needs to use
325N/A * to satisfy JAX-WS requirements.
325N/A *
325N/A * @author Jitendra Kotamraju
325N/A */
325N/Apublic class ClientTubeAssemblerContext {
325N/A
325N/A private final @NotNull EndpointAddress address;
325N/A private final @Nullable WSDLPort wsdlModel;
325N/A private final @Nullable SEIModel seiModel;
325N/A private final @NotNull WSService rootOwner;
325N/A private final @NotNull WSBinding binding;
325N/A private final @NotNull Container container;
325N/A private @NotNull Codec codec;
325N/A
325N/A //Nullable only to maintain comaptibility with old constructors of this class.
325N/A private final @Nullable WSBindingProvider bindingProvider;
325N/A
325N/A /**
325N/A * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
325N/A * @deprecated
325N/A * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSBindingProvider, WSBinding, Container, Codec, SEIModel)}
325N/A */
325N/A public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel, @NotNull WSService rootOwner, @NotNull WSBinding binding) {
325N/A this(address, wsdlModel, rootOwner, binding, Container.NONE);
325N/A }
325N/A
325N/A /**
325N/A * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
325N/A * @deprecated
325N/A * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSBindingProvider, WSBinding, Container, Codec, SEIModel)}.
325N/A */
325N/A public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
325N/A @NotNull WSService rootOwner, @NotNull WSBinding binding,
325N/A @NotNull Container container) {
325N/A // WSBinding is actually BindingImpl
325N/A this(address, wsdlModel, rootOwner, binding, container, ((BindingImpl)binding).createCodec() );
325N/A }
325N/A
325N/A /**
325N/A * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
325N/A * @deprecated
325N/A * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSBindingProvider, WSBinding, Container, Codec,SEIModel)}.
325N/A */
325N/A public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
325N/A @NotNull WSService rootOwner, @NotNull WSBinding binding,
325N/A @NotNull Container container, Codec codec) {
325N/A this(address, wsdlModel, rootOwner, binding, container, codec, null);
325N/A }
325N/A
325N/A /**
325N/A * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
325N/A * @deprecated
325N/A * Use {@link #ClientTubeAssemblerContext(EndpointAddress, WSDLPort, WSBindingProvider, WSBinding, Container, Codec, SEIModel)}.
325N/A */
325N/A public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
325N/A @NotNull WSService rootOwner, @NotNull WSBinding binding,
325N/A @NotNull Container container, Codec codec, SEIModel seiModel) {
325N/A this(address, wsdlModel, rootOwner, null/* no info on which port it is, so pass null*/, binding, container, codec,seiModel);
325N/A }
325N/A
325N/A /**
325N/A * This constructor should be used only by JAX-WS Runtime and is not meant for external consumption.
325N/A *
325N/A * @since JAX-WS 2.2
325N/A */
325N/A public ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
325N/A @NotNull WSBindingProvider bindingProvider, @NotNull WSBinding binding,
325N/A @NotNull Container container, Codec codec, SEIModel seiModel) {
325N/A this(address, wsdlModel, (bindingProvider==null? null: bindingProvider.getPortInfo().getOwner()), bindingProvider, binding, container, codec,seiModel);
325N/A
325N/A }
325N/A
325N/A //common constructor
325N/A //WSService is null, when ClientTubeAssemblerContext is created for sending non-anonymous responses.
325N/A private ClientTubeAssemblerContext(@NotNull EndpointAddress address, @Nullable WSDLPort wsdlModel,
325N/A @Nullable WSService rootOwner, @Nullable WSBindingProvider bindingProvider, @NotNull WSBinding binding,
325N/A @NotNull Container container, Codec codec, SEIModel seiModel) {
325N/A this.address = address;
325N/A this.wsdlModel = wsdlModel;
325N/A this.rootOwner = rootOwner;
325N/A this.bindingProvider = bindingProvider;
325N/A this.binding = binding;
325N/A this.container = container;
325N/A this.codec = codec;
325N/A this.seiModel = seiModel;
325N/A }
325N/A
325N/A /**
325N/A * The endpoint address. Always non-null. This parameter is taken separately
325N/A * 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()})
325N/A * because sometimes WSDL is not available.
325N/A */
325N/A public @NotNull EndpointAddress getAddress() {
325N/A return address;
325N/A }
325N/A
325N/A /**
325N/A * The created pipeline will be used to serve this port.
325N/A * Null if the service isn't associated with any port definition in WSDL,
325N/A * and otherwise non-null.
325N/A */
325N/A public @Nullable WSDLPort getWsdlModel() {
325N/A return wsdlModel;
325N/A }
325N/A
325N/A /**
325N/A * The pipeline is created for this {@link com.sun.xml.internal.ws.api.WSService}.
325N/A * Always non-null. (To be precise, the newly created pipeline
325N/A * is owned by a proxy or a dispatch created from thsi {@link com.sun.xml.internal.ws.api.WSService}.)
325N/A */
325N/A public @NotNull WSService getService() {
325N/A return rootOwner;
325N/A }
325N/A
325N/A /**
325N/A * The pipeline is created for this {@link com.sun.xml.internal.ws.api.client.WSPortInfo}.
325N/A * Nullable incase of backwards compatible usages of this class.
325N/A */
325N/A public @Nullable WSPortInfo getPortInfo() {
325N/A return bindingProvider == null? null: bindingProvider.getPortInfo();
325N/A }
325N/A
325N/A
325N/A /**
325N/A * The pipeline is created for this {@link WSBindingProvider}.
325N/A * Nullable incase of backwards compatible usages of this class.
325N/A */
325N/A public @Nullable WSBindingProvider getBindingProvider() {
325N/A return bindingProvider;
325N/A }
325N/A
325N/A /**
325N/A * The binding of the new pipeline to be created.
325N/A */
325N/A public @NotNull WSBinding getBinding() {
325N/A return binding;
325N/A }
325N/A
325N/A /**
325N/A * The created pipeline will use seiModel to get java concepts for the endpoint
325N/A *
325N/A * @return Null if the service doesn't have SEI model e.g. Dispatch,
325N/A * and otherwise non-null.
325N/A */
325N/A public @Nullable SEIModel getSEIModel() {
325N/A return seiModel;
325N/A }
325N/A
325N/A /**
325N/A * Returns the Container in which the client is running
325N/A *
325N/A * @return Container in which client is running
325N/A */
325N/A public Container getContainer() {
325N/A return container;
325N/A }
325N/A
325N/A /**
325N/A * creates a {@link Tube} that dumps messages that pass through.
325N/A */
325N/A public Tube createDumpTube(String name, PrintStream out, Tube next) {
325N/A return new DumpTube(name, out, next);
325N/A }
325N/A
325N/A /**
325N/A * Creates a {@link Tube} that adds container specific security
325N/A */
325N/A public @NotNull Tube createSecurityTube(@NotNull Tube next) {
325N/A ClientPipelineHook hook = container.getSPI(ClientPipelineHook.class);
325N/A if (hook != null) {
325N/A ClientPipeAssemblerContext ctxt = new ClientPipeAssemblerContext(address, wsdlModel,
325N/A rootOwner, binding, container);
325N/A return PipeAdapter.adapt(hook.createSecurityPipe(ctxt, PipeAdapter.adapt(next)));
325N/A }
325N/A return next;
325N/A }
325N/A
325N/A /**
325N/A * Creates a {@link Tube} that invokes protocol and logical handlers.
325N/A */
325N/A public Tube createWsaTube(Tube next) {
325N/A if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
325N/A if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
325N/A return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
325N/A } else {
325N/A return new W3CWsaClientTube(wsdlModel, binding, next);
325N/A }
325N/A else
325N/A return next;
325N/A }
325N/A
325N/A /**
325N/A * Creates a {@link Tube} that invokes protocol and logical handlers.
325N/A */
325N/A public Tube createHandlerTube(Tube next) {
325N/A HandlerTube cousinHandlerTube = null;
325N/A //XML/HTTP Binding can have only LogicalHandlerPipe
325N/A if (binding instanceof SOAPBinding) {
325N/A //Add MessageHandlerTube
325N/A HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
325N/A next = cousinHandlerTube = messageHandlerTube;
325N/A
325N/A //Add SOAPHandlerTuber
325N/A HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
325N/A next = cousinHandlerTube = soapHandlerTube;
325N/A }
325N/A return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
325N/A }
325N/A
325N/A /**
325N/A * Creates a {@link Tube} that performs SOAP mustUnderstand processing.
325N/A * This pipe should be before HandlerPipes.
325N/A */
325N/A public Tube createClientMUTube(Tube next) {
325N/A if(binding instanceof SOAPBinding)
325N/A return new ClientMUTube(binding,next);
325N/A else
325N/A return next;
325N/A }
325N/A
325N/A /**
325N/A * creates a {@link Tube} that validates messages against schema
325N/A */
325N/A public Tube createValidationTube(Tube next) {
325N/A if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
325N/A return new ClientSchemaValidationTube(binding, wsdlModel, next);
325N/A else
325N/A return next;
325N/A }
325N/A
325N/A /**
325N/A * Creates a transport pipe (for client), which becomes the terminal pipe.
325N/A */
325N/A public Tube createTransportTube() {
325N/A ClassLoader cl = Thread.currentThread().getContextClassLoader();
325N/A
325N/A // The application may configure the endpoint address through request context
325N/A // using {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}. Let us
325N/A // defer the creation of actual transport until the service invocation,
325N/A // DeferredTransportPipe is used for this purpose.
325N/A return new DeferredTransportPipe(cl,this);
325N/A }
325N/A
325N/A /**
325N/A * Gets the {@link Codec} that is set by {@link #setCodec} or the default codec
325N/A * based on the binding.
325N/A *
325N/A * @return codec to be used for web service requests
325N/A */
325N/A public @NotNull Codec getCodec() {
325N/A return codec;
325N/A }
325N/A
325N/A /**
325N/A * Interception point to change {@link Codec} during {@link Tube}line assembly. The
325N/A * new codec will be used by jax-ws client runtime for encoding/decoding web service
325N/A * request/response messages. The new codec should be used by the transport tubes.
325N/A *
325N/A * <p>
325N/A * the codec should correctly implement {@link Codec#copy} since it is used while
325N/A * serving requests concurrently.
325N/A *
325N/A * @param codec codec to be used for web service requests
325N/A */
325N/A public void setCodec(@NotNull Codec codec) {
325N/A this.codec = codec;
325N/A }
325N/A
325N/A}