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

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2011, 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.Binder;
    33 import javax.xml.bind.JAXBContext;
    34 import javax.xml.bind.JAXBException;
    35 import javax.xml.bind.JAXBIntrospector;
    36 import javax.xml.bind.Marshaller;
    37 import javax.xml.bind.SchemaOutputResolver;
    38 import javax.xml.bind.Unmarshaller;
    39 import javax.xml.namespace.QName;
    40 import javax.xml.transform.Result;
    42 import org.w3c.dom.Node;
    44 import com.sun.xml.internal.bind.api.BridgeContext;
    45 import com.sun.xml.internal.bind.api.CompositeStructure;
    46 import com.sun.xml.internal.bind.api.JAXBRIContext;
    47 import com.sun.xml.internal.bind.api.TypeReference;
    48 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
    49 import com.sun.xml.internal.bind.api.Bridge;
    50 import com.sun.xml.internal.ws.spi.db.BindingContext;
    51 import com.sun.xml.internal.ws.spi.db.XMLBridge;
    52 import com.sun.xml.internal.ws.spi.db.PropertyAccessor;
    53 import com.sun.xml.internal.ws.spi.db.TypeInfo;
    54 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
    56 class JAXBRIContextWrapper implements BindingContext {
    58         private Map<TypeInfo, TypeReference> typeRefs;
    59         private Map<TypeReference, TypeInfo> typeInfos;
    60         private JAXBRIContext context;
    62         JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) {
    63                 context = cxt;
    64                 typeRefs = refs;
    65                 if (refs != null) {
    66                         typeInfos = new java.util.HashMap<TypeReference, TypeInfo>();
    67                         for (TypeInfo ti : refs.keySet()) typeInfos.put(typeRefs.get(ti), ti);
    68                 }
    69         }
    71         TypeReference typeReference(TypeInfo ti) {
    72                 return (typeRefs != null)? typeRefs.get(ti) : null;
    73         }
    75         TypeInfo typeInfo(TypeReference tr) {
    76                 return (typeInfos != null)? typeInfos.get(tr) : null;
    77         }
    79         public Marshaller createMarshaller() throws JAXBException {
    80                 return context.createMarshaller();
    81         }
    83         public Unmarshaller createUnmarshaller() throws JAXBException {
    84                 return context.createUnmarshaller();
    85         }
    87         public void generateSchema(SchemaOutputResolver outputResolver)
    88                         throws IOException {
    89                 context.generateSchema(outputResolver);
    90         }
    92         public String getBuildId() {
    93                 return context.getBuildId();
    94         }
    96         public QName getElementName(Class o) throws JAXBException {
    97                 return context.getElementName(o);
    98         }
   100         public QName getElementName(Object o) throws JAXBException {
   101                 return context.getElementName(o);
   102         }
   104         public <B, V> com.sun.xml.internal.ws.spi.db.PropertyAccessor<B, V> getElementPropertyAccessor(
   105                         Class<B> wrapperBean, String nsUri, String localName)
   106                         throws JAXBException {
   107                 return new RawAccessorWrapper(context.getElementPropertyAccessor(wrapperBean, nsUri, localName));
   108         }
   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         public int hashCode() {
   123                 return context.hashCode();
   124         }
   126         public boolean hasSwaRef() {
   127                 return context.hasSwaRef();
   128         }
   130         public String toString() {
   131                 return JAXBRIContextWrapper.class.getName() + " : " + context.toString();
   132         }
   134         public XMLBridge createBridge(TypeInfo ti) {
   135                 TypeReference tr = typeRefs.get(ti);
   136                 com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
   137                 return WrapperComposite.class.equals(ti.type) ?
   138                                 new WrapperBridge(this, b) :
   139                                 new BridgeWrapper(this, b);
   140         }
   142         public JAXBContext getJAXBContext() {
   143                 return context;
   144         }
   146         public QName getTypeName(TypeInfo ti) {
   147                 TypeReference tr = typeRefs.get(ti);
   148                 return context.getTypeName(tr);
   149         }
   151         public XMLBridge createFragmentBridge() {
   152                 return new MarshallerBridge((com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl)context);
   153         }
   155     public Object newWrapperInstace(Class<?> wrapperType)
   156             throws InstantiationException, IllegalAccessException {
   157         return wrapperType.newInstance();
   158     }
   159 }

mercurial