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

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

ohair@286 1 /*
alanb@368 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
ohair@286 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@286 4 *
ohair@286 5 * This code is free software; you can redistribute it and/or modify it
ohair@286 6 * under the terms of the GNU General Public License version 2 only, as
ohair@286 7 * published by the Free Software Foundation. Oracle designates this
ohair@286 8 * particular file as subject to the "Classpath" exception as provided
ohair@286 9 * by Oracle in the LICENSE file that accompanied this code.
ohair@286 10 *
ohair@286 11 * This code is distributed in the hope that it will be useful, but WITHOUT
ohair@286 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@286 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@286 14 * version 2 for more details (a copy is included in the LICENSE file that
ohair@286 15 * accompanied this code).
ohair@286 16 *
ohair@286 17 * You should have received a copy of the GNU General Public License version
ohair@286 18 * 2 along with this work; if not, write to the Free Software Foundation,
ohair@286 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@286 20 *
ohair@286 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@286 22 * or visit www.oracle.com if you need additional information or have any
ohair@286 23 * questions.
ohair@286 24 */
ohair@286 25
ohair@286 26 package com.sun.xml.internal.ws.db.glassfish;
ohair@286 27
ohair@286 28 import java.io.IOException;
ohair@286 29 import java.util.List;
ohair@286 30 import java.util.Map;
ohair@286 31
ohair@286 32 import javax.xml.bind.JAXBContext;
ohair@286 33 import javax.xml.bind.JAXBException;
ohair@286 34 import javax.xml.bind.Marshaller;
ohair@286 35 import javax.xml.bind.SchemaOutputResolver;
ohair@286 36 import javax.xml.bind.Unmarshaller;
ohair@286 37 import javax.xml.namespace.QName;
ohair@286 38 import com.sun.xml.internal.bind.api.JAXBRIContext;
ohair@286 39 import com.sun.xml.internal.bind.api.TypeReference;
ohair@286 40 import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
ohair@286 41 import com.sun.xml.internal.ws.spi.db.BindingContext;
ohair@286 42 import com.sun.xml.internal.ws.spi.db.XMLBridge;
ohair@286 43 import com.sun.xml.internal.ws.spi.db.TypeInfo;
ohair@286 44 import com.sun.xml.internal.ws.spi.db.WrapperComposite;
ohair@286 45
ohair@286 46 class JAXBRIContextWrapper implements BindingContext {
ohair@286 47
alanb@368 48 private Map<TypeInfo, TypeReference> typeRefs;
alanb@368 49 private Map<TypeReference, TypeInfo> typeInfos;
alanb@368 50 private JAXBRIContext context;
ohair@286 51
alanb@368 52 JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) {
alanb@368 53 context = cxt;
alanb@368 54 typeRefs = refs;
alanb@368 55 if (refs != null) {
alanb@368 56 typeInfos = new java.util.HashMap<TypeReference, TypeInfo>();
alanb@368 57 for (TypeInfo ti : refs.keySet()) {
alanb@368 58 typeInfos.put(typeRefs.get(ti), ti);
alanb@368 59 }
ohair@286 60 }
alanb@368 61 }
ohair@286 62
alanb@368 63 TypeReference typeReference(TypeInfo ti) {
alanb@368 64 return (typeRefs != null) ? typeRefs.get(ti) : null;
alanb@368 65 }
alanb@368 66
alanb@368 67 TypeInfo typeInfo(TypeReference tr) {
alanb@368 68 return (typeInfos != null) ? typeInfos.get(tr) : null;
alanb@368 69 }
alanb@368 70
alanb@368 71 @Override
alanb@368 72 public Marshaller createMarshaller() throws JAXBException {
alanb@368 73 return context.createMarshaller();
alanb@368 74 }
alanb@368 75
alanb@368 76 @Override
alanb@368 77 public Unmarshaller createUnmarshaller() throws JAXBException {
alanb@368 78 return context.createUnmarshaller();
alanb@368 79 }
alanb@368 80
alanb@368 81 @Override
alanb@368 82 public void generateSchema(SchemaOutputResolver outputResolver)
alanb@368 83 throws IOException {
alanb@368 84 context.generateSchema(outputResolver);
alanb@368 85 }
alanb@368 86
alanb@368 87 @Override
alanb@368 88 public String getBuildId() {
alanb@368 89 return context.getBuildId();
alanb@368 90 }
alanb@368 91
alanb@368 92 @Override
alanb@368 93 public QName getElementName(Class o) throws JAXBException {
alanb@368 94 return context.getElementName(o);
alanb@368 95 }
alanb@368 96
alanb@368 97 @Override
alanb@368 98 public QName getElementName(Object o) throws JAXBException {
alanb@368 99 return context.getElementName(o);
alanb@368 100 }
alanb@368 101
alanb@368 102 @Override
alanb@368 103 public <B, V> com.sun.xml.internal.ws.spi.db.PropertyAccessor<B, V> getElementPropertyAccessor(
alanb@368 104 Class<B> wrapperBean, String nsUri, String localName)
alanb@368 105 throws JAXBException {
alanb@368 106 return new RawAccessorWrapper(context.getElementPropertyAccessor(wrapperBean, nsUri, localName));
alanb@368 107 }
alanb@368 108
alanb@368 109 @Override
alanb@368 110 public List<String> getKnownNamespaceURIs() {
alanb@368 111 return context.getKnownNamespaceURIs();
alanb@368 112 }
alanb@368 113
alanb@368 114 public RuntimeTypeInfoSet getRuntimeTypeInfoSet() {
alanb@368 115 return context.getRuntimeTypeInfoSet();
alanb@368 116 }
alanb@368 117
alanb@368 118 public QName getTypeName(com.sun.xml.internal.bind.api.TypeReference tr) {
alanb@368 119 return context.getTypeName(tr);
alanb@368 120 }
alanb@368 121
alanb@368 122 @Override
alanb@368 123 public int hashCode() {
alanb@368 124 return context.hashCode();
alanb@368 125 }
alanb@368 126
alanb@368 127 @Override
alanb@368 128 public boolean equals(Object obj) {
alanb@368 129 if (obj == null) {
alanb@368 130 return false;
ohair@286 131 }
alanb@368 132 if (getClass() != obj.getClass()) {
alanb@368 133 return false;
alanb@368 134 }
alanb@368 135 final JAXBRIContextWrapper other = (JAXBRIContextWrapper) obj;
alanb@368 136 if (this.context != other.context && (this.context == null || !this.context.equals(other.context))) {
alanb@368 137 return false;
alanb@368 138 }
alanb@368 139 return true;
alanb@368 140 }
ohair@286 141
alanb@368 142 @Override
alanb@368 143 public boolean hasSwaRef() {
alanb@368 144 return context.hasSwaRef();
alanb@368 145 }
ohair@286 146
alanb@368 147 @Override
alanb@368 148 public String toString() {
alanb@368 149 return JAXBRIContextWrapper.class.getName() + " : " + context.toString();
alanb@368 150 }
ohair@286 151
alanb@368 152 @Override
alanb@368 153 public XMLBridge createBridge(TypeInfo ti) {
alanb@368 154 TypeReference tr = typeRefs.get(ti);
alanb@368 155 com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
alanb@368 156 return WrapperComposite.class.equals(ti.type)
alanb@368 157 ? new WrapperBridge(this, b)
alanb@368 158 : new BridgeWrapper(this, b);
alanb@368 159 }
ohair@286 160
alanb@368 161 @Override
alanb@368 162 public JAXBContext getJAXBContext() {
alanb@368 163 return context;
alanb@368 164 }
ohair@286 165
alanb@368 166 @Override
alanb@368 167 public QName getTypeName(TypeInfo ti) {
alanb@368 168 TypeReference tr = typeRefs.get(ti);
alanb@368 169 return context.getTypeName(tr);
alanb@368 170 }
ohair@286 171
alanb@368 172 @Override
alanb@368 173 public XMLBridge createFragmentBridge() {
alanb@368 174 return new MarshallerBridge((com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl) context);
alanb@368 175 }
ohair@286 176
alanb@368 177 @Override
ohair@286 178 public Object newWrapperInstace(Class<?> wrapperType)
ohair@286 179 throws InstantiationException, IllegalAccessException {
ohair@286 180 return wrapperType.newInstance();
ohair@286 181 }
ohair@286 182 }

mercurial