< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/FastInfosetReflection.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  27 
  28 import java.lang.reflect.*;
  29 import javax.xml.transform.Source;
  30 import javax.xml.transform.Result;
  31 import java.io.InputStream;
  32 import java.io.OutputStream;
  33 
  34 import org.w3c.dom.Document;
  35 import org.w3c.dom.Node;
  36 
  37 /**
  38  *
  39  * @author Santiago.PericasGeertsen@sun.com
  40  * @author Paul.Sandoz@sun.com
  41  */
  42 public class FastInfosetReflection {
  43 
  44     /**
  45      * FI DOMDocumentParser constructor using reflection.
  46      */
  47     static Constructor fiDOMDocumentParser_new;
  48 
  49     /**
  50      * FI <code>DOMDocumentParser.parse()</code> method via reflection.
  51      */
  52     static Method fiDOMDocumentParser_parse;
  53 
  54     /**
  55      * FI DOMDocumentSerializer constructor using reflection.
  56      */
  57     static Constructor fiDOMDocumentSerializer_new;
  58 
  59     /**
  60      * FI <code>FastInfosetSource.serialize(Document)</code> method via reflection.
  61      */
  62     static Method fiDOMDocumentSerializer_serialize;
  63 
  64     /**
  65      * FI <code>FastInfosetSource.setOutputStream(OutputStream)</code> method via reflection.
  66      */
  67     static Method fiDOMDocumentSerializer_setOutputStream;
  68 
  69     /**
  70      * FI FastInfosetSource constructor using reflection.
  71      */
  72     static Class fiFastInfosetSource_class;
  73 
  74     /**
  75      * FI FastInfosetSource constructor using reflection.
  76      */
  77     static Constructor fiFastInfosetSource_new;
  78 
  79     /**
  80      * FI <code>FastInfosetSource.getInputStream()</code> method via reflection.
  81      */
  82     static Method fiFastInfosetSource_getInputStream;
  83 
  84     /**
  85      * FI <code>FastInfosetSource.setInputSTream()</code> method via reflection.
  86      */
  87     static Method fiFastInfosetSource_setInputStream;
  88 
  89     /**
  90      * FI FastInfosetResult constructor using reflection.
  91      */
  92     static Constructor fiFastInfosetResult_new;
  93 
  94     /**
  95      * FI <code>FastInfosetResult.getOutputSTream()</code> method via reflection.
  96      */
  97     static Method fiFastInfosetResult_getOutputStream;
  98 
  99     static {
 100         try {
 101             Class clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentParser");
 102             fiDOMDocumentParser_new = clazz.getConstructor((Class[]) null);
 103             fiDOMDocumentParser_parse = clazz.getMethod("parse",
 104                 new Class[] { org.w3c.dom.Document.class, java.io.InputStream.class });
 105 
 106             clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentSerializer");
 107             fiDOMDocumentSerializer_new = clazz.getConstructor((Class[])null);
 108             fiDOMDocumentSerializer_serialize = clazz.getMethod("serialize",
 109                 new Class[] { org.w3c.dom.Node.class });
 110             fiDOMDocumentSerializer_setOutputStream = clazz.getMethod("setOutputStream",
 111                 new Class[] { java.io.OutputStream.class });
 112 
 113             fiFastInfosetSource_class = clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
 114             fiFastInfosetSource_new = clazz.getConstructor(
 115                 new Class[] { java.io.InputStream.class });
 116             fiFastInfosetSource_getInputStream = clazz.getMethod("getInputStream", (Class[]) null);
 117             fiFastInfosetSource_setInputStream = clazz.getMethod("setInputStream",
 118                 new Class[] { java.io.InputStream.class });
 119 
 120             clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
 121             fiFastInfosetResult_new = clazz.getConstructor(


 162         }
 163         fiDOMDocumentSerializer_serialize.invoke(serializer, new Object[] { node });
 164     }
 165 
 166     public static void DOMDocumentSerializer_setOutputStream(Object serializer,
 167         OutputStream os) throws Exception
 168     {
 169         if (fiDOMDocumentSerializer_setOutputStream == null) {
 170             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 171         }
 172         fiDOMDocumentSerializer_setOutputStream.invoke(serializer, new Object[] { os });
 173     }
 174 
 175     // -- FastInfosetSource ----------------------------------------------
 176 
 177     public static boolean isFastInfosetSource(Source source) {
 178         return source.getClass().getName().equals(
 179             "com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
 180     }
 181 
 182     public static Class getFastInfosetSource_class() {
 183         if (fiFastInfosetSource_class == null) {
 184             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 185         }
 186 
 187         return fiFastInfosetSource_class;
 188     }
 189     public static Source FastInfosetSource_new(InputStream is)
 190         throws Exception
 191     {
 192         if (fiFastInfosetSource_new == null) {
 193             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 194         }
 195         return (Source) fiFastInfosetSource_new.newInstance(new Object[] { is });
 196     }
 197 
 198     public static InputStream FastInfosetSource_getInputStream(Source source)
 199         throws Exception
 200     {
 201         if (fiFastInfosetSource_getInputStream == null) {
 202             throw new RuntimeException("Unable to locate Fast Infoset implementation");


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  27 
  28 import java.lang.reflect.*;
  29 import javax.xml.transform.Source;
  30 import javax.xml.transform.Result;
  31 import java.io.InputStream;
  32 import java.io.OutputStream;
  33 
  34 import org.w3c.dom.Document;
  35 import org.w3c.dom.Node;
  36 
  37 /**
  38  *
  39  * @author Santiago.PericasGeertsen@sun.com
  40  * @author Paul.Sandoz@sun.com
  41  */
  42 public class FastInfosetReflection {
  43 
  44     /**
  45      * FI DOMDocumentParser constructor using reflection.
  46      */
  47     static Constructor<?> fiDOMDocumentParser_new;
  48 
  49     /**
  50      * FI <code>DOMDocumentParser.parse()</code> method via reflection.
  51      */
  52     static Method fiDOMDocumentParser_parse;
  53 
  54     /**
  55      * FI DOMDocumentSerializer constructor using reflection.
  56      */
  57     static Constructor<?> fiDOMDocumentSerializer_new;
  58 
  59     /**
  60      * FI <code>FastInfosetSource.serialize(Document)</code> method via reflection.
  61      */
  62     static Method fiDOMDocumentSerializer_serialize;
  63 
  64     /**
  65      * FI <code>FastInfosetSource.setOutputStream(OutputStream)</code> method via reflection.
  66      */
  67     static Method fiDOMDocumentSerializer_setOutputStream;
  68 
  69     /**
  70      * FI FastInfosetSource constructor using reflection.
  71      */
  72     static Class<?> fiFastInfosetSource_class;
  73 
  74     /**
  75      * FI FastInfosetSource constructor using reflection.
  76      */
  77     static Constructor<?> fiFastInfosetSource_new;
  78 
  79     /**
  80      * FI <code>FastInfosetSource.getInputStream()</code> method via reflection.
  81      */
  82     static Method fiFastInfosetSource_getInputStream;
  83 
  84     /**
  85      * FI <code>FastInfosetSource.setInputSTream()</code> method via reflection.
  86      */
  87     static Method fiFastInfosetSource_setInputStream;
  88 
  89     /**
  90      * FI FastInfosetResult constructor using reflection.
  91      */
  92     static Constructor<?> fiFastInfosetResult_new;
  93 
  94     /**
  95      * FI <code>FastInfosetResult.getOutputSTream()</code> method via reflection.
  96      */
  97     static Method fiFastInfosetResult_getOutputStream;
  98 
  99     static {
 100         try {
 101             Class<?> clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentParser");
 102             fiDOMDocumentParser_new = clazz.getConstructor((Class[]) null);
 103             fiDOMDocumentParser_parse = clazz.getMethod("parse",
 104                 new Class[] { org.w3c.dom.Document.class, java.io.InputStream.class });
 105 
 106             clazz = Class.forName("com.sun.xml.internal.fastinfoset.dom.DOMDocumentSerializer");
 107             fiDOMDocumentSerializer_new = clazz.getConstructor((Class[])null);
 108             fiDOMDocumentSerializer_serialize = clazz.getMethod("serialize",
 109                 new Class[] { org.w3c.dom.Node.class });
 110             fiDOMDocumentSerializer_setOutputStream = clazz.getMethod("setOutputStream",
 111                 new Class[] { java.io.OutputStream.class });
 112 
 113             fiFastInfosetSource_class = clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
 114             fiFastInfosetSource_new = clazz.getConstructor(
 115                 new Class[] { java.io.InputStream.class });
 116             fiFastInfosetSource_getInputStream = clazz.getMethod("getInputStream", (Class[]) null);
 117             fiFastInfosetSource_setInputStream = clazz.getMethod("setInputStream",
 118                 new Class[] { java.io.InputStream.class });
 119 
 120             clazz = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetResult");
 121             fiFastInfosetResult_new = clazz.getConstructor(


 162         }
 163         fiDOMDocumentSerializer_serialize.invoke(serializer, new Object[] { node });
 164     }
 165 
 166     public static void DOMDocumentSerializer_setOutputStream(Object serializer,
 167         OutputStream os) throws Exception
 168     {
 169         if (fiDOMDocumentSerializer_setOutputStream == null) {
 170             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 171         }
 172         fiDOMDocumentSerializer_setOutputStream.invoke(serializer, new Object[] { os });
 173     }
 174 
 175     // -- FastInfosetSource ----------------------------------------------
 176 
 177     public static boolean isFastInfosetSource(Source source) {
 178         return source.getClass().getName().equals(
 179             "com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetSource");
 180     }
 181 
 182     public static Class<?> getFastInfosetSource_class() {
 183         if (fiFastInfosetSource_class == null) {
 184             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 185         }
 186 
 187         return fiFastInfosetSource_class;
 188     }
 189     public static Source FastInfosetSource_new(InputStream is)
 190         throws Exception
 191     {
 192         if (fiFastInfosetSource_new == null) {
 193             throw new RuntimeException("Unable to locate Fast Infoset implementation");
 194         }
 195         return (Source) fiFastInfosetSource_new.newInstance(new Object[] { is });
 196     }
 197 
 198     public static InputStream FastInfosetSource_getInputStream(Source source)
 199         throws Exception
 200     {
 201         if (fiFastInfosetSource_getInputStream == null) {
 202             throw new RuntimeException("Unable to locate Fast Infoset implementation");


< prev index next >