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 Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,141 @@ 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.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 + public BindingContext context() { 1.64 + return parent; 1.65 + } 1.66 + 1.67 + public boolean equals(Object obj) { 1.68 + return bridge.equals(obj); 1.69 + } 1.70 + 1.71 + public TypeInfo getTypeInfo() { 1.72 + return parent.typeInfo(bridge.getTypeReference()); 1.73 + } 1.74 + 1.75 + public int hashCode() { 1.76 + return bridge.hashCode(); 1.77 + } 1.78 + 1.79 + static CompositeStructure convert(Object o) { 1.80 + WrapperComposite w = (WrapperComposite) o; 1.81 + CompositeStructure cs = new CompositeStructure(); 1.82 + cs.values = w.values; 1.83 + cs.bridges = new Bridge[w.bridges.length]; 1.84 + for (int i = 0; i < cs.bridges.length; i++) 1.85 + cs.bridges[i] = ((BridgeWrapper)w.bridges[i]).getBridge(); 1.86 + return cs; 1.87 + } 1.88 + 1.89 + public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException { 1.90 + bridge.marshal((T) convert(object), contentHandler, am); 1.91 +// bridge.marshal(object, contentHandler, am); 1.92 + } 1.93 + 1.94 + public void marshal(T object, Node output) throws JAXBException { 1.95 + throw new UnsupportedOperationException(); 1.96 +// bridge.marshal(object, output); 1.97 +// bridge.marshal((T) convert(object), output); 1.98 + } 1.99 + 1.100 + public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException { 1.101 + bridge.marshal((T) convert(object), output, nsContext, am); 1.102 + } 1.103 + 1.104 + public final void marshal(T object, Result result) throws JAXBException { 1.105 + throw new UnsupportedOperationException(); 1.106 +// bridge.marshal(object, result); 1.107 + } 1.108 + 1.109 + public final void marshal(T object, XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException { 1.110 + bridge.marshal((T) convert(object), output, am); 1.111 + } 1.112 + 1.113 + public String toString() { 1.114 + return BridgeWrapper.class.getName() + " : " + bridge.toString(); 1.115 + } 1.116 + 1.117 + public final T unmarshal(InputStream in) throws JAXBException { 1.118 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.119 + throw new UnsupportedOperationException(); 1.120 +// return bridge.unmarshal(in); 1.121 + } 1.122 + 1.123 + public final T unmarshal(Node n, AttachmentUnmarshaller au) throws JAXBException { 1.124 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.125 + throw new UnsupportedOperationException(); 1.126 +// return bridge.unmarshal(n, au); 1.127 + } 1.128 + 1.129 + public final T unmarshal(Source in, AttachmentUnmarshaller au) throws JAXBException { 1.130 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.131 + throw new UnsupportedOperationException(); 1.132 +// return bridge.unmarshal(in, au); 1.133 + } 1.134 + 1.135 + public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) throws JAXBException { 1.136 + //EndpointArgumentsBuilder.RpcLit.readRequest 1.137 + throw new UnsupportedOperationException(); 1.138 +// return bridge.unmarshal(in, au); 1.139 + } 1.140 + 1.141 + public boolean supportOutputStream() { 1.142 + return true; 1.143 + } 1.144 +}