1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Sep 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xml.internal.utils;
23
25 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
26 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
27 import java.util.HashMap;
28 import javax.xml.XMLConstants;
29 import javax.xml.catalog.CatalogFeatures;
30 import javax.xml.parsers.FactoryConfigurationError;
31 import javax.xml.parsers.ParserConfigurationException;
32 import javax.xml.parsers.SAXParserFactory;
33 import jdk.xml.internal.JdkXmlFeatures;
34 import jdk.xml.internal.JdkXmlUtils;
35 import jdk.xml.internal.SecuritySupport;
36 import org.xml.sax.SAXException;
37 import org.xml.sax.SAXNotRecognizedException;
38 import org.xml.sax.SAXNotSupportedException;
39 import org.xml.sax.XMLReader;
40 import org.xml.sax.helpers.XMLReaderFactory;
41
42 /**
43 * Creates XMLReader objects and caches them for re-use.
44 * This class follows the singleton pattern.
45 */
46 @SuppressWarnings("deprecation") //org.xml.sax.helpers.XMLReaderFactory
47 public class XMLReaderManager {
48
49 private static final String NAMESPACES_FEATURE =
50 "http://xml.org/sax/features/namespaces";
51 private static final String NAMESPACE_PREFIXES_FEATURE =
52 "http://xml.org/sax/features/namespace-prefixes";
53 private static final XMLReaderManager m_singletonManager =
54 new XMLReaderManager();
55 private static final String property = "org.xml.sax.driver";
56 /**
57 * Parser factory to be used to construct XMLReader objects
58 */
59 private static SAXParserFactory m_parserFactory;
60
61 /**
62 * Cache of XMLReader objects
63 */
64 private ThreadLocal<XMLReader> m_readers;
|
1 /*
2 * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.xml.internal.utils;
22
24 import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
25 import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
26 import java.util.HashMap;
27 import javax.xml.XMLConstants;
28 import javax.xml.catalog.CatalogFeatures;
29 import javax.xml.parsers.FactoryConfigurationError;
30 import javax.xml.parsers.ParserConfigurationException;
31 import javax.xml.parsers.SAXParserFactory;
32 import jdk.xml.internal.JdkXmlFeatures;
33 import jdk.xml.internal.JdkXmlUtils;
34 import jdk.xml.internal.SecuritySupport;
35 import org.xml.sax.SAXException;
36 import org.xml.sax.SAXNotRecognizedException;
37 import org.xml.sax.SAXNotSupportedException;
38 import org.xml.sax.XMLReader;
39 import org.xml.sax.helpers.XMLReaderFactory;
40
41 /**
42 * Creates XMLReader objects and caches them for re-use.
43 * This class follows the singleton pattern.
44 *
45 * @LastModified: Sep 2017
46 */
47 @SuppressWarnings("deprecation") //org.xml.sax.helpers.XMLReaderFactory
48 public class XMLReaderManager {
49
50 private static final String NAMESPACES_FEATURE =
51 "http://xml.org/sax/features/namespaces";
52 private static final String NAMESPACE_PREFIXES_FEATURE =
53 "http://xml.org/sax/features/namespace-prefixes";
54 private static final XMLReaderManager m_singletonManager =
55 new XMLReaderManager();
56 private static final String property = "org.xml.sax.driver";
57 /**
58 * Parser factory to be used to construct XMLReader objects
59 */
60 private static SAXParserFactory m_parserFactory;
61
62 /**
63 * Cache of XMLReader objects
64 */
65 private ThreadLocal<XMLReader> m_readers;
|