src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Operation.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.processor.model;
    28 import com.sun.tools.internal.ws.processor.model.java.JavaMethod;
    29 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
    30 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;
    31 import com.sun.tools.internal.ws.wsdl.framework.Entity;
    32 import com.sun.xml.internal.ws.spi.db.BindingHelper;
    34 import javax.xml.namespace.QName;
    35 import java.util.HashSet;
    36 import java.util.Iterator;
    37 import java.util.Set;
    39 /**
    40  *
    41  * @author WS Development Team
    42  */
    43 public class Operation extends ModelObject {
    45     public Operation(Entity entity) {
    46         super(entity);
    47     }
    49     public Operation(Operation operation, Entity entity){
    50         this(operation._name, entity);
    51         this._style = operation._style;
    52         this._use = operation._use;
    53         this.customizedName = operation.customizedName;
    54     }
    55     public Operation(QName name, Entity entity) {
    56         super(entity);
    57         _name = name;
    58         _uniqueName = name.getLocalPart();
    59         _faultNames = new HashSet<String>();
    60         _faults = new HashSet<Fault>();
    61     }
    63     public QName getName() {
    64         return _name;
    65     }
    67     public void setName(QName n) {
    68         _name = n;
    69     }
    71     public String getUniqueName() {
    72         return _uniqueName;
    73     }
    75     public void setUniqueName(String s) {
    76         _uniqueName = s;
    77     }
    79     public Request getRequest() {
    80         return _request;
    81     }
    83     public void setRequest(Request r) {
    84         _request = r;
    85     }
    87     public Response getResponse() {
    88         return _response;
    89     }
    91     public void setResponse(Response r) {
    92         _response = r;
    93     }
    95     public boolean isOverloaded() {
    96         return !_name.getLocalPart().equals(_uniqueName);
    97     }
    99     public void addFault(Fault f) {
   100         if (_faultNames.contains(f.getName())) {
   101             throw new ModelException("model.uniqueness");
   102         }
   103         _faultNames.add(f.getName());
   104         _faults.add(f);
   105     }
   107     public Iterator<Fault> getFaults() {
   108         return _faults.iterator();
   109     }
   111     public Set<Fault> getFaultsSet() {
   112         return _faults;
   113     }
   115     /* serialization */
   116     public void setFaultsSet(Set<Fault> s) {
   117         _faults = s;
   118         initializeFaultNames();
   119     }
   121     private void initializeFaultNames() {
   122         _faultNames = new HashSet<String>();
   123         if (_faults != null) {
   124             for (Iterator iter = _faults.iterator(); iter.hasNext();) {
   125                 Fault f = (Fault) iter.next();
   126                 if (f.getName() != null && _faultNames.contains(f.getName())) {
   127                     throw new ModelException("model.uniqueness");
   128                 }
   129                 _faultNames.add(f.getName());
   130             }
   131         }
   132     }
   134     public Iterator<Fault> getAllFaults() {
   135         Set<Fault> allFaults = getAllFaultsSet();
   136         return allFaults.iterator();
   137     }
   139     public Set<Fault> getAllFaultsSet() {
   140         Set transSet = new HashSet();
   141         transSet.addAll(_faults);
   142         Iterator iter = _faults.iterator();
   143         Fault fault;
   144         Set tmpSet;
   145         while (iter.hasNext()) {
   146             tmpSet = ((Fault)iter.next()).getAllFaultsSet();
   147             transSet.addAll(tmpSet);
   148         }
   149         return transSet;
   150     }
   152     public int getFaultCount() {
   153         return _faults.size();
   154     }
   156     public Set<Block> getAllFaultBlocks(){
   157         Set<Block> blocks = new HashSet<Block>();
   158         Iterator faults = _faults.iterator();
   159         while(faults.hasNext()){
   160             Fault f = (Fault)faults.next();
   161             blocks.add(f.getBlock());
   162         }
   163         return blocks;
   164     }
   166     public JavaMethod getJavaMethod() {
   167         return _javaMethod;
   168     }
   170     public void setJavaMethod(JavaMethod i) {
   171         _javaMethod = i;
   172     }
   174     public String getSOAPAction() {
   175         return _soapAction;
   176     }
   178     public void setSOAPAction(String s) {
   179         _soapAction = s;
   180     }
   182     public SOAPStyle getStyle() {
   183         return _style;
   184     }
   186     public void setStyle(SOAPStyle s) {
   187         _style = s;
   188     }
   190     public SOAPUse getUse() {
   191         return _use;
   192     }
   194     public void setUse(SOAPUse u) {
   195         _use = u;
   196     }
   198     public boolean isWrapped() {
   199         return _isWrapped;
   200     }
   202     public void setWrapped(boolean isWrapped) {
   203         _isWrapped = isWrapped;
   204     }
   207     public void accept(ModelVisitor visitor) throws Exception {
   208         visitor.visit(this);
   209     }
   211     public void setCustomizedName(String name){
   212         this.customizedName = name;
   213     }
   215     public String getCustomizedName(){
   216         return customizedName;
   217     }
   219     public String getJavaMethodName(){
   220         //if JavaMethod is created return the name
   221         if(_javaMethod != null){
   222             return _javaMethod.getName();
   223         }
   225         //return the customized operation name if any without mangling
   226         if(customizedName != null){
   227             return customizedName;
   228         }
   230         return BindingHelper.mangleNameToVariableName(_name.getLocalPart());
   231     }
   233     public com.sun.tools.internal.ws.wsdl.document.Operation getWSDLPortTypeOperation(){
   234         return wsdlOperation;
   235     }
   237     public void setWSDLPortTypeOperation(com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation){
   238         this.wsdlOperation = wsdlOperation;
   239     }
   243     private String customizedName;
   244     private boolean _isWrapped = true;
   245     private QName _name;
   246     private String _uniqueName;
   247     private Request _request;
   248     private Response _response;
   249     private JavaMethod _javaMethod;
   250     private String _soapAction;
   251     private SOAPStyle _style = SOAPStyle.DOCUMENT;
   252     private SOAPUse _use = SOAPUse.LITERAL;
   253     private Set<String> _faultNames;
   254     private Set<Fault> _faults;
   255     private com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation;
   257 }

mercurial