1 23 package com.sun.enterprise.deployment; 24 25 import java.util.List ; 26 import java.util.LinkedList ; 27 import java.util.Map ; 28 import java.util.HashMap ; 29 import java.util.Collection ; 30 import java.util.HashSet ; 31 import java.util.Set ; 32 import java.util.Iterator ; 33 34 import java.io.*; 35 36 import java.net.URL ; 37 import java.net.MalformedURLException ; 38 import javax.xml.namespace.QName ; 39 import javax.xml.rpc.Stub ; 40 41 import com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor; 42 43 48 49 public class ServiceRefPortInfo extends Descriptor { 50 51 private String serviceEndpointInterface; 52 53 private boolean containerManaged; 54 55 private String portComponentLinkName; 56 private WebServiceEndpoint portComponentLink; 57 58 private ServiceReferenceDescriptor serviceRef; 60 61 65 private QName wsdlPort; 66 67 private Set stubProperties; 69 70 private Set callProperties; 72 73 private String targetEndpointAddress; 76 77 private MessageSecurityBindingDescriptor messageSecBindingDesc = null; 79 80 private String mtomEnabled = null; 81 82 public ServiceRefPortInfo(ServiceRefPortInfo other) { 83 super(other); 84 serviceEndpointInterface = other.serviceEndpointInterface; 85 containerManaged = other.containerManaged; 86 portComponentLinkName = other.portComponentLinkName; 87 portComponentLink = other.portComponentLink; serviceRef = other.serviceRef; wsdlPort = other.wsdlPort; mtomEnabled = other.mtomEnabled; 91 92 stubProperties = new HashSet (); 93 for (Iterator i = other.stubProperties.iterator(); i.hasNext();) { 94 stubProperties.add(new NameValuePairDescriptor 95 ((NameValuePairDescriptor)i.next())); 96 } 97 98 callProperties = new HashSet (); for (Iterator i = other.callProperties.iterator(); i.hasNext();) { 100 callProperties.add(new NameValuePairDescriptor( 101 (NameValuePairDescriptor)i.next())); 102 } 103 104 targetEndpointAddress = other.targetEndpointAddress; 105 } 106 107 public ServiceRefPortInfo() { 108 stubProperties = new HashSet (); 109 callProperties = new HashSet (); 110 containerManaged = false; 111 } 112 113 public void setServiceReference(ServiceReferenceDescriptor desc) { 114 serviceRef = desc; 115 } 116 117 public ServiceReferenceDescriptor getServiceReference() { 118 return serviceRef; 119 } 120 121 public boolean hasServiceEndpointInterface() { 122 return (serviceEndpointInterface != null); 123 } 124 125 public void setServiceEndpointInterface(String sei) { 126 serviceEndpointInterface = sei; 127 } 128 129 public String getServiceEndpointInterface() { 130 return serviceEndpointInterface; 131 } 132 133 public void setIsContainerManaged(boolean flag) { 134 containerManaged = flag; 135 } 136 137 public boolean isContainerManaged() { 138 return containerManaged; 139 } 140 141 public boolean isClientManaged() { 142 return !containerManaged; 143 } 144 145 151 public void setPortComponentLinkName(String linkName) { 152 setPortComponentLinkName(linkName, false); 153 } 154 155 public WebServiceEndpoint setPortComponentLinkName(String linkName, 156 boolean resolve) { 157 portComponentLinkName = linkName; 158 159 return resolve ? resolveLinkName() : null; 160 } 161 162 public boolean hasPortComponentLinkName() { 163 return (portComponentLinkName != null); 164 } 165 166 public String getPortComponentLinkName() { 167 return portComponentLinkName; 168 } 169 170 public void setMessageSecurityBinding( 171 MessageSecurityBindingDescriptor messageSecBindingDesc) { 172 this.messageSecBindingDesc = messageSecBindingDesc; 173 } 174 175 public MessageSecurityBindingDescriptor getMessageSecurityBinding() { 176 return messageSecBindingDesc; 177 } 178 179 183 public boolean isLinkedToPortComponent() { 184 return (portComponentLinkName != null ) && (portComponentLink != null); 185 } 186 187 194 public WebServiceEndpoint resolveLinkName() { 195 196 WebServiceEndpoint port = null; 197 String linkName = portComponentLinkName; 198 199 if( (linkName != null) && (linkName.length() > 0) ) { 200 int hashIndex = linkName.indexOf('#'); 201 boolean absoluteLink = (hashIndex != -1); 202 203 BundleDescriptor bundleDescriptor = getBundleDescriptor(); 204 Application app = bundleDescriptor.getApplication(); 205 BundleDescriptor targetBundle = bundleDescriptor; 206 String portName = linkName; 207 208 if( (app != null) && absoluteLink ) { 209 String relativeModuleUri = linkName.substring(0, hashIndex); 211 portName = linkName.substring(hashIndex + 1); 212 targetBundle = app.getRelativeBundle(bundleDescriptor, 213 relativeModuleUri); 214 } 215 216 if( targetBundle != null ) { 219 LinkedList bundles = new LinkedList (); 220 bundles.addFirst(targetBundle); 221 if( (app != null) && !absoluteLink ) { 222 bundles.addAll(app.getBundleDescriptors()); 223 } 224 for(Iterator iter = bundles.iterator(); iter.hasNext();) { 225 BundleDescriptor next = (BundleDescriptor) iter.next(); 226 port = next.getWebServiceEndpointByName(portName); 227 if( port != null ) { 228 setPortComponentLink(port); 229 break; 230 } 231 } 232 } 233 } 234 235 return port; 236 } 237 238 public WebServiceEndpoint getPortComponentLink() { 239 return portComponentLink; 240 } 241 242 245 public void setPortComponentLink(WebServiceEndpoint newPort) { 246 if( newPort != null ) { 247 248 BundleDescriptor bundleDescriptor = getBundleDescriptor(); 251 BundleDescriptor targetBundleDescriptor = 252 newPort.getBundleDescriptor(); 253 String linkName = newPort.getEndpointName(); 254 if( bundleDescriptor != targetBundleDescriptor ) { 255 Application app = bundleDescriptor.getApplication(); 256 String relativeUri = app.getRelativeUri(bundleDescriptor, 257 targetBundleDescriptor); 258 linkName = relativeUri + "#" + linkName; 259 } 260 portComponentLinkName = linkName; 261 } 262 portComponentLink = newPort; 263 } 264 265 private BundleDescriptor getBundleDescriptor() { 266 return serviceRef.getBundleDescriptor(); 267 } 268 269 273 public boolean hasWsdlPort() { 274 return (wsdlPort != null); 275 } 276 277 public void setWsdlPort(QName port) { 278 wsdlPort = port; 279 } 280 281 public QName getWsdlPort() { 282 return wsdlPort; 283 } 284 285 public Set getStubProperties() { 287 return stubProperties; 288 } 289 290 public boolean hasStubProperty(String name) { 291 return (getStubPropertyValue(name) != null); 292 } 293 294 public String getStubPropertyValue(String name) { 295 String value = null; 296 for(Iterator iter = stubProperties.iterator(); iter.hasNext();) { 297 NameValuePairDescriptor next = (NameValuePairDescriptor)iter.next(); 298 if( next.getName().equals(name) ) { 299 value = next.getValue(); 300 break; 301 } 302 } 303 return value; 304 } 305 306 public NameValuePairDescriptor getStubPropertyByName(String name) { 307 NameValuePairDescriptor prop = null; 308 for(Iterator iter = stubProperties.iterator(); iter.hasNext();) { 309 NameValuePairDescriptor next = (NameValuePairDescriptor) 310 iter.next(); 311 if( next.getName().equals(name) ) { 312 prop = next; 313 break; 314 } 315 } 316 return prop; 317 } 318 319 324 public void addStubProperty(NameValuePairDescriptor property) { 325 NameValuePairDescriptor prop = 326 getStubPropertyByName(property.getName()); 327 if( prop != null ) { 328 prop.setValue(property.getValue()); 329 } else { 330 stubProperties.add(property); 331 } 332 } 333 334 339 public void removeStubProperty(NameValuePairDescriptor property) { 340 NameValuePairDescriptor prop = 341 getStubPropertyByName(property.getName()); 342 if (prop != null) { 343 stubProperties.remove(property); 344 } 345 } 346 347 352 public void addStubProperty(String name, String value) { 353 NameValuePairDescriptor nvPair = new NameValuePairDescriptor(); 354 nvPair.setName(name); 355 nvPair.setValue(value); 356 addStubProperty(nvPair); 357 } 358 359 public Set getCallProperties() { 360 return callProperties; 361 } 362 363 public boolean hasCallProperty(String name) { 364 return (getCallPropertyByName(name) != null); 365 } 366 367 public NameValuePairDescriptor getCallPropertyByName(String name) { 368 NameValuePairDescriptor prop = null; 369 for(Iterator iter = callProperties.iterator(); iter.hasNext();) { 370 NameValuePairDescriptor next = (NameValuePairDescriptor) 371 iter.next(); 372 if( next.getName().equals(name) ) { 373 prop = next; 374 break; 375 } 376 } 377 return prop; 378 } 379 380 385 public void addCallProperty(NameValuePairDescriptor property) { 386 NameValuePairDescriptor prop = 387 getCallPropertyByName(property.getName()); 388 if( prop != null ) { 389 prop.setValue(property.getValue()); 390 } else { 391 callProperties.add(property); 392 } 393 } 394 395 396 401 public void removeCallProperty(NameValuePairDescriptor property) { 402 NameValuePairDescriptor prop = 403 getCallPropertyByName(property.getName()); 404 if( prop != null ) { 405 callProperties.remove(property); 406 } 407 } 408 409 public boolean hasTargetEndpointAddress() { 410 return (targetEndpointAddress != null); 411 } 412 413 public void setTargetEndpointAddress(String address) { 414 targetEndpointAddress = address; 415 } 416 417 public String getTargetEndpointAddress() { 418 return targetEndpointAddress; 419 } 420 421 public void setMtomEnabled(String value) { 422 mtomEnabled = value; 423 } 424 425 public String getMtomEnabled() { 426 return mtomEnabled; 427 } 428 } 429 | Popular Tags |