src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Operation.java

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Operation.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,257 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, 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.processor.model;
    1.30 +
    1.31 +import com.sun.tools.internal.ws.processor.model.java.JavaMethod;
    1.32 +import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
    1.33 +import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
    1.34 +import com.sun.tools.internal.ws.wsdl.framework.Entity;
    1.35 +import com.sun.xml.internal.ws.spi.db.BindingHelper;
    1.36 +
    1.37 +import javax.xml.namespace.QName;
    1.38 +import java.util.HashSet;
    1.39 +import java.util.Iterator;
    1.40 +import java.util.Set;
    1.41 +
    1.42 +/**
    1.43 + *
    1.44 + * @author WS Development Team
    1.45 + */
    1.46 +public class Operation extends ModelObject {
    1.47 +
    1.48 +    public Operation(Entity entity) {
    1.49 +        super(entity);
    1.50 +    }
    1.51 +
    1.52 +    public Operation(Operation operation, Entity entity){
    1.53 +        this(operation._name, entity);
    1.54 +        this._style = operation._style;
    1.55 +        this._use = operation._use;
    1.56 +        this.customizedName = operation.customizedName;
    1.57 +    }
    1.58 +    public Operation(QName name, Entity entity) {
    1.59 +        super(entity);
    1.60 +        _name = name;
    1.61 +        _uniqueName = name.getLocalPart();
    1.62 +        _faultNames = new HashSet<String>();
    1.63 +        _faults = new HashSet<Fault>();
    1.64 +    }
    1.65 +
    1.66 +    public QName getName() {
    1.67 +        return _name;
    1.68 +    }
    1.69 +
    1.70 +    public void setName(QName n) {
    1.71 +        _name = n;
    1.72 +    }
    1.73 +
    1.74 +    public String getUniqueName() {
    1.75 +        return _uniqueName;
    1.76 +    }
    1.77 +
    1.78 +    public void setUniqueName(String s) {
    1.79 +        _uniqueName = s;
    1.80 +    }
    1.81 +
    1.82 +    public Request getRequest() {
    1.83 +        return _request;
    1.84 +    }
    1.85 +
    1.86 +    public void setRequest(Request r) {
    1.87 +        _request = r;
    1.88 +    }
    1.89 +
    1.90 +    public Response getResponse() {
    1.91 +        return _response;
    1.92 +    }
    1.93 +
    1.94 +    public void setResponse(Response r) {
    1.95 +        _response = r;
    1.96 +    }
    1.97 +
    1.98 +    public boolean isOverloaded() {
    1.99 +        return !_name.getLocalPart().equals(_uniqueName);
   1.100 +    }
   1.101 +
   1.102 +    public void addFault(Fault f) {
   1.103 +        if (_faultNames.contains(f.getName())) {
   1.104 +            throw new ModelException("model.uniqueness");
   1.105 +        }
   1.106 +        _faultNames.add(f.getName());
   1.107 +        _faults.add(f);
   1.108 +    }
   1.109 +
   1.110 +    public Iterator<Fault> getFaults() {
   1.111 +        return _faults.iterator();
   1.112 +    }
   1.113 +
   1.114 +    public Set<Fault> getFaultsSet() {
   1.115 +        return _faults;
   1.116 +    }
   1.117 +
   1.118 +    /* serialization */
   1.119 +    public void setFaultsSet(Set<Fault> s) {
   1.120 +        _faults = s;
   1.121 +        initializeFaultNames();
   1.122 +    }
   1.123 +
   1.124 +    private void initializeFaultNames() {
   1.125 +        _faultNames = new HashSet<String>();
   1.126 +        if (_faults != null) {
   1.127 +            for (Iterator iter = _faults.iterator(); iter.hasNext();) {
   1.128 +                Fault f = (Fault) iter.next();
   1.129 +                if (f.getName() != null && _faultNames.contains(f.getName())) {
   1.130 +                    throw new ModelException("model.uniqueness");
   1.131 +                }
   1.132 +                _faultNames.add(f.getName());
   1.133 +            }
   1.134 +        }
   1.135 +    }
   1.136 +
   1.137 +    public Iterator<Fault> getAllFaults() {
   1.138 +        Set<Fault> allFaults = getAllFaultsSet();
   1.139 +        return allFaults.iterator();
   1.140 +    }
   1.141 +
   1.142 +    public Set<Fault> getAllFaultsSet() {
   1.143 +        Set transSet = new HashSet();
   1.144 +        transSet.addAll(_faults);
   1.145 +        Iterator iter = _faults.iterator();
   1.146 +        Fault fault;
   1.147 +        Set tmpSet;
   1.148 +        while (iter.hasNext()) {
   1.149 +            tmpSet = ((Fault)iter.next()).getAllFaultsSet();
   1.150 +            transSet.addAll(tmpSet);
   1.151 +        }
   1.152 +        return transSet;
   1.153 +    }
   1.154 +
   1.155 +    public int getFaultCount() {
   1.156 +        return _faults.size();
   1.157 +    }
   1.158 +
   1.159 +    public Set<Block> getAllFaultBlocks(){
   1.160 +        Set<Block> blocks = new HashSet<Block>();
   1.161 +        Iterator faults = _faults.iterator();
   1.162 +        while(faults.hasNext()){
   1.163 +            Fault f = (Fault)faults.next();
   1.164 +            blocks.add(f.getBlock());
   1.165 +        }
   1.166 +        return blocks;
   1.167 +    }
   1.168 +
   1.169 +    public JavaMethod getJavaMethod() {
   1.170 +        return _javaMethod;
   1.171 +    }
   1.172 +
   1.173 +    public void setJavaMethod(JavaMethod i) {
   1.174 +        _javaMethod = i;
   1.175 +    }
   1.176 +
   1.177 +    public String getSOAPAction() {
   1.178 +        return _soapAction;
   1.179 +    }
   1.180 +
   1.181 +    public void setSOAPAction(String s) {
   1.182 +        _soapAction = s;
   1.183 +    }
   1.184 +
   1.185 +    public SOAPStyle getStyle() {
   1.186 +        return _style;
   1.187 +    }
   1.188 +
   1.189 +    public void setStyle(SOAPStyle s) {
   1.190 +        _style = s;
   1.191 +    }
   1.192 +
   1.193 +    public SOAPUse getUse() {
   1.194 +        return _use;
   1.195 +    }
   1.196 +
   1.197 +    public void setUse(SOAPUse u) {
   1.198 +        _use = u;
   1.199 +    }
   1.200 +
   1.201 +    public boolean isWrapped() {
   1.202 +        return _isWrapped;
   1.203 +    }
   1.204 +
   1.205 +    public void setWrapped(boolean isWrapped) {
   1.206 +        _isWrapped = isWrapped;
   1.207 +    }
   1.208 +
   1.209 +
   1.210 +    public void accept(ModelVisitor visitor) throws Exception {
   1.211 +        visitor.visit(this);
   1.212 +    }
   1.213 +
   1.214 +    public void setCustomizedName(String name){
   1.215 +        this.customizedName = name;
   1.216 +    }
   1.217 +
   1.218 +    public String getCustomizedName(){
   1.219 +        return customizedName;
   1.220 +    }
   1.221 +
   1.222 +    public String getJavaMethodName(){
   1.223 +        //if JavaMethod is created return the name
   1.224 +        if(_javaMethod != null){
   1.225 +            return _javaMethod.getName();
   1.226 +        }
   1.227 +
   1.228 +        //return the customized operation name if any without mangling
   1.229 +        if(customizedName != null){
   1.230 +            return customizedName;
   1.231 +        }
   1.232 +
   1.233 +        return BindingHelper.mangleNameToVariableName(_name.getLocalPart());
   1.234 +    }
   1.235 +
   1.236 +    public com.sun.tools.internal.ws.wsdl.document.Operation getWSDLPortTypeOperation(){
   1.237 +        return wsdlOperation;
   1.238 +    }
   1.239 +
   1.240 +    public void setWSDLPortTypeOperation(com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation){
   1.241 +        this.wsdlOperation = wsdlOperation;
   1.242 +    }
   1.243 +
   1.244 +
   1.245 +
   1.246 +    private String customizedName;
   1.247 +    private boolean _isWrapped = true;
   1.248 +    private QName _name;
   1.249 +    private String _uniqueName;
   1.250 +    private Request _request;
   1.251 +    private Response _response;
   1.252 +    private JavaMethod _javaMethod;
   1.253 +    private String _soapAction;
   1.254 +    private SOAPStyle _style = SOAPStyle.DOCUMENT;
   1.255 +    private SOAPUse _use = SOAPUse.LITERAL;
   1.256 +    private Set<String> _faultNames;
   1.257 +    private Set<Fault> _faults;
   1.258 +    private com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation;
   1.259 +
   1.260 +}

mercurial