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/WrapperBridge.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,157 @@ 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.InputStream; 1.32 +import java.io.OutputStream; 1.33 + 1.34 +import javax.xml.bind.JAXBException; 1.35 +import javax.xml.bind.attachment.AttachmentMarshaller; 1.36 +import javax.xml.bind.attachment.AttachmentUnmarshaller; 1.37 +import javax.xml.namespace.NamespaceContext; 1.38 +import javax.xml.stream.XMLStreamReader; 1.39 +import javax.xml.stream.XMLStreamWriter; 1.40 +import javax.xml.transform.Result; 1.41 +import javax.xml.transform.Source; 1.42 + 1.43 +import org.w3c.dom.Node; 1.44 +import org.xml.sax.ContentHandler; 1.45 + 1.46 +import com.sun.xml.internal.bind.api.Bridge; 1.47 +import com.sun.xml.internal.bind.api.CompositeStructure; 1.48 +import com.sun.xml.internal.ws.spi.db.BindingContext; 1.49 +import com.sun.xml.internal.ws.spi.db.XMLBridge; 1.50 +import com.sun.xml.internal.ws.spi.db.TypeInfo; 1.51 +import com.sun.xml.internal.ws.spi.db.WrapperComposite; 1.52 + 1.53 +public class WrapperBridge<T> implements XMLBridge<T> { 1.54 + 1.55 + private JAXBRIContextWrapper parent; 1.56 + private com.sun.xml.internal.bind.api.Bridge<T> bridge; 1.57 + 1.58 + public WrapperBridge(JAXBRIContextWrapper p, com.sun.xml.internal.bind.api.Bridge<T> b) { 1.59 + parent = p; 1.60 + bridge = b; 1.61 + } 1.62 + 1.63 + @Override 1.64 + public BindingContext context() { 1.65 + return parent; 1.66 + } 1.67 + 1.68 + @Override 1.69 + public boolean equals(Object obj) { 1.70 + return bridge.equals(obj); 1.71 + } 1.72 + 1.73 + @Override 1.74 + public TypeInfo getTypeInfo() { 1.75 + return parent.typeInfo(bridge.getTypeReference()); 1.76 + } 1.77 + 1.78 + @Override 1.79 + public int hashCode() { 1.80 + return bridge.hashCode(); 1.81 + } 1.82 + 1.83 + static CompositeStructure convert(Object o) { 1.84 + WrapperComposite w = (WrapperComposite) o; 1.85 + CompositeStructure cs = new CompositeStructure(); 1.86 + cs.values = w.values; 1.87 + cs.bridges = new Bridge[w.bridges.length]; 1.88 + for (int i = 0; i < cs.bridges.length; i++) { 1.89 + cs.bridges[i] = ((BridgeWrapper) w.bridges[i]).getBridge(); 1.90 + } 1.91 + return cs; 1.92 + } 1.93 + 1.94 + @Override 1.95 + public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException { 1.96 + bridge.marshal((T) convert(object), contentHandler, am); 1.97 +// bridge.marshal(object, contentHandler, am); 1.98 + } 1.99 + 1.100 + @Override 1.101 + public void marshal(T object, Node output) throws JAXBException { 1.102 + throw new UnsupportedOperationException(); 1.103 +// bridge.marshal(object, output); 1.104 +// bridge.marshal((T) convert(object), output); 1.105 + } 1.106 + 1.107 + @Override 1.108 + public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException { 1.109 + bridge.marshal((T) convert(object), output, nsContext, am); 1.110 + } 1.111 + 1.112 + @Override 1.113 + public final void marshal(T object, Result result) throws JAXBException { 1.114 + throw new UnsupportedOperationException(); 1.115 +// bridge.marshal(object, result); 1.116 + } 1.117 + 1.118 + @Override 1.119 + public final void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException { 1.120 + bridge.marshal((T) convert(object), output, am); 1.121 + } 1.122 + 1.123 + @Override 1.124 + public String toString() { 1.125 + return BridgeWrapper.class.getName() + " : " + bridge.toString(); 1.126 + } 1.127 + 1.128 + @Override 1.129 + public final T unmarshal(InputStream in) throws JAXBException { 1.130 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.131 + throw new UnsupportedOperationException(); 1.132 +// return bridge.unmarshal(in); 1.133 + } 1.134 + 1.135 + @Override 1.136 + public final T unmarshal(Node n, AttachmentUnmarshaller au) throws JAXBException { 1.137 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.138 + throw new UnsupportedOperationException(); 1.139 +// return bridge.unmarshal(n, au); 1.140 + } 1.141 + 1.142 + @Override 1.143 + public final T unmarshal(Source in, AttachmentUnmarshaller au) throws JAXBException { 1.144 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.145 + throw new UnsupportedOperationException(); 1.146 +// return bridge.unmarshal(in, au); 1.147 + } 1.148 + 1.149 + @Override 1.150 + public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) throws JAXBException { 1.151 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.152 + throw new UnsupportedOperationException(); 1.153 +// return bridge.unmarshal(in, au); 1.154 + } 1.155 + 1.156 + @Override 1.157 + public boolean supportOutputStream() { 1.158 + return true; 1.159 + } 1.160 +}