001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.dataformat.soap.name;
018    
019    import java.util.HashMap;
020    import java.util.Map;
021    
022    import org.apache.camel.RuntimeCamelException;
023    
024    /**
025     * Value object to hold information about a method in a JAX-WS service interface.
026     * Method can have many parameters in the signature, but only one response object.
027     */
028    public final class MethodInfo {
029        private String name;
030        private String soapAction;
031        private TypeInfo[] in;
032        private TypeInfo out;
033        
034        // map of type name to qname
035        private Map<String, TypeInfo> inTypeMap;
036    
037        /**
038         * Initialize 
039         * 
040         * @param name method name
041         * @param soapAction
042         * @param in input parameters
043         * @param out return types
044         */
045        public MethodInfo(String name, String soapAction, TypeInfo[] in, TypeInfo out) {
046            super();
047            this.name = name;
048            this.soapAction = soapAction;
049            this.in = in;
050            this.out = out;
051            
052            this.inTypeMap = new HashMap<String, TypeInfo>();
053            for (int i = 0; i < in.length; i++) {
054                TypeInfo ti = in[i];
055                if (inTypeMap.containsKey(ti.getTypeName())
056                    && (!(ti.getTypeName().equals("javax.xml.ws.Holder")))
057                    && (!(inTypeMap.get(ti.getTypeName()).equals(ti.getElName())))) {
058                    throw new RuntimeCamelException("Ambiguous QName mapping. The type [ "
059                                                      + ti.getTypeName()
060                                                      + " ] is already mapped to a QName in this method."
061                                                      + " This is not supported.");                   
062                }
063                inTypeMap.put(in[i].getTypeName(), in[i]);
064            }
065        }
066    
067        public String getName() {
068            return name;
069        }
070        
071        public String getSoapAction() {
072            return soapAction;
073        }
074    
075        public TypeInfo[] getIn() {
076            return in;
077        }
078    
079        public TypeInfo getOut() {
080            return out;
081        }
082         
083        public TypeInfo getIn(String typeName) {
084            return this.inTypeMap.get(typeName);
085        }
086        
087    }