1 /*
2 * Copyright (c) 1997, 2015, 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.streaming.XMLReaderException;
31 import com.sun.xml.internal.ws.util.xml.XmlUtil;
32 import org.xml.sax.InputSource;
33
34 import javax.xml.stream.XMLInputFactory;
35 import javax.xml.stream.XMLStreamException;
36 import javax.xml.stream.XMLStreamReader;
37 import java.io.IOException;
38 import java.io.InputStream;
39 import java.io.InputStreamReader;
40 import java.io.Reader;
41 import java.io.StringReader;
42 import java.io.UnsupportedEncodingException;
43 import java.lang.reflect.InvocationTargetException;
44 import java.lang.reflect.Method;
45 import java.net.URL;
46 import java.security.AccessController;
47 import java.util.logging.Level;
48 import java.util.logging.Logger;
49
50 import com.sun.xml.internal.ws.resources.StreamingMessages;
62 public abstract class XMLStreamReaderFactory {
63
64 private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName());
65
66 private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
67
68 /**
69 * Singleton instance.
70 */
71 private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader =
72 new ContextClassloaderLocal<XMLStreamReaderFactory>() {
73
74 @Override
75 protected XMLStreamReaderFactory initialValue() {
76
77 XMLInputFactory xif = getXMLInputFactory();
78 XMLStreamReaderFactory f=null;
79
80 // this system property can be used to disable the pooling altogether,
81 // in case someone hits an issue with pooling in the production system.
82 if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
83 f = Zephyr.newInstance(xif);
84 }
85
86 if(f==null) {
87 // is this Woodstox?
88 if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
89 f = new Woodstox(xif);
90 }
91 }
92
93 if (f==null) {
94 f = new Default();
95 }
96
97 if (LOGGER.isLoggable(Level.FINE)) {
98 LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f);
99 }
100 return f;
101 }
102 };
|
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.streaming.XMLReaderException;
31 import com.sun.xml.internal.ws.util.MrJarUtil;
32 import com.sun.xml.internal.ws.util.xml.XmlUtil;
33 import org.xml.sax.InputSource;
34
35 import javax.xml.stream.XMLInputFactory;
36 import javax.xml.stream.XMLStreamException;
37 import javax.xml.stream.XMLStreamReader;
38 import java.io.IOException;
39 import java.io.InputStream;
40 import java.io.InputStreamReader;
41 import java.io.Reader;
42 import java.io.StringReader;
43 import java.io.UnsupportedEncodingException;
44 import java.lang.reflect.InvocationTargetException;
45 import java.lang.reflect.Method;
46 import java.net.URL;
47 import java.security.AccessController;
48 import java.util.logging.Level;
49 import java.util.logging.Logger;
50
51 import com.sun.xml.internal.ws.resources.StreamingMessages;
63 public abstract class XMLStreamReaderFactory {
64
65 private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName());
66
67 private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
68
69 /**
70 * Singleton instance.
71 */
72 private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader =
73 new ContextClassloaderLocal<XMLStreamReaderFactory>() {
74
75 @Override
76 protected XMLStreamReaderFactory initialValue() {
77
78 XMLInputFactory xif = getXMLInputFactory();
79 XMLStreamReaderFactory f=null;
80
81 // this system property can be used to disable the pooling altogether,
82 // in case someone hits an issue with pooling in the production system.
83 if(!MrJarUtil.getNoPoolProperty(XMLStreamReaderFactory.class.getName())) {
84 f = Zephyr.newInstance(xif);
85 }
86
87 if(f==null) {
88 // is this Woodstox?
89 if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
90 f = new Woodstox(xif);
91 }
92 }
93
94 if (f==null) {
95 f = new Default();
96 }
97
98 if (LOGGER.isLoggable(Level.FINE)) {
99 LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f);
100 }
101 return f;
102 }
103 };
|