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

liquibase.parser.core.xml.ContextClassLoaderXsdStreamResolver Maven / Gradle / Ivy

There is a newer version: 3.6.2.5.inovus
Show newest version
package liquibase.parser.core.xml;

import liquibase.logging.LogService;
import liquibase.logging.LogType;
import liquibase.logging.Logger;

import java.io.InputStream;

public class ContextClassLoaderXsdStreamResolver extends XsdStreamResolver {

    private static final Logger LOGGER = LogService.getLog(ContextClassLoaderXsdStreamResolver.class);

    @Override
    public InputStream getResourceAsStream(String xsdFile) {
        LOGGER.debug(LogType.LOG, "Trying to load resource from context classloader");

        if (Thread.currentThread().getContextClassLoader() == null) {
            LOGGER.debug(LogType.LOG, "Failed to load resource from context classloader");
            return getSuccessorValue(xsdFile);
        }

        InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(xsdFile);
        if(resourceAsStream == null){
            LOGGER.debug(LogType.LOG, "Failed to load resource from context classloader");
            return getSuccessorValue(xsdFile);
        }
        return resourceAsStream;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy