src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/util/FastInfosetReflection.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.messaging.saaj.util;
ohair@286 27
ohair@286 28 import java.lang.reflect.*;
ohair@286 29 import javax.xml.transform.Source;
ohair@286 30 import javax.xml.transform.Result;
ohair@286 31 import java.io.InputStream;
ohair@286 32 import java.io.OutputStream;
ohair@286 33
ohair@286 34 import org.w3c.dom.Document;
ohair@286 35 import org.w3c.dom.Node;
ohair@286 36
ohair@286 37 /**
ohair@286 38 *
ohair@286 39 * @author Santiago.PericasGeertsen@sun.com
ohair@286 40 * @author Paul.Sandoz@sun.com
ohair@286 41 */
ohair@286 42 public class FastInfosetReflection {
ohair@286 43
ohair@286 44 /**
ohair@286 45 * FI DOMDocumentParser constructor using reflection.
ohair@286 46 */
ohair@286 47 static Constructor fiDOMDocumentParser_new;
ohair@286 48
ohair@286 49 /**
ohair@286 50 * FI <code>DOMDocumentParser.parse()</code> method via reflection.
ohair@286 51 */
ohair@286 52 static Method fiDOMDocumentParser_parse;
ohair@286 53
ohair@286 54 /**
ohair@286 55 * FI DOMDocumentSerializer constructor using reflection.
ohair@286 56 */
ohair@286 57 static Constructor fiDOMDocumentSerializer_new;
ohair@286 58
ohair@286 59 /**
ohair@286 60 * FI <code>FastInfosetSource.serialize(Document)</code> method via reflection.
ohair@286 61 */
ohair@286 62 static Method fiDOMDocumentSerializer_serialize;
ohair@286 63
ohair@286 64 /**
ohair@286 65 * FI <code>FastInfosetSource.setOutputStream(OutputStream)</code> method via reflection.
ohair@286 66 */
ohair@286 67 static Method fiDOMDocumentSerializer_setOutputStream;
ohair@286 68
ohair@286 69 /**
ohair@286 70 * FI FastInfosetSource constructor using reflection.
ohair@286 71 */
ohair@286 72 static Class fiFastInfosetSource_class;
ohair@286 73
ohair@286 74 /**
ohair@286 75 * FI FastInfosetSource constructor using reflection.
ohair@286 76 */
ohair@286 77 static Constructor fiFastInfosetSource_new;
ohair@286 78
ohair@286 79 /**
ohair@286 80 * FI <code>FastInfosetSource.getInputStream()</code> method via reflection.
ohair@286 81 */
ohair@286 82 static Method fiFastInfosetSource_getInputStream;
ohair@286 83
ohair@286 84 /**
ohair@286 85 * FI <code>FastInfosetSource.setInputSTream()</code> method via reflection.
ohair@286 86 */
ohair@286 87 static Method fiFastInfosetSource_setInputStream;
ohair@286 88
ohair@286 89 /**
ohair@286 90 * FI FastInfosetResult constructor using reflection.
ohair@286 91 */
ohair@286 92 static Constructor fiFastInfosetResult_new;
ohair@286 93
ohair@286 94 /**
ohair@286 95 * FI <code>FastInfosetResult.getOutputSTream()</code> method via reflection.
ohair@286 96 */
ohair@286 97 static Method fiFastInfosetResult_getOutputStream;
ohair@286 98
ohair@286 99 static {
ohair@286 100 try {
ohair@286 101 Class clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentParser");
ohair@286 102 fiDOMDocumentParser_new = clazz.getConstructor((Class[]) null);
ohair@286 103 fiDOMDocumentParser_parse = clazz.getMethod("parse",
ohair@286 104 new Class[] { org.w3c.dom.Document.class, java.io.InputStream.class });
ohair@286 105
ohair@286 106 clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentSerializer");
ohair@286 107 fiDOMDocumentSerializer_new = clazz.getConstructor((Class[])null);
ohair@286 108 fiDOMDocumentSerializer_serialize = clazz.getMethod("serialize",
ohair@286 109 new Class[] { org.w3c.dom.Node.class });
ohair@286 110 fiDOMDocumentSerializer_setOutputStream = clazz.getMethod("setOutputStream",
ohair@286 111 new Class[] { java.io.OutputStream.class });
ohair@286 112
ohair@286 113 fiFastInfosetSource_class = clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
ohair@286 114 fiFastInfosetSource_new = clazz.getConstructor(
ohair@286 115 new Class[] { java.io.InputStream.class });
ohair@286 116 fiFastInfosetSource_getInputStream = clazz.getMethod("getInputStream", (Class[]) null);
ohair@286 117 fiFastInfosetSource_setInputStream = clazz.getMethod("setInputStream",
ohair@286 118 new Class[] { java.io.InputStream.class });
ohair@286 119
ohair@286 120 clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
ohair@286 121 fiFastInfosetResult_new = clazz.getConstructor(
ohair@286 122 new Class[] { java.io.OutputStream.class });
ohair@286 123 fiFastInfosetResult_getOutputStream = clazz.getMethod("getOutputStream", (Class[]) null);
ohair@286 124 }
ohair@286 125 catch (Exception e) {
ohair@286 126 // falls through
ohair@286 127 }
ohair@286 128 }
ohair@286 129
ohair@286 130 // -- DOMDocumentParser ----------------------------------------------
ohair@286 131
ohair@286 132 public static Object DOMDocumentParser_new() throws Exception {
ohair@286 133 if (fiDOMDocumentParser_new == null) {
ohair@286 134 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 135 }
ohair@286 136 return fiDOMDocumentParser_new.newInstance((Object[])null);
ohair@286 137 }
ohair@286 138
ohair@286 139 public static void DOMDocumentParser_parse(Object parser,
ohair@286 140 Document d, InputStream s) throws Exception
ohair@286 141 {
ohair@286 142 if (fiDOMDocumentParser_parse == null) {
ohair@286 143 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 144 }
ohair@286 145 fiDOMDocumentParser_parse.invoke(parser, new Object[] { d, s });
ohair@286 146 }
ohair@286 147
ohair@286 148 // -- DOMDocumentSerializer-------------------------------------------
ohair@286 149
ohair@286 150 public static Object DOMDocumentSerializer_new() throws Exception {
ohair@286 151 if (fiDOMDocumentSerializer_new == null) {
ohair@286 152 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 153 }
ohair@286 154 return fiDOMDocumentSerializer_new.newInstance((Object[])null);
ohair@286 155 }
ohair@286 156
ohair@286 157 public static void DOMDocumentSerializer_serialize(Object serializer, Node node)
ohair@286 158 throws Exception
ohair@286 159 {
ohair@286 160 if (fiDOMDocumentSerializer_serialize == null) {
ohair@286 161 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 162 }
ohair@286 163 fiDOMDocumentSerializer_serialize.invoke(serializer, new Object[] { node });
ohair@286 164 }
ohair@286 165
ohair@286 166 public static void DOMDocumentSerializer_setOutputStream(Object serializer,
ohair@286 167 OutputStream os) throws Exception
ohair@286 168 {
ohair@286 169 if (fiDOMDocumentSerializer_setOutputStream == null) {
ohair@286 170 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 171 }
ohair@286 172 fiDOMDocumentSerializer_setOutputStream.invoke(serializer, new Object[] { os });
ohair@286 173 }
ohair@286 174
ohair@286 175 // -- FastInfosetSource ----------------------------------------------
ohair@286 176
ohair@286 177 public static boolean isFastInfosetSource(Source source) {
ohair@286 178 return source.getClass().getName().equals(
ohair@286 179 "com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
ohair@286 180 }
ohair@286 181
ohair@286 182 public static Class getFastInfosetSource_class() {
ohair@286 183 if (fiFastInfosetSource_class == null) {
ohair@286 184 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 185 }
ohair@286 186
ohair@286 187 return fiFastInfosetSource_class;
ohair@286 188 }
ohair@286 189 public static Source FastInfosetSource_new(InputStream is)
ohair@286 190 throws Exception
ohair@286 191 {
ohair@286 192 if (fiFastInfosetSource_new == null) {
ohair@286 193 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 194 }
ohair@286 195 return (Source) fiFastInfosetSource_new.newInstance(new Object[] { is });
ohair@286 196 }
ohair@286 197
ohair@286 198 public static InputStream FastInfosetSource_getInputStream(Source source)
ohair@286 199 throws Exception
ohair@286 200 {
ohair@286 201 if (fiFastInfosetSource_getInputStream == null) {
ohair@286 202 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 203 }
ohair@286 204 return (InputStream) fiFastInfosetSource_getInputStream.invoke(source, (Object[])null);
ohair@286 205 }
ohair@286 206
ohair@286 207 public static void FastInfosetSource_setInputStream(Source source,
ohair@286 208 InputStream is) throws Exception
ohair@286 209 {
ohair@286 210 if (fiFastInfosetSource_setInputStream == null) {
ohair@286 211 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 212 }
ohair@286 213 fiFastInfosetSource_setInputStream.invoke(source, new Object[] { is });
ohair@286 214 }
ohair@286 215
ohair@286 216 // -- FastInfosetResult ----------------------------------------------
ohair@286 217
ohair@286 218 public static boolean isFastInfosetResult(Result result) {
ohair@286 219 return result.getClass().getName().equals(
ohair@286 220 "com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
ohair@286 221 }
ohair@286 222
ohair@286 223 public static Result FastInfosetResult_new(OutputStream os)
ohair@286 224 throws Exception
ohair@286 225 {
ohair@286 226 if (fiFastInfosetResult_new == null) {
ohair@286 227 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 228 }
ohair@286 229 return (Result) fiFastInfosetResult_new.newInstance(new Object[] { os });
ohair@286 230 }
ohair@286 231
ohair@286 232 public static OutputStream FastInfosetResult_getOutputStream(Result result)
ohair@286 233 throws Exception
ohair@286 234 {
ohair@286 235 if (fiFastInfosetResult_getOutputStream == null) {
ohair@286 236 throw new RuntimeException("Unable to locate Fast Infoset implementation");
ohair@286 237 }
ohair@286 238 return (OutputStream) fiFastInfosetResult_getOutputStream.invoke(result, (Object[])null);
ohair@286 239 }
ohair@286 240 }

mercurial