2
* Copyright 2003-2007 the original author or authors.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
import javax.xml.parsers.ParserConfigurationException;
20
import javax.xml.parsers.DocumentBuilderFactory;
21
import javax.xml.parsers.SAXParserFactory;
22
import java.security.PrivilegedExceptionAction;
23
import java.security.AccessController;
24
import java.security.PrivilegedActionException;
27
* Support class for creating XML Factories
29
public class FactorySupport {
30
static Object createFactory(PrivilegedExceptionAction action) throws ParserConfigurationException {
33
factory = AccessController.doPrivileged(action);
34
} catch (PrivilegedActionException pae) {
35
Exception e = pae.getException();
36
if (e instanceof ParserConfigurationException) {
37
throw(ParserConfigurationException) e;
39
throw new RuntimeException(e);
45
public static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException {
46
return (DocumentBuilderFactory) createFactory(new PrivilegedExceptionAction() {
47
public Object run() throws ParserConfigurationException {
48
return DocumentBuilderFactory.newInstance();
53
public static SAXParserFactory createSaxParserFactory() throws ParserConfigurationException {
54
return (SAXParserFactory) createFactory(new PrivilegedExceptionAction() {
55
public Object run() throws ParserConfigurationException {
56
return SAXParserFactory.newInstance();
2
* Copyright 2003-2007 the original author or authors.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
import javax.xml.parsers.ParserConfigurationException;
20
import javax.xml.parsers.DocumentBuilderFactory;
21
import javax.xml.parsers.SAXParserFactory;
22
import java.security.PrivilegedExceptionAction;
23
import java.security.AccessController;
24
import java.security.PrivilegedActionException;
27
* Support class for creating XML Factories
29
public class FactorySupport {
30
static Object createFactory(PrivilegedExceptionAction action) throws ParserConfigurationException {
33
factory = AccessController.doPrivileged(action);
34
} catch (PrivilegedActionException pae) {
35
Exception e = pae.getException();
36
if (e instanceof ParserConfigurationException) {
37
throw(ParserConfigurationException) e;
39
throw new RuntimeException(e);
45
public static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException {
46
return (DocumentBuilderFactory) createFactory(new PrivilegedExceptionAction() {
47
public Object run() throws ParserConfigurationException {
48
return DocumentBuilderFactory.newInstance();
53
public static SAXParserFactory createSaxParserFactory() throws ParserConfigurationException {
54
return (SAXParserFactory) createFactory(new PrivilegedExceptionAction() {
55
public Object run() throws ParserConfigurationException {
56
return SAXParserFactory.newInstance();