summaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/xml/providers/XMLInputFactoryProvider.java
blob: a17f09164c8591db309c112e5656e6d482c80861 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.xml.providers;

import com.yahoo.container.di.componentgraph.Provider;

import javax.xml.stream.XMLInputFactory;

/**
 * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
 * @since 5.1.29
 */
public class XMLInputFactoryProvider implements Provider<XMLInputFactory> {
    private static final String INPUT_FACTORY_INTERFACE = XMLInputFactory.class.getName();
    public static final String FACTORY_CLASS = "com.sun.xml.internal.stream.XMLInputFactoryImpl";

    @Override
    public XMLInputFactory get() {
        //ugly, but must be done
        System.setProperty(INPUT_FACTORY_INTERFACE, FACTORY_CLASS);

        // NOTE: In case the newFactory(String, ClassLoader) is used,
        //       the given class loader is ignored if the system property is set!
        return XMLInputFactory.newFactory();
    }

    @Override
    public void deconstruct() { }
}