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

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/document/BindingOperation.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,234 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.internal.ws.wsdl.document;
    1.30 +
    1.31 +import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
    1.32 +import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension;
    1.33 +import com.sun.tools.internal.ws.wsdl.framework.Entity;
    1.34 +import com.sun.tools.internal.ws.wsdl.framework.EntityAction;
    1.35 +import com.sun.tools.internal.ws.wsdl.framework.ExtensibilityHelper;
    1.36 +import org.xml.sax.Locator;
    1.37 +
    1.38 +import javax.xml.namespace.QName;
    1.39 +import java.util.ArrayList;
    1.40 +import java.util.List;
    1.41 +
    1.42 +/**
    1.43 + * Entity corresponding to the "operation" child element of a WSDL "binding" element.
    1.44 + *
    1.45 + * @author WS Development Team
    1.46 + */
    1.47 +public class BindingOperation extends Entity implements TWSDLExtensible {
    1.48 +
    1.49 +    public BindingOperation(Locator locator) {
    1.50 +        super(locator);
    1.51 +        _faults = new ArrayList<BindingFault>();
    1.52 +        _helper = new ExtensibilityHelper();
    1.53 +    }
    1.54 +
    1.55 +    public String getName() {
    1.56 +        return _name;
    1.57 +    }
    1.58 +
    1.59 +    public void setName(String name) {
    1.60 +        _name = name;
    1.61 +    }
    1.62 +
    1.63 +    public String getUniqueKey() {
    1.64 +        if (_uniqueKey == null) {
    1.65 +            StringBuilder sb = new StringBuilder();
    1.66 +            sb.append(_name);
    1.67 +            sb.append(' ');
    1.68 +            if (_input != null) {
    1.69 +                sb.append(_input.getName());
    1.70 +            } else {
    1.71 +                sb.append(_name);
    1.72 +                if (_style == OperationStyle.REQUEST_RESPONSE) {
    1.73 +                    sb.append("Request");
    1.74 +                } else if (_style == OperationStyle.SOLICIT_RESPONSE) {
    1.75 +                    sb.append("Response");
    1.76 +                }
    1.77 +            }
    1.78 +            sb.append(' ');
    1.79 +            if (_output != null) {
    1.80 +                sb.append(_output.getName());
    1.81 +            } else {
    1.82 +                sb.append(_name);
    1.83 +                if (_style == OperationStyle.SOLICIT_RESPONSE) {
    1.84 +                    sb.append("Solicit");
    1.85 +                } else if (_style == OperationStyle.REQUEST_RESPONSE) {
    1.86 +                    sb.append("Response");
    1.87 +                }
    1.88 +            }
    1.89 +            _uniqueKey = sb.toString();
    1.90 +        }
    1.91 +
    1.92 +        return _uniqueKey;
    1.93 +    }
    1.94 +
    1.95 +    public OperationStyle getStyle() {
    1.96 +        return _style;
    1.97 +    }
    1.98 +
    1.99 +    public void setStyle(OperationStyle s) {
   1.100 +        _style = s;
   1.101 +    }
   1.102 +
   1.103 +    public BindingInput getInput() {
   1.104 +        return _input;
   1.105 +    }
   1.106 +
   1.107 +    public void setInput(BindingInput i) {
   1.108 +        _input = i;
   1.109 +    }
   1.110 +
   1.111 +    public BindingOutput getOutput() {
   1.112 +        return _output;
   1.113 +    }
   1.114 +
   1.115 +    public void setOutput(BindingOutput o) {
   1.116 +        _output = o;
   1.117 +    }
   1.118 +
   1.119 +    public void addFault(BindingFault f) {
   1.120 +        _faults.add(f);
   1.121 +    }
   1.122 +
   1.123 +    public Iterable<BindingFault> faults() {
   1.124 +        return _faults;
   1.125 +    }
   1.126 +
   1.127 +    @Override
   1.128 +    public QName getElementName() {
   1.129 +        return WSDLConstants.QNAME_OPERATION;
   1.130 +    }
   1.131 +
   1.132 +    public Documentation getDocumentation() {
   1.133 +        return _documentation;
   1.134 +    }
   1.135 +
   1.136 +    public void setDocumentation(Documentation d) {
   1.137 +        _documentation = d;
   1.138 +    }
   1.139 +
   1.140 +    @Override
   1.141 +    public String getNameValue() {
   1.142 +        return getName();
   1.143 +    }
   1.144 +
   1.145 +    @Override
   1.146 +    public String getNamespaceURI() {
   1.147 +        return (parent == null) ? null : parent.getNamespaceURI();
   1.148 +    }
   1.149 +
   1.150 +    @Override
   1.151 +    public QName getWSDLElementName() {
   1.152 +        return getElementName();
   1.153 +    }
   1.154 +
   1.155 +    @Override
   1.156 +    public void addExtension(TWSDLExtension e) {
   1.157 +        _helper.addExtension(e);
   1.158 +    }
   1.159 +
   1.160 +    @Override
   1.161 +    public Iterable<TWSDLExtension> extensions() {
   1.162 +        return _helper.extensions();
   1.163 +    }
   1.164 +
   1.165 +    @Override
   1.166 +    public TWSDLExtensible getParent() {
   1.167 +        return parent;
   1.168 +    }
   1.169 +
   1.170 +    @Override
   1.171 +    public void withAllSubEntitiesDo(EntityAction action) {
   1.172 +        if (_input != null) {
   1.173 +            action.perform(_input);
   1.174 +        }
   1.175 +        if (_output != null) {
   1.176 +            action.perform(_output);
   1.177 +        }
   1.178 +        for (BindingFault _fault : _faults) {
   1.179 +            action.perform(_fault);
   1.180 +        }
   1.181 +        _helper.withAllSubEntitiesDo(action);
   1.182 +    }
   1.183 +
   1.184 +    public void accept(WSDLDocumentVisitor visitor) throws Exception {
   1.185 +        visitor.preVisit(this);
   1.186 +        //bug fix: 4947340, extensions should be the first element
   1.187 +        _helper.accept(visitor);
   1.188 +        if (_input != null) {
   1.189 +            _input.accept(visitor);
   1.190 +        }
   1.191 +        if (_output != null) {
   1.192 +            _output.accept(visitor);
   1.193 +        }
   1.194 +        for (BindingFault _fault : _faults) {
   1.195 +            _fault.accept(visitor);
   1.196 +        }
   1.197 +        visitor.postVisit(this);
   1.198 +    }
   1.199 +
   1.200 +    @Override
   1.201 +    public void validateThis() {
   1.202 +        if (_name == null) {
   1.203 +            failValidation("validation.missingRequiredAttribute", "name");
   1.204 +        }
   1.205 +        if (_style == null) {
   1.206 +            failValidation("validation.missingRequiredProperty", "style");
   1.207 +        }
   1.208 +
   1.209 +        // verify operation style
   1.210 +        if (_style == OperationStyle.ONE_WAY) {
   1.211 +            if (_input == null) {
   1.212 +                failValidation("validation.missingRequiredSubEntity", "input");
   1.213 +            }
   1.214 +            if (_output != null) {
   1.215 +                failValidation("validation.invalidSubEntity", "output");
   1.216 +            }
   1.217 +            if (_faults != null && !_faults.isEmpty()) {
   1.218 +                failValidation("validation.invalidSubEntity", "fault");
   1.219 +            }
   1.220 +        }
   1.221 +    }
   1.222 +
   1.223 +    private ExtensibilityHelper _helper;
   1.224 +    private Documentation _documentation;
   1.225 +    private String _name;
   1.226 +    private BindingInput _input;
   1.227 +    private BindingOutput _output;
   1.228 +    private List<BindingFault> _faults;
   1.229 +    private OperationStyle _style;
   1.230 +    private String _uniqueKey;
   1.231 +
   1.232 +    public void setParent(TWSDLExtensible parent) {
   1.233 +        this.parent = parent;
   1.234 +    }
   1.235 +
   1.236 +    private TWSDLExtensible parent;
   1.237 +}

mercurial