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

mercurial