< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, 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
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.streaming;
  27 
  28 import com.sun.istack.internal.NotNull;
  29 import com.sun.istack.internal.Nullable;
  30 import com.sun.xml.internal.ws.encoding.HasEncoding;
  31 import com.sun.xml.internal.ws.encoding.SOAPBindingCodec;
  32 import com.sun.xml.internal.ws.streaming.XMLReaderException;

  33 import com.sun.xml.internal.ws.util.xml.XMLStreamWriterFilter;
  34 
  35 import javax.xml.stream.XMLOutputFactory;
  36 import javax.xml.stream.XMLStreamException;
  37 import javax.xml.stream.XMLStreamReader;
  38 import javax.xml.stream.XMLStreamWriter;
  39 import javax.xml.transform.stream.StreamResult;
  40 import javax.xml.ws.WebServiceException;
  41 import java.io.OutputStream;
  42 import java.io.StringWriter;
  43 import java.lang.reflect.InvocationTargetException;
  44 import java.lang.reflect.Method;
  45 import java.security.AccessController;
  46 import java.security.PrivilegedAction;
  47 import java.util.logging.Level;
  48 import java.util.logging.Logger;
  49 
  50 /**
  51  * Factory for {@link XMLStreamWriter}.
  52  *


  68             new ContextClassloaderLocal<XMLStreamWriterFactory>() {
  69 
  70         @Override
  71         protected XMLStreamWriterFactory initialValue() {
  72             XMLOutputFactory  xof = null;
  73             if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
  74                 try {
  75                     xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
  76                 } catch (Exception e) {
  77                     // Ignore and fallback to default XMLOutputFactory
  78                 }
  79             }
  80             if (xof == null) {
  81                 xof = XMLOutputFactory.newInstance();
  82             }
  83 
  84             XMLStreamWriterFactory f=null;
  85 
  86             // this system property can be used to disable the pooling altogether,
  87             // in case someone hits an issue with pooling in the production system.
  88             if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) {
  89                 try {
  90                     Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
  91                     if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
  92                         f =  new Zephyr(xof,clazz);
  93                     }
  94                 } catch (XMLStreamException ex) {
  95                     Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
  96                 }
  97             }
  98 
  99             if(f==null) {
 100                 // is this Woodstox?
 101                 if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
 102                     f = new NoLock(xof);
 103             }
 104             if (f == null)
 105                 f = new Default(xof);
 106 
 107             if (LOGGER.isLoggable(Level.FINE)) {
 108                 LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);


   1 /*
   2  * Copyright (c) 1997, 2017, 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
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.streaming;
  27 
  28 import com.sun.istack.internal.NotNull;
  29 import com.sun.istack.internal.Nullable;
  30 import com.sun.xml.internal.ws.encoding.HasEncoding;
  31 import com.sun.xml.internal.ws.encoding.SOAPBindingCodec;
  32 import com.sun.xml.internal.ws.streaming.XMLReaderException;
  33 import com.sun.xml.internal.ws.util.MrJarUtil;
  34 import com.sun.xml.internal.ws.util.xml.XMLStreamWriterFilter;
  35 
  36 import javax.xml.stream.XMLOutputFactory;
  37 import javax.xml.stream.XMLStreamException;
  38 import javax.xml.stream.XMLStreamReader;
  39 import javax.xml.stream.XMLStreamWriter;
  40 import javax.xml.transform.stream.StreamResult;
  41 import javax.xml.ws.WebServiceException;
  42 import java.io.OutputStream;
  43 import java.io.StringWriter;
  44 import java.lang.reflect.InvocationTargetException;
  45 import java.lang.reflect.Method;
  46 import java.security.AccessController;
  47 import java.security.PrivilegedAction;
  48 import java.util.logging.Level;
  49 import java.util.logging.Logger;
  50 
  51 /**
  52  * Factory for {@link XMLStreamWriter}.
  53  *


  69             new ContextClassloaderLocal<XMLStreamWriterFactory>() {
  70 
  71         @Override
  72         protected XMLStreamWriterFactory initialValue() {
  73             XMLOutputFactory  xof = null;
  74             if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
  75                 try {
  76                     xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
  77                 } catch (Exception e) {
  78                     // Ignore and fallback to default XMLOutputFactory
  79                 }
  80             }
  81             if (xof == null) {
  82                 xof = XMLOutputFactory.newInstance();
  83             }
  84 
  85             XMLStreamWriterFactory f=null;
  86 
  87             // this system property can be used to disable the pooling altogether,
  88             // in case someone hits an issue with pooling in the production system.
  89             if (!MrJarUtil.getNoPoolProperty(XMLStreamWriterFactory.class.getName())) {
  90                 try {
  91                     Class<?> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
  92                     if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
  93                         f =  new Zephyr(xof,clazz);
  94                     }
  95                 } catch (XMLStreamException ex) {
  96                     Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
  97                 }
  98             }
  99 
 100             if(f==null) {
 101                 // is this Woodstox?
 102                 if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
 103                     f = new NoLock(xof);
 104             }
 105             if (f == null)
 106                 f = new Default(xof);
 107 
 108             if (LOGGER.isLoggable(Level.FINE)) {
 109                 LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);


< prev index next >