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 Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,182 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, 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.JAXBContext; 1.36 +import javax.xml.bind.JAXBException; 1.37 +import javax.xml.bind.Marshaller; 1.38 +import javax.xml.bind.SchemaOutputResolver; 1.39 +import javax.xml.bind.Unmarshaller; 1.40 +import javax.xml.namespace.QName; 1.41 +import com.sun.xml.internal.bind.api.JAXBRIContext; 1.42 +import com.sun.xml.internal.bind.api.TypeReference; 1.43 +import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet; 1.44 +import com.sun.xml.internal.ws.spi.db.BindingContext; 1.45 +import com.sun.xml.internal.ws.spi.db.XMLBridge; 1.46 +import com.sun.xml.internal.ws.spi.db.TypeInfo; 1.47 +import com.sun.xml.internal.ws.spi.db.WrapperComposite; 1.48 + 1.49 +class JAXBRIContextWrapper implements BindingContext { 1.50 + 1.51 + private Map<TypeInfo, TypeReference> typeRefs; 1.52 + private Map<TypeReference, TypeInfo> typeInfos; 1.53 + private JAXBRIContext context; 1.54 + 1.55 + JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) { 1.56 + context = cxt; 1.57 + typeRefs = refs; 1.58 + if (refs != null) { 1.59 + typeInfos = new java.util.HashMap<TypeReference, TypeInfo>(); 1.60 + for (TypeInfo ti : refs.keySet()) { 1.61 + typeInfos.put(typeRefs.get(ti), ti); 1.62 + } 1.63 + } 1.64 + } 1.65 + 1.66 + TypeReference typeReference(TypeInfo ti) { 1.67 + return (typeRefs != null) ? typeRefs.get(ti) : null; 1.68 + } 1.69 + 1.70 + TypeInfo typeInfo(TypeReference tr) { 1.71 + return (typeInfos != null) ? typeInfos.get(tr) : null; 1.72 + } 1.73 + 1.74 + @Override 1.75 + public Marshaller createMarshaller() throws JAXBException { 1.76 + return context.createMarshaller(); 1.77 + } 1.78 + 1.79 + @Override 1.80 + public Unmarshaller createUnmarshaller() throws JAXBException { 1.81 + return context.createUnmarshaller(); 1.82 + } 1.83 + 1.84 + @Override 1.85 + public void generateSchema(SchemaOutputResolver outputResolver) 1.86 + throws IOException { 1.87 + context.generateSchema(outputResolver); 1.88 + } 1.89 + 1.90 + @Override 1.91 + public String getBuildId() { 1.92 + return context.getBuildId(); 1.93 + } 1.94 + 1.95 + @Override 1.96 + public QName getElementName(Class o) throws JAXBException { 1.97 + return context.getElementName(o); 1.98 + } 1.99 + 1.100 + @Override 1.101 + public QName getElementName(Object o) throws JAXBException { 1.102 + return context.getElementName(o); 1.103 + } 1.104 + 1.105 + @Override 1.106 + public <B, V> com.sun.xml.internal.ws.spi.db.PropertyAccessor<B, V> getElementPropertyAccessor( 1.107 + Class<B> wrapperBean, String nsUri, String localName) 1.108 + throws JAXBException { 1.109 + return new RawAccessorWrapper(context.getElementPropertyAccessor(wrapperBean, nsUri, localName)); 1.110 + } 1.111 + 1.112 + @Override 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 + @Override 1.126 + public int hashCode() { 1.127 + return context.hashCode(); 1.128 + } 1.129 + 1.130 + @Override 1.131 + public boolean equals(Object obj) { 1.132 + if (obj == null) { 1.133 + return false; 1.134 + } 1.135 + if (getClass() != obj.getClass()) { 1.136 + return false; 1.137 + } 1.138 + final JAXBRIContextWrapper other = (JAXBRIContextWrapper) obj; 1.139 + if (this.context != other.context && (this.context == null || !this.context.equals(other.context))) { 1.140 + return false; 1.141 + } 1.142 + return true; 1.143 + } 1.144 + 1.145 + @Override 1.146 + public boolean hasSwaRef() { 1.147 + return context.hasSwaRef(); 1.148 + } 1.149 + 1.150 + @Override 1.151 + public String toString() { 1.152 + return JAXBRIContextWrapper.class.getName() + " : " + context.toString(); 1.153 + } 1.154 + 1.155 + @Override 1.156 + public XMLBridge createBridge(TypeInfo ti) { 1.157 + TypeReference tr = typeRefs.get(ti); 1.158 + com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr); 1.159 + return WrapperComposite.class.equals(ti.type) 1.160 + ? new WrapperBridge(this, b) 1.161 + : new BridgeWrapper(this, b); 1.162 + } 1.163 + 1.164 + @Override 1.165 + public JAXBContext getJAXBContext() { 1.166 + return context; 1.167 + } 1.168 + 1.169 + @Override 1.170 + public QName getTypeName(TypeInfo ti) { 1.171 + TypeReference tr = typeRefs.get(ti); 1.172 + return context.getTypeName(tr); 1.173 + } 1.174 + 1.175 + @Override 1.176 + public XMLBridge createFragmentBridge() { 1.177 + return new MarshallerBridge((com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl) context); 1.178 + } 1.179 + 1.180 + @Override 1.181 + public Object newWrapperInstace(Class<?> wrapperType) 1.182 + throws InstantiationException, IllegalAccessException { 1.183 + return wrapperType.newInstance(); 1.184 + } 1.185 +}