1/* 2 * Copyright (c) 1997, 2013, 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 */ 25 26/* 27 * To change this template, choose Tools | Templates 28 * and open the template in the editor. 29 */ 30package com.sun.xml.internal.ws.assembler; 31 32import com.sun.istack.internal.NotNull; 33import com.sun.istack.internal.Nullable; 34import com.sun.xml.internal.ws.api.EndpointAddress; 35import com.sun.xml.internal.ws.api.WSBinding; 36import com.sun.xml.internal.ws.api.WSService; 37import com.sun.xml.internal.ws.api.client.WSPortInfo; 38import com.sun.xml.internal.ws.api.model.SEIModel; 39import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; 40import com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext; 41import com.sun.xml.internal.ws.api.pipe.Codec; 42import com.sun.xml.internal.ws.api.server.Container; 43import com.sun.xml.internal.ws.assembler.dev.ClientTubelineAssemblyContext; 44import com.sun.xml.internal.ws.policy.PolicyMap; 45 46/** 47 * The context is a wrapper around the existing JAX-WS {@link ClientTubeAssemblerContext} with additional features 48 * 49 * @author Marek Potociar (marek.potociar at sun.com) 50 */ 51class DefaultClientTubelineAssemblyContext extends TubelineAssemblyContextImpl implements ClientTubelineAssemblyContext { 52 53 private final @NotNull ClientTubeAssemblerContext wrappedContext; 54 private final PolicyMap policyMap; 55 private final WSPortInfo portInfo; // TODO: is this really needed? 56 private final WSDLPort wsdlPort; 57 // TODO: replace the PipeConfiguration 58 59 public DefaultClientTubelineAssemblyContext(@NotNull ClientTubeAssemblerContext context) { 60 this.wrappedContext = context; 61 this.wsdlPort = context.getWsdlModel(); 62 this.portInfo = context.getPortInfo(); 63 this.policyMap = context.getPortInfo().getPolicyMap(); 64 } 65 66 public PolicyMap getPolicyMap() { 67 return policyMap; 68 } 69 70 public boolean isPolicyAvailable() { 71 return policyMap != null && !policyMap.isEmpty(); 72 } 73 74 /** 75 * The created pipeline will be used to serve this port. 76 * Null if the service isn't associated with any port definition in WSDL, 77 * and otherwise non-null. 78 * 79 * Replaces {@link com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext#getWsdlModel()} 80 */ 81 public WSDLPort getWsdlPort() { 82 return wsdlPort; 83 } 84 85 public WSPortInfo getPortInfo() { 86 return portInfo; 87 } 88 89 /** 90 * The endpoint address. Always non-null. This parameter is taken separately 91 * 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()}) 92 * because sometimes WSDL is not available. 93 */ 94 public @NotNull EndpointAddress getAddress() { 95 return wrappedContext.getAddress(); 96 } 97 98 /** 99 * The pipeline is created for this {@link com.sun.xml.internal.ws.api.WSService}. 100 * Always non-null. (To be precise, the newly created pipeline 101 * is owned by a proxy or a dispatch created from this {@link com.sun.xml.internal.ws.api.WSService}.) 102 */ 103 public @NotNull WSService getService() { 104 return wrappedContext.getService(); 105 } 106 107 /** 108 * The binding of the new pipeline to be created. 109 */ 110 public @NotNull WSBinding getBinding() { 111 return wrappedContext.getBinding(); 112 } 113 114 /** 115 * The created pipeline will use seiModel to get java concepts for the endpoint 116 * 117 * @return Null if the service doesn't have SEI model e.g. Dispatch, 118 * and otherwise non-null. 119 */ 120 public @Nullable SEIModel getSEIModel() { 121 return wrappedContext.getSEIModel(); 122 } 123 124 /** 125 * Returns the Container in which the client is running 126 * 127 * @return Container in which client is running 128 */ 129 public Container getContainer() { 130 return wrappedContext.getContainer(); 131 } 132 133 /** 134 * Gets the {@link Codec} that is set by {@link #setCodec} or the default codec 135 * based on the binding. 136 * 137 * @return codec to be used for web service requests 138 */ 139 public @NotNull Codec getCodec() { 140 return wrappedContext.getCodec(); 141 } 142 143 /** 144 * Interception point to change {@link Codec} during {@link com.sun.xml.internal.ws.api.pipe.Tube}line assembly. The 145 * new codec will be used by jax-ws client runtime for encoding/decoding web service 146 * request/response messages. The new codec should be used by the transport tubes. 147 * 148 * <p> 149 * the codec should correctly implement {@link Codec#copy} since it is used while 150 * serving requests concurrently. 151 * 152 * @param codec codec to be used for web service requests 153 */ 154 public void setCodec(@NotNull Codec codec) { 155 wrappedContext.setCodec(codec); 156 } 157 158 public ClientTubeAssemblerContext getWrappedContext() { 159 return wrappedContext; 160 } 161} 162