src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/document/Port.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    26 package com.sun.tools.internal.ws.wsdl.document;
    28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
    29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension;
    30 import com.sun.tools.internal.ws.wsdl.framework.*;
    31 import com.sun.tools.internal.ws.resources.WsdlMessages;
    32 import com.sun.tools.internal.ws.wscompile.AbortException;
    33 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
    34 import org.xml.sax.Locator;
    36 import javax.xml.namespace.QName;
    38 /**
    39  * Entity corresponding to the "port" WSDL element.
    40  *
    41  * @author WS Development Team
    42  */
    43 public class Port extends GlobalEntity implements TWSDLExtensible {
    45     public Port(Defining defining, Locator locator, ErrorReceiver errReceiver) {
    46         super(defining, locator, errReceiver);
    47         _helper = new ExtensibilityHelper();
    48     }
    50     public Service getService() {
    51         return _service;
    52     }
    54     public void setService(Service s) {
    55         _service = s;
    56     }
    58     public QName getBinding() {
    59         return _binding;
    60     }
    62     public void setBinding(QName n) {
    63         _binding = n;
    64     }
    66     public Binding resolveBinding(AbstractDocument document) {
    67         try{
    68             return (Binding) document.find(Kinds.BINDING, _binding);
    69         } catch (NoSuchEntityException e) {
    70             errorReceiver.error(getLocator(), WsdlMessages.ENTITY_NOT_FOUND_BINDING(_binding, new QName(getNamespaceURI(), getName())));
    71             throw new AbortException();
    72         }
    73     }
    75     public Kind getKind() {
    76         return Kinds.PORT;
    77     }
    79     public String getNameValue() {
    80         return getName();
    81     }
    83     public String getNamespaceURI() {
    84         return getDefining().getTargetNamespaceURI();
    85     }
    87     public QName getWSDLElementName() {
    88         return WSDLConstants.QNAME_PORT;
    89     }
    91     public Documentation getDocumentation() {
    92         return _documentation;
    93     }
    95     public void setDocumentation(Documentation d) {
    96         _documentation = d;
    97     }
    99     public void withAllQNamesDo(QNameAction action) {
   100         super.withAllQNamesDo(action);
   102         if (_binding != null) {
   103             action.perform(_binding);
   104         }
   105     }
   107     public void withAllEntityReferencesDo(EntityReferenceAction action) {
   108         super.withAllEntityReferencesDo(action);
   109         if (_binding != null) {
   110             action.perform(Kinds.BINDING, _binding);
   111         }
   112     }
   114     public void accept(WSDLDocumentVisitor visitor) throws Exception {
   115         visitor.preVisit(this);
   116         _helper.accept(visitor);
   117         visitor.postVisit(this);
   118     }
   120     public void validateThis() {
   121         if (getName() == null) {
   122             failValidation("validation.missingRequiredAttribute", "name");
   123         }
   124         if (_binding == null) {
   125             failValidation("validation.missingRequiredAttribute", "binding");
   126         }
   127     }
   129     public void addExtension(TWSDLExtension e) {
   130         _helper.addExtension(e);
   131     }
   133     public Iterable<TWSDLExtension> extensions() {
   134         return _helper.extensions();
   135     }
   137     public TWSDLExtensible getParent() {
   138         return parent;
   139     }
   141     public void setParent(TWSDLExtensible parent) {
   142         this.parent = parent;
   143     }
   145     public void withAllSubEntitiesDo(EntityAction action) {
   146         _helper.withAllSubEntitiesDo(action);
   147     }
   149     private ExtensibilityHelper _helper;
   150     private Documentation _documentation;
   151     private Service _service;
   152     private QName _binding;
   154     public QName getElementName() {
   155         return getWSDLElementName();
   156     }
   158     private TWSDLExtensible parent;
   159 }

mercurial