⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typemappingregistryimpl.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.encoding;import org.apache.axis.Constants;import org.apache.axis.utils.Messages;import java.util.HashMap;/** * <p> * The TypeMappingRegistry keeps track of the individual TypeMappings. * </p> * <p> * The TypeMappingRegistry for axis contains a default type mapping * that is set for either SOAP 1.1 or SOAP 1.2 * The default type mapping is a singleton used for the entire * runtime and should not have anything new registered in it. * </p> * <p> * Instead the new TypeMappings for the deploy and service are * made in a separate TypeMapping which is identified by * the soap encoding.  These new TypeMappings delegate back to  * the default type mapping when information is not found. * </p> * <p> * So logically we have: * <pre> *         TMR *         | |   *         | +---------------> DefaultTM  *         |                      ^ *         |                      | *         +----> TM --delegate---+ * </pre> * * But in the implementation, the TMR references * "delegate" TypeMappings (TM') which then reference the actual TM's * </p> * <p> * So the picture is really: * <pre> *         TMR *         | |   *         | +-----------TM'------> DefaultTM  *         |              ^ *         |              | *         +-TM'-> TM ----+ * </pre> * * This extra indirection is necessary because the user may want to  * change the default type mapping.  In such cases, the TMR * just needs to adjust the TM' for the DefaultTM, and all of the * other TMs will properly delegate to the new one.  Here's the picture: * <pre> *         TMR *         | |   *         | +-----------TM'--+     DefaultTM  *         |              ^   | *         |              |   +---> New User Defined Default TM *         +-TM'-> TM ----+ * </pre> * * The other reason that it is necessary is when a deploy * has a TMR, and then TMR's are defined for the individual services * in such cases the delegate() method is invoked on the service * to delegate to the deploy TMR * <pre> *       Deploy TMR *         | |   *         | +-----------TM'------> DefaultTM  *         |              ^ *         |              | *         +-TM'-> TM ----+ * *       Service TMR *         | |   *         | +-----------TM'------> DefaultTM  *         |              ^ *         |              | *         +-TM'-> TM ----+ * *    ServiceTMR.delegate(DeployTMR) * *       Deploy TMR *         | |   *         | +------------TM'------> DefaultTM  *         |              ^ ^  *         |              | | *         +-TM'-> TM ----+ | *           ^              | *   +-------+              | *   |                      | *   |   Service TMR        | *   |     | |              | *   |     | +----------TM'-+                *   |     |               *   |     |               *   |     +-TM'-> TM + *   |                | *   +----------------+ * </pre> * * So now the service uses the DefaultTM of the Deploy TMR, and * the Service TM properly delegates to the deploy's TM.  And * if either the deploy defaultTM or TMs change, the links are not broken. * </p> *  * @author James Snell (jasnell@us.ibm.com) * @author Sam Ruby (rubys@us.ibm.com) * Re-written for JAX-RPC Compliance by * @author Rich Scheuerle (scheu@us.ibm.com */public class TypeMappingRegistryImpl implements TypeMappingRegistry {         private HashMap mapTM;          // Type Mappings keyed with Namespace URI    private TypeMappingDelegate defaultDelTM;  // Delegate to default Type Mapping    private boolean isDelegated = false;    /**     * Construct TypeMappingRegistry     * @param tm     */     public TypeMappingRegistryImpl(TypeMappingImpl tm) {        mapTM = new HashMap();        defaultDelTM = new TypeMappingDelegate(tm);//        TypeMappingDelegate del = new TypeMappingDelegate(new DefaultSOAPEncodingTypeMappingImpl());//        register(Constants.URI_SOAP11_ENC, del);    }    /**     * Construct TypeMappingRegistry     */    public TypeMappingRegistryImpl() {        this(true);    }    public TypeMappingRegistryImpl(boolean registerDefaults) {        mapTM = new HashMap();        if (registerDefaults) {            defaultDelTM = DefaultTypeMappingImpl.getSingletonDelegate();            TypeMappingDelegate del = new TypeMappingDelegate(new DefaultSOAPEncodingTypeMappingImpl());            register(Constants.URI_SOAP11_ENC, del);        } else {            defaultDelTM = new TypeMappingDelegate(TypeMappingDelegate.placeholder);        }    }    /**     * delegate     *     * Changes the contained type mappings to delegate to      * their corresponding types in the secondary TMR.     */    public void delegate(TypeMappingRegistry secondaryTMR) {        if (isDelegated || secondaryTMR == null || secondaryTMR == this) {            return;        }        isDelegated = true;        String[]  keys = secondaryTMR.getRegisteredEncodingStyleURIs();        TypeMappingDelegate otherDefault =                ((TypeMappingRegistryImpl)secondaryTMR).defaultDelTM;        if (keys != null) {            for (int i=0; i < keys.length; i++) {                try {                    String nsURI = keys[i];                    TypeMappingDelegate tm = (TypeMappingDelegate) mapTM.get(nsURI);                    if (tm == null) {                        tm = (TypeMappingDelegate)createTypeMapping();                        tm.setSupportedEncodings(new String[] { nsURI });                        register(nsURI, tm);                    }                    if (tm != null) {                        // Get the secondaryTMR's TM'                        TypeMappingDelegate del = (TypeMappingDelegate)                            ((TypeMappingRegistryImpl)secondaryTMR).mapTM.get(nsURI);                        while (del.next != null) {                            TypeMappingDelegate nu = new TypeMappingDelegate(del.delegate);                            tm.setNext(nu);                            if (del.next == otherDefault) {                                nu.setNext(defaultDelTM);                                break;                            }                            del = del.next;                            tm = nu;                        }                    }                } catch (Exception e) {                }            }        }        // Change our defaultDelTM to delegate to the one in         // the secondaryTMR        if (defaultDelTM.delegate != TypeMappingDelegate.placeholder) {            defaultDelTM.setNext(otherDefault);        } else {            defaultDelTM.delegate = otherDefault.delegate;        }            }                            /********* JAX-RPC Compliant Method Definitions *****************/        /**     * The method register adds a TypeMapping instance for a specific      * namespace                      *     * @param namespaceURI      * @param mapping - TypeMapping for specific namespaces     *     * @return Previous TypeMapping associated with the specified namespaceURI,     * or null if there was no TypeMapping associated with the specified namespaceURI     *     */    public javax.xml.rpc.encoding.TypeMapping register(String namespaceURI,                         javax.xml.rpc.encoding.TypeMapping mapping) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -