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 26package com.sun.xml.internal.ws.model.wsdl; 27 28import java.util.List; 29 30import com.sun.xml.internal.ws.api.EndpointAddress; 31import com.sun.xml.internal.ws.api.SOAPVersion; 32import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; 33import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; 34import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType; 35import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel; 36import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort; 37import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService; 38import com.sun.xml.internal.ws.resources.ClientMessages; 39import com.sun.xml.internal.ws.util.exception.LocatableWebServiceException; 40import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser; 41import com.sun.xml.internal.ws.binding.WebServiceFeatureList; 42import com.sun.istack.internal.Nullable; 43import com.sun.istack.internal.NotNull; 44 45import javax.xml.namespace.QName; 46import javax.xml.stream.XMLStreamReader; 47 48/** 49 * Implementation of {@link WSDLPort} 50 * 51 * @author Vivek Pandey 52 */ 53public final class WSDLPortImpl extends AbstractFeaturedObjectImpl implements EditableWSDLPort { 54 private final QName name; 55 private EndpointAddress address; 56 private final QName bindingName; 57 private final EditableWSDLService owner; 58 private WSEndpointReference epr; 59 60 /** 61 * To be set after the WSDL parsing is complete. 62 */ 63 private EditableWSDLBoundPortType boundPortType; 64 65 public WSDLPortImpl(XMLStreamReader xsr, EditableWSDLService owner, QName name, QName binding) { 66 super(xsr); 67 this.owner = owner; 68 this.name = name; 69 this.bindingName = binding; 70 } 71 72 public QName getName() { 73 return name; 74 } 75 76 public QName getBindingName() { 77 return bindingName; 78 } 79 80 public EndpointAddress getAddress() { 81 return address; 82 } 83 84 public EditableWSDLService getOwner() { 85 return owner; 86 } 87 88 /** 89 * Only meant for {@link RuntimeWSDLParser} to call. 90 */ 91 public void setAddress(EndpointAddress address) { 92 assert address!=null; 93 this.address = address; 94 } 95 96 /** 97 * Only meant for {@link RuntimeWSDLParser} to call. 98 */ 99 public void setEPR(@NotNull WSEndpointReference epr) { 100 assert epr!=null; 101 this.addExtension(epr); 102 this.epr = epr; 103 } 104 105 public @Nullable WSEndpointReference getEPR() { 106 return epr; 107 } 108 109 public EditableWSDLBoundPortType getBinding() { 110 return boundPortType; 111 } 112 113 @SuppressWarnings("unchecked") 114 public void freeze(EditableWSDLModel root) { 115 boundPortType = root.getBinding(bindingName); 116 if(boundPortType==null) { 117 throw new LocatableWebServiceException( 118 ClientMessages.UNDEFINED_BINDING(bindingName), getLocation()); 119 } 120 if(features == null) 121 features = new WebServiceFeatureList(); 122 features.setParentFeaturedObject(boundPortType); 123 notUnderstoodExtensions.addAll((List<UnknownWSDLExtension>)boundPortType.getNotUnderstoodExtensions()); 124 } 125} 126