src/share/jaxws_classes/com/sun/xml/internal/ws/client/PortInfo.java

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

ohair@286 1 /*
mkos@408 2 * Copyright (c) 1997, 2013, 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.client;
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.api.BindingID;
ohair@286 31 import com.sun.xml.internal.ws.api.EndpointAddress;
ohair@286 32 import com.sun.xml.internal.ws.api.WSService;
ohair@286 33 import com.sun.xml.internal.ws.api.policy.PolicyResolverFactory;
ohair@286 34 import com.sun.xml.internal.ws.api.policy.PolicyResolver;
ohair@286 35 import com.sun.xml.internal.ws.api.client.WSPortInfo;
ohair@286 36 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
ohair@286 37 import com.sun.xml.internal.ws.binding.BindingImpl;
ohair@286 38 import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
ohair@286 39 import com.sun.xml.internal.ws.policy.PolicyMap;
ohair@286 40 import com.sun.xml.internal.ws.policy.jaxws.PolicyUtil;
ohair@286 41
ohair@286 42 import javax.xml.namespace.QName;
ohair@286 43 import javax.xml.ws.WebServiceFeature;
ohair@286 44
ohair@286 45 /**
ohair@286 46 * Information about a port.
ohair@286 47 * <p/>
ohair@286 48 * This object is owned by {@link WSServiceDelegate} to keep track of a port,
ohair@286 49 * since a port maybe added dynamically.
ohair@286 50 *
ohair@286 51 * @author JAXWS Development Team
ohair@286 52 */
ohair@286 53 public class PortInfo implements WSPortInfo {
ohair@286 54 private final @NotNull WSServiceDelegate owner;
ohair@286 55
ohair@286 56 public final @NotNull QName portName;
ohair@286 57 public final @NotNull EndpointAddress targetEndpoint;
ohair@286 58 public final @NotNull BindingID bindingId;
ohair@286 59
ohair@286 60 public final @NotNull PolicyMap policyMap;
ohair@286 61 /**
ohair@286 62 * If a port is known statically to a WSDL, {@link PortInfo} may
ohair@286 63 * have the corresponding WSDL model. This would occur when the
ohair@286 64 * service was created with the WSDL location and the port is defined
ohair@286 65 * in the WSDL.
ohair@286 66 * <p/>
ohair@286 67 * If this is a {@link SEIPortInfo}, then this is always non-null.
ohair@286 68 */
ohair@286 69 public final @Nullable WSDLPort portModel;
ohair@286 70
ohair@286 71 public PortInfo(WSServiceDelegate owner, EndpointAddress targetEndpoint, QName name, BindingID bindingId) {
ohair@286 72 this.owner = owner;
ohair@286 73 this.targetEndpoint = targetEndpoint;
ohair@286 74 this.portName = name;
ohair@286 75 this.bindingId = bindingId;
ohair@286 76 this.portModel = getPortModel(owner, name);
ohair@286 77 this.policyMap = createPolicyMap();
ohair@286 78
ohair@286 79 }
ohair@286 80
ohair@286 81 public PortInfo(@NotNull WSServiceDelegate owner, @NotNull WSDLPort port) {
ohair@286 82 this.owner = owner;
ohair@286 83 this.targetEndpoint = port.getAddress();
ohair@286 84 this.portName = port.getName();
ohair@286 85 this.bindingId = port.getBinding().getBindingId();
ohair@286 86 this.portModel = port;
ohair@286 87 this.policyMap = createPolicyMap();
ohair@286 88 }
ohair@286 89
ohair@286 90 public PolicyMap getPolicyMap() {
ohair@286 91 return policyMap;
ohair@286 92 }
ohair@286 93
ohair@286 94 public PolicyMap createPolicyMap() {
ohair@286 95 PolicyMap map;
ohair@286 96 if(portModel != null) {
mkos@408 97 map = portModel.getOwner().getParent().getPolicyMap();
ohair@286 98 } else {
ohair@286 99 map = PolicyResolverFactory.create().resolve(new PolicyResolver.ClientContext(null,owner.getContainer()));
ohair@286 100 }
ohair@286 101 //still map is null, create a empty map
ohair@286 102 if(map == null)
ohair@286 103 map = PolicyMap.createPolicyMap(null);
ohair@286 104 return map;
ohair@286 105 }
ohair@286 106 /**
ohair@286 107 * Creates {@link BindingImpl} for this {@link PortInfo}.
ohair@286 108 *
ohair@286 109 * @param webServiceFeatures
ohair@286 110 * User-specified features.
ohair@286 111 * @param portInterface
ohair@286 112 * Null if this is for dispatch. Otherwise the interface the proxy is going to implement
ohair@286 113 * @return
ohair@286 114 * The initialized BindingImpl
ohair@286 115 */
ohair@286 116 public BindingImpl createBinding(WebServiceFeature[] webServiceFeatures, Class<?> portInterface) {
ohair@286 117 return createBinding(new WebServiceFeatureList(webServiceFeatures), portInterface, null);
ohair@286 118 }
ohair@286 119
ohair@286 120 public BindingImpl createBinding(WebServiceFeatureList webServiceFeatures, Class<?> portInterface,
ohair@286 121 BindingImpl existingBinding) {
ohair@286 122 if (existingBinding != null) {
ohair@286 123 webServiceFeatures.addAll(existingBinding.getFeatures());
ohair@286 124 }
ohair@286 125
ohair@286 126 Iterable<WebServiceFeature> configFeatures;
ohair@286 127 //TODO incase of Dispatch, provide a way to User for complete control of the message processing by giving
ohair@286 128 // ability to turn off the WSDL/Policy based features and its associated tubes.
ohair@286 129
ohair@286 130 //Even in case of Dispatch, merge all features configured via WSDL/Policy or deployment configuration
ohair@286 131 if (portModel != null) {
ohair@286 132 // could have merged features from this.policyMap, but some features are set in WSDLModel which are not there in PolicyMap
ohair@286 133 // for ex: <wsaw:UsingAddressing> wsdl extn., and since the policyMap features are merged into WSDLModel anyway during postFinished(),
ohair@286 134 // So, using here WsdlModel for merging is right.
ohair@286 135
ohair@286 136 // merge features from WSDL
ohair@286 137 configFeatures = portModel.getFeatures();
ohair@286 138 } else {
ohair@286 139 configFeatures = PolicyUtil.getPortScopedFeatures(policyMap, owner.getServiceName(),portName);
ohair@286 140 }
ohair@286 141 webServiceFeatures.mergeFeatures(configFeatures, false);
ohair@286 142
ohair@286 143 // merge features from interceptor
ohair@286 144 webServiceFeatures.mergeFeatures(owner.serviceInterceptor.preCreateBinding(this, portInterface, webServiceFeatures), false);
ohair@286 145
ohair@286 146 BindingImpl bindingImpl = BindingImpl.create(bindingId, webServiceFeatures.toArray());
ohair@286 147 owner.getHandlerConfigurator().configureHandlers(this,bindingImpl);
ohair@286 148 return bindingImpl;
ohair@286 149 }
ohair@286 150
ohair@286 151 //This method is used for Dispatch client only
ohair@286 152 private WSDLPort getPortModel(WSServiceDelegate owner, QName portName) {
ohair@286 153
ohair@286 154 if (owner.getWsdlService() != null){
mkos@408 155 Iterable<? extends WSDLPort> ports = owner.getWsdlService().getPorts();
mkos@408 156 for (WSDLPort port : ports){
ohair@286 157 if (port.getName().equals(portName))
ohair@286 158 return port;
ohair@286 159 }
ohair@286 160 }
ohair@286 161 return null;
ohair@286 162 }
ohair@286 163
ohair@286 164 //
ohair@286 165 // implementation of API PortInfo interface
ohair@286 166 //
ohair@286 167
ohair@286 168 @Nullable
ohair@286 169 public WSDLPort getPort() {
ohair@286 170 return portModel;
ohair@286 171 }
ohair@286 172
ohair@286 173 @NotNull
ohair@286 174 public WSService getOwner() {
ohair@286 175 return owner;
ohair@286 176 }
ohair@286 177
ohair@286 178 @NotNull
ohair@286 179 public BindingID getBindingId() {
ohair@286 180 return bindingId;
ohair@286 181 }
ohair@286 182
ohair@286 183 @NotNull
ohair@286 184 public EndpointAddress getEndpointAddress() {
ohair@286 185 return targetEndpoint;
ohair@286 186 }
ohair@286 187
ohair@286 188 /**
ohair@286 189 * @deprecated
ohair@286 190 * Only meant to be used via {@link javax.xml.ws.handler.PortInfo}.
ohair@286 191 * Use {@link WSServiceDelegate#getServiceName()}.
ohair@286 192 */
ohair@286 193 public QName getServiceName() {
ohair@286 194 return owner.getServiceName();
ohair@286 195 }
ohair@286 196
ohair@286 197 /**
ohair@286 198 * Only meant to be used via {@link javax.xml.ws.handler.PortInfo}.
ohair@286 199 * Use {@link #portName}.
ohair@286 200 */
ohair@286 201 public QName getPortName() {
ohair@286 202 return portName;
ohair@286 203 }
ohair@286 204
ohair@286 205 /**
ohair@286 206 * @deprecated
ohair@286 207 * Only meant to be used via {@link javax.xml.ws.handler.PortInfo}.
ohair@286 208 * Use {@link #bindingId}.
ohair@286 209 */
ohair@286 210 public String getBindingID() {
ohair@286 211 return bindingId.toString();
ohair@286 212 }
ohair@286 213 }

mercurial