src/share/jaxws_classes/com/sun/xml/internal/ws/db/glassfish/JAXBRIContextWrapper.java

Thu, 12 Oct 2017 19:44:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 19:44:07 +0800
changeset 760
e530533619ec
parent 637
9c07ef4934dd
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.xml.internal.ws.db.glassfish;
    28 import java.io.IOException;
    29 import java.util.List;
    30 import java.util.Map;
    32 import javax.xml.bind.JAXBContext;
    33 import javax.xml.bind.JAXBException;
    34 import javax.xml.bind.Marshaller;
    35 import javax.xml.bind.SchemaOutputResolver;
    36 import javax.xml.bind.Unmarshaller;
    37 import javax.xml.namespace.QName;
    38 import com.sun.xml.internal.bind.api.JAXBRIContext;
    39 import com.sun.xml.internal.bind.api.TypeReference;
    40 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
    41 import com.sun.xml.internal.ws.spi.db.BindingContext;
    42 import com.sun.xml.internal.ws.spi.db.XMLBridge;
    43 import com.sun.xml.internal.ws.spi.db.TypeInfo;
    44 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
    46 class JAXBRIContextWrapper implements BindingContext {
    48     private Map<TypeInfo, TypeReference> typeRefs;
    49     private Map<TypeReference, TypeInfo> typeInfos;
    50     private JAXBRIContext context;
    52     JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) {
    53         context = cxt;
    54         typeRefs = refs;
    55         if (refs != null) {
    56             typeInfos = new java.util.HashMap<TypeReference, TypeInfo>();
    57             for (TypeInfo ti : refs.keySet()) {
    58                 typeInfos.put(typeRefs.get(ti), ti);
    59             }
    60         }
    61     }
    63     TypeReference typeReference(TypeInfo ti) {
    64         return (typeRefs != null) ? typeRefs.get(ti) : null;
    65     }
    67     TypeInfo typeInfo(TypeReference tr) {
    68         return (typeInfos != null) ? typeInfos.get(tr) : null;
    69     }
    71     @Override
    72     public Marshaller createMarshaller() throws JAXBException {
    73         return context.createMarshaller();
    74     }
    76     @Override
    77     public Unmarshaller createUnmarshaller() throws JAXBException {
    78         return context.createUnmarshaller();
    79     }
    81     @Override
    82     public void generateSchema(SchemaOutputResolver outputResolver)
    83             throws IOException {
    84         context.generateSchema(outputResolver);
    85     }
    87     @Override
    88     public String getBuildId() {
    89         return context.getBuildId();
    90     }
    92     @Override
    93     public QName getElementName(Class o) throws JAXBException {
    94         return context.getElementName(o);
    95     }
    97     @Override
    98     public QName getElementName(Object o) throws JAXBException {
    99         return context.getElementName(o);
   100     }
   102     @Override
   103     public <B, V> com.sun.xml.internal.ws.spi.db.PropertyAccessor<B, V> getElementPropertyAccessor(
   104             Class<B> wrapperBean, String nsUri, String localName)
   105             throws JAXBException {
   106         return new RawAccessorWrapper(context.getElementPropertyAccessor(wrapperBean, nsUri, localName));
   107     }
   109     @Override
   110     public List<String> getKnownNamespaceURIs() {
   111         return context.getKnownNamespaceURIs();
   112     }
   114     public RuntimeTypeInfoSet getRuntimeTypeInfoSet() {
   115         return context.getRuntimeTypeInfoSet();
   116     }
   118     public QName getTypeName(com.sun.xml.internal.bind.api.TypeReference tr) {
   119         return context.getTypeName(tr);
   120     }
   122     @Override
   123     public int hashCode() {
   124         return context.hashCode();
   125     }
   127     @Override
   128     public boolean equals(Object obj) {
   129         if (obj == null) {
   130             return false;
   131         }
   132         if (getClass() != obj.getClass()) {
   133             return false;
   134         }
   135         final JAXBRIContextWrapper other = (JAXBRIContextWrapper) obj;
   136         if (this.context != other.context && (this.context == null || !this.context.equals(other.context))) {
   137             return false;
   138         }
   139         return true;
   140     }
   142     @Override
   143     public boolean hasSwaRef() {
   144         return context.hasSwaRef();
   145     }
   147     @Override
   148     public String toString() {
   149         return JAXBRIContextWrapper.class.getName() + " : " + context.toString();
   150     }
   152     @Override
   153     public XMLBridge createBridge(TypeInfo ti) {
   154         TypeReference tr = typeRefs.get(ti);
   155         com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
   156         return WrapperComposite.class.equals(ti.type)
   157                 ? new WrapperBridge(this, b)
   158                 : new BridgeWrapper(this, b);
   159     }
   161     @Override
   162     public JAXBContext getJAXBContext() {
   163         return context;
   164     }
   166     @Override
   167     public QName getTypeName(TypeInfo ti) {
   168         TypeReference tr = typeRefs.get(ti);
   169         return context.getTypeName(tr);
   170     }
   172     @Override
   173     public XMLBridge createFragmentBridge() {
   174         return new MarshallerBridge((com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl) context);
   175     }
   177     @Override
   178     public Object newWrapperInstace(Class<?> wrapperType)
   179             throws InstantiationException, IllegalAccessException {
   180         return wrapperType.newInstance();
   181     }
   182 }

mercurial