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.servicemix.soap.bindings.soap;
018
019 import java.util.HashMap;
020 import java.util.Iterator;
021 import java.util.Map;
022
023 import javax.xml.namespace.QName;
024
025 /**
026 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
027 */
028 public class SoapVersionFactory {
029 private static SoapVersionFactory factory = new SoapVersionFactory();
030
031 static {
032 getInstance().register(Soap11.getInstance());
033 getInstance().register(Soap12.getInstance());
034 }
035
036 private Map<String, SoapVersion> versions = new HashMap<String, SoapVersion>();
037
038 public static SoapVersionFactory getInstance() {
039 return factory;
040 }
041
042 public SoapVersion getSoapVersion(QName name) {
043 SoapVersion v = getSoapVersion(name.getNamespaceURI());
044 if (v != null && name.getPrefix() != null && !name.getPrefix().equals(v.getPrefix())) {
045 v = v.getDerivedVersion(name.getPrefix());
046 }
047 return v;
048 }
049
050 public SoapVersion getSoapVersion(String namespace) {
051 return versions.get(namespace);
052 }
053
054 public void register(SoapVersion version) {
055 versions.put(version.getNamespace(), version);
056 }
057
058 public Iterator<SoapVersion> getVersions() {
059 return versions.values().iterator();
060 }
061 }