aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.internal.ws.wsdl.document; aoqi@0: aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; aoqi@0: import com.sun.tools.internal.ws.wsdl.framework.*; aoqi@0: import com.sun.tools.internal.ws.resources.WsdlMessages; aoqi@0: import com.sun.tools.internal.ws.wscompile.AbortException; aoqi@0: import com.sun.tools.internal.ws.wscompile.ErrorReceiver; aoqi@0: import org.xml.sax.Locator; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: aoqi@0: /** aoqi@0: * Entity corresponding to the "port" WSDL element. aoqi@0: * aoqi@0: * @author WS Development Team aoqi@0: */ aoqi@0: public class Port extends GlobalEntity implements TWSDLExtensible { aoqi@0: aoqi@0: public Port(Defining defining, Locator locator, ErrorReceiver errReceiver) { aoqi@0: super(defining, locator, errReceiver); aoqi@0: _helper = new ExtensibilityHelper(); aoqi@0: } aoqi@0: aoqi@0: public Service getService() { aoqi@0: return _service; aoqi@0: } aoqi@0: aoqi@0: public void setService(Service s) { aoqi@0: _service = s; aoqi@0: } aoqi@0: aoqi@0: public QName getBinding() { aoqi@0: return _binding; aoqi@0: } aoqi@0: aoqi@0: public void setBinding(QName n) { aoqi@0: _binding = n; aoqi@0: } aoqi@0: aoqi@0: public Binding resolveBinding(AbstractDocument document) { aoqi@0: try{ aoqi@0: return (Binding) document.find(Kinds.BINDING, _binding); aoqi@0: } catch (NoSuchEntityException e) { aoqi@0: errorReceiver.error(getLocator(), WsdlMessages.ENTITY_NOT_FOUND_BINDING(_binding, new QName(getNamespaceURI(), getName()))); aoqi@0: throw new AbortException(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public Kind getKind() { aoqi@0: return Kinds.PORT; aoqi@0: } aoqi@0: aoqi@0: public String getNameValue() { aoqi@0: return getName(); aoqi@0: } aoqi@0: aoqi@0: public String getNamespaceURI() { aoqi@0: return getDefining().getTargetNamespaceURI(); aoqi@0: } aoqi@0: aoqi@0: public QName getWSDLElementName() { aoqi@0: return WSDLConstants.QNAME_PORT; aoqi@0: } aoqi@0: aoqi@0: public Documentation getDocumentation() { aoqi@0: return _documentation; aoqi@0: } aoqi@0: aoqi@0: public void setDocumentation(Documentation d) { aoqi@0: _documentation = d; aoqi@0: } aoqi@0: aoqi@0: public void withAllQNamesDo(QNameAction action) { aoqi@0: super.withAllQNamesDo(action); aoqi@0: aoqi@0: if (_binding != null) { aoqi@0: action.perform(_binding); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void withAllEntityReferencesDo(EntityReferenceAction action) { aoqi@0: super.withAllEntityReferencesDo(action); aoqi@0: if (_binding != null) { aoqi@0: action.perform(Kinds.BINDING, _binding); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void accept(WSDLDocumentVisitor visitor) throws Exception { aoqi@0: visitor.preVisit(this); aoqi@0: _helper.accept(visitor); aoqi@0: visitor.postVisit(this); aoqi@0: } aoqi@0: aoqi@0: public void validateThis() { aoqi@0: if (getName() == null) { aoqi@0: failValidation("validation.missingRequiredAttribute", "name"); aoqi@0: } aoqi@0: if (_binding == null) { aoqi@0: failValidation("validation.missingRequiredAttribute", "binding"); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void addExtension(TWSDLExtension e) { aoqi@0: _helper.addExtension(e); aoqi@0: } aoqi@0: aoqi@0: public Iterable extensions() { aoqi@0: return _helper.extensions(); aoqi@0: } aoqi@0: aoqi@0: public TWSDLExtensible getParent() { aoqi@0: return parent; aoqi@0: } aoqi@0: aoqi@0: public void setParent(TWSDLExtensible parent) { aoqi@0: this.parent = parent; aoqi@0: } aoqi@0: aoqi@0: public void withAllSubEntitiesDo(EntityAction action) { aoqi@0: _helper.withAllSubEntitiesDo(action); aoqi@0: } aoqi@0: aoqi@0: private ExtensibilityHelper _helper; aoqi@0: private Documentation _documentation; aoqi@0: private Service _service; aoqi@0: private QName _binding; aoqi@0: aoqi@0: public QName getElementName() { aoqi@0: return getWSDLElementName(); aoqi@0: } aoqi@0: aoqi@0: private TWSDLExtensible parent; aoqi@0: }