All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.apicurio.registry.util.SchemaFactoryAccessor Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
package io.apicurio.registry.util;

import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;

import javax.xml.XMLConstants;
import javax.xml.validation.SchemaFactory;

public class SchemaFactoryAccessor {

    private static ThreadLocal threadLocalSchemaFactory = new ThreadLocal() {
        @Override
        protected SchemaFactory initialValue() {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            try {
                factory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
                factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
            } catch (SAXNotRecognizedException | SAXNotSupportedException e) {
                // Don't care.
            }
            return factory;
        }
    };

    public static final SchemaFactory getSchemaFactory() {
        return threadLocalSchemaFactory.get();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy