src/share/jaxws_classes/com/sun/xml/internal/ws/model/SOAPSEIModel.java

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

     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.xml.internal.ws.model;
    28 import com.sun.xml.internal.ws.api.model.ParameterBinding;
    29 import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
    31 import javax.jws.WebParam.Mode;
    32 import javax.xml.namespace.QName;
    33 import java.util.HashSet;
    34 import java.util.Iterator;
    35 import java.util.Set;
    37 /**
    38  * Creates SOAP specific RuntimeModel
    39  *
    40  * @author Vivek Pandey
    41  */
    42 public class SOAPSEIModel extends AbstractSEIModelImpl {
    44     public SOAPSEIModel(WebServiceFeatureList features) {
    45         super(features);
    46     }
    48     @Override
    49     protected void populateMaps() {
    50         int emptyBodyCount = 0;
    51         for(JavaMethodImpl jm : getJavaMethods()){
    52             put(jm.getMethod(), jm);
    53             boolean bodyFound = false;
    54             for(ParameterImpl p:jm.getRequestParameters()){
    55                 ParameterBinding binding = p.getBinding();
    56                 if(binding.isBody()){
    57                     put(p.getName(), jm);
    58                     bodyFound = true;
    59                 }
    60             }
    61             if(!bodyFound){
    62                 put(emptyBodyName, jm);
    63 //                System.out.println("added empty body for: "+jm.getMethod().getName());
    64                 emptyBodyCount++;
    65             }
    66         }
    67         if(emptyBodyCount > 1){
    68             //TODO throw exception
    69 //            System.out.println("Error: Unqiue signature violation - more than 1 empty body!");
    70         }
    71     }
    73     public Set<QName> getKnownHeaders() {
    74         Set<QName> headers = new HashSet<QName>();
    75         for (JavaMethodImpl method : getJavaMethods()) {
    76             // fill in request headers
    77             Iterator<ParameterImpl> params = method.getRequestParameters().iterator();
    78             fillHeaders(params, headers, Mode.IN);
    80             // fill in response headers
    81             params = method.getResponseParameters().iterator();
    82             fillHeaders(params, headers, Mode.OUT);
    83         }
    84         return headers;
    85     }
    87     /**
    88      * @param params
    89      * @param headers
    90      */
    91     private void fillHeaders(Iterator<ParameterImpl> params, Set<QName> headers, Mode mode) {
    92         while (params.hasNext()) {
    93             ParameterImpl param = params.next();
    94             ParameterBinding binding = (mode == Mode.IN)?param.getInBinding():param.getOutBinding();
    95             QName name = param.getName();
    96             if (binding.isHeader() && !headers.contains(name)) {
    97                 headers.add(name);
    98             }
    99         }
   100     }
   101 }

mercurial