Search in sources :

Example 1 with StandardServiceLocator

use of liquibase.servicelocator.StandardServiceLocator in project liquibase by liquibase.

the class Scope method getCurrentScope.

public static Scope getCurrentScope() {
    if (scopeManager == null) {
        scopeManager = new SingletonScopeManager();
    }
    if (scopeManager.getCurrentScope() == null) {
        Scope rootScope = new Scope();
        scopeManager.setCurrentScope(rootScope);
        rootScope.values.put(Attr.logService.name(), new JavaLogService());
        rootScope.values.put(Attr.resourceAccessor.name(), new ClassLoaderResourceAccessor());
        rootScope.values.put(Attr.serviceLocator.name(), new StandardServiceLocator());
        rootScope.values.put(Attr.ui.name(), new ConsoleUIService());
        rootScope.getSingleton(LiquibaseConfiguration.class).init(rootScope);
        LogService overrideLogService = rootScope.getSingleton(LogServiceFactory.class).getDefaultLogService();
        if (overrideLogService == null) {
            throw new UnexpectedLiquibaseException("Cannot find default log service");
        }
        rootScope.values.put(Attr.logService.name(), overrideLogService);
        // check for higher-priority serviceLocator
        ServiceLocator serviceLocator = rootScope.getServiceLocator();
        for (ServiceLocator possibleLocator : serviceLocator.findInstances(ServiceLocator.class)) {
            if (possibleLocator.getPriority() > serviceLocator.getPriority()) {
                serviceLocator = possibleLocator;
            }
        }
        rootScope.values.put(Attr.serviceLocator.name(), serviceLocator);
        rootScope.values.put(Attr.osgiPlatform.name(), Activator.OSGIContainerChecker.isOsgiPlatform());
    }
    return scopeManager.getCurrentScope();
}
Also used : StandardServiceLocator(liquibase.servicelocator.StandardServiceLocator) ServiceLocator(liquibase.servicelocator.ServiceLocator) ConsoleUIService(liquibase.ui.ConsoleUIService) StandardServiceLocator(liquibase.servicelocator.StandardServiceLocator) JavaLogService(liquibase.logging.core.JavaLogService) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) LogServiceFactory(liquibase.logging.core.LogServiceFactory) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LogService(liquibase.logging.LogService) JavaLogService(liquibase.logging.core.JavaLogService)

Aggregations

LiquibaseConfiguration (liquibase.configuration.LiquibaseConfiguration)1 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)1 LogService (liquibase.logging.LogService)1 JavaLogService (liquibase.logging.core.JavaLogService)1 LogServiceFactory (liquibase.logging.core.LogServiceFactory)1 ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)1 ServiceLocator (liquibase.servicelocator.ServiceLocator)1 StandardServiceLocator (liquibase.servicelocator.StandardServiceLocator)1 ConsoleUIService (liquibase.ui.ConsoleUIService)1