1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/db/glassfish/JAXBRIContextWrapper.java Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,159 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.ws.db.glassfish; 1.30 + 1.31 +import java.io.IOException; 1.32 +import java.util.List; 1.33 +import java.util.Map; 1.34 + 1.35 +import javax.xml.bind.Binder; 1.36 +import javax.xml.bind.JAXBContext; 1.37 +import javax.xml.bind.JAXBException; 1.38 +import javax.xml.bind.JAXBIntrospector; 1.39 +import javax.xml.bind.Marshaller; 1.40 +import javax.xml.bind.SchemaOutputResolver; 1.41 +import javax.xml.bind.Unmarshaller; 1.42 +import javax.xml.namespace.QName; 1.43 +import javax.xml.transform.Result; 1.44 + 1.45 +import org.w3c.dom.Node; 1.46 + 1.47 +import com.sun.xml.internal.bind.api.BridgeContext; 1.48 +import com.sun.xml.internal.bind.api.CompositeStructure; 1.49 +import com.sun.xml.internal.bind.api.JAXBRIContext; 1.50 +import com.sun.xml.internal.bind.api.TypeReference; 1.51 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet; 1.52 +import com.sun.xml.internal.bind.api.Bridge; 1.53 +import com.sun.xml.internal.ws.spi.db.BindingContext; 1.54 +import com.sun.xml.internal.ws.spi.db.XMLBridge; 1.55 +import com.sun.xml.internal.ws.spi.db.PropertyAccessor; 1.56 +import com.sun.xml.internal.ws.spi.db.TypeInfo; 1.57 +import com.sun.xml.internal.ws.spi.db.WrapperComposite; 1.58 + 1.59 +class JAXBRIContextWrapper implements BindingContext { 1.60 + 1.61 + private Map<TypeInfo, TypeReference> typeRefs; 1.62 + private Map<TypeReference, TypeInfo> typeInfos; 1.63 + private JAXBRIContext context; 1.64 + 1.65 + JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) { 1.66 + context = cxt; 1.67 + typeRefs = refs; 1.68 + if (refs != null) { 1.69 + typeInfos = new java.util.HashMap<TypeReference, TypeInfo>(); 1.70 + for (TypeInfo ti : refs.keySet()) typeInfos.put(typeRefs.get(ti), ti); 1.71 + } 1.72 + } 1.73 + 1.74 + TypeReference typeReference(TypeInfo ti) { 1.75 + return (typeRefs != null)? typeRefs.get(ti) : null; 1.76 + } 1.77 + 1.78 + TypeInfo typeInfo(TypeReference tr) { 1.79 + return (typeInfos != null)? typeInfos.get(tr) : null; 1.80 + } 1.81 + 1.82 + public Marshaller createMarshaller() throws JAXBException { 1.83 + return context.createMarshaller(); 1.84 + } 1.85 + 1.86 + public Unmarshaller createUnmarshaller() throws JAXBException { 1.87 + return context.createUnmarshaller(); 1.88 + } 1.89 + 1.90 + public void generateSchema(SchemaOutputResolver outputResolver) 1.91 + throws IOException { 1.92 + context.generateSchema(outputResolver); 1.93 + } 1.94 + 1.95 + public String getBuildId() { 1.96 + return context.getBuildId(); 1.97 + } 1.98 + 1.99 + public QName getElementName(Class o) throws JAXBException { 1.100 + return context.getElementName(o); 1.101 + } 1.102 + 1.103 + public QName getElementName(Object o) throws JAXBException { 1.104 + return context.getElementName(o); 1.105 + } 1.106 + 1.107 + public <B, V> com.sun.xml.internal.ws.spi.db.PropertyAccessor<B, V> getElementPropertyAccessor( 1.108 + Class<B> wrapperBean, String nsUri, String localName) 1.109 + throws JAXBException { 1.110 + return new RawAccessorWrapper(context.getElementPropertyAccessor(wrapperBean, nsUri, localName)); 1.111 + } 1.112 + 1.113 + public List<String> getKnownNamespaceURIs() { 1.114 + return context.getKnownNamespaceURIs(); 1.115 + } 1.116 + 1.117 + public RuntimeTypeInfoSet getRuntimeTypeInfoSet() { 1.118 + return context.getRuntimeTypeInfoSet(); 1.119 + } 1.120 + 1.121 + public QName getTypeName(com.sun.xml.internal.bind.api.TypeReference tr) { 1.122 + return context.getTypeName(tr); 1.123 + } 1.124 + 1.125 + public int hashCode() { 1.126 + return context.hashCode(); 1.127 + } 1.128 + 1.129 + public boolean hasSwaRef() { 1.130 + return context.hasSwaRef(); 1.131 + } 1.132 + 1.133 + public String toString() { 1.134 + return JAXBRIContextWrapper.class.getName() + " : " + context.toString(); 1.135 + } 1.136 + 1.137 + public XMLBridge createBridge(TypeInfo ti) { 1.138 + TypeReference tr = typeRefs.get(ti); 1.139 + com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr); 1.140 + return WrapperComposite.class.equals(ti.type) ? 1.141 + new WrapperBridge(this, b) : 1.142 + new BridgeWrapper(this, b); 1.143 + } 1.144 + 1.145 + public JAXBContext getJAXBContext() { 1.146 + return context; 1.147 + } 1.148 + 1.149 + public QName getTypeName(TypeInfo ti) { 1.150 + TypeReference tr = typeRefs.get(ti); 1.151 + return context.getTypeName(tr); 1.152 + } 1.153 + 1.154 + public XMLBridge createFragmentBridge() { 1.155 + return new MarshallerBridge((com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl)context); 1.156 + } 1.157 + 1.158 + public Object newWrapperInstace(Class<?> wrapperType) 1.159 + throws InstantiationException, IllegalAccessException { 1.160 + return wrapperType.newInstance(); 1.161 + } 1.162 +}