public <T extends SingletonObject> T getSingleton(Class<T> type) {
        if (getParent() != null) {
            return getParent().getSingleton(type);
        }

        String key = type.getName();
        T singleton = get(key, type);
        if (singleton == null) {
            try {
                try {
                    Constructor<T> constructor = type.getDeclaredConstructor(Scope.class);
                    constructor.setAccessible(true);
                    singleton = constructor.newInstance(this);
                } catch (NoSuchMethodException e) { //try without scope
                    Constructor<T> constructor = type.getDeclaredConstructor();
                    constructor.setAccessible(true);
                    singleton = constructor.newInstance();
                }
            } catch (Exception e) {
                throw new UnexpectedLiquibaseException(e);
            }

            values.put(key, singleton);
        }
        return singleton;
    }
public <T extends SingletonObject> T getSingleton(Class<T> type) {
        if (getParent() != null) {
            return getParent().getSingleton(type);
        }

        String key = type.getName();
        T singleton = get(key, type);
        if (singleton == null) {
            try {
                try {
                    Constructor<T> constructor = type.getDeclaredConstructor(Scope.class);
                    constructor.setAccessible(true);
                    singleton = constructor.newInstance(this);
                } catch (NoSuchMethodException e) { 
                    Constructor<T> constructor = type.getDeclaredConstructor();
                    constructor.setAccessible(true);
                    singleton = constructor.newInstance();
                }
            } catch (Exception e) {
                throw new UnexpectedLiquibaseException(e);
            }

            values.put(key, singleton);
        }
        return singleton;
    }
public < T extends SingletonObject > T getSingleton ( Class < T > type ) { if ( getParent ( ) != null ) { return getParent ( ) . getSingleton ( type ) ; } String key = type . getName ( ) ; T singleton = get ( key , type ) ; if ( singleton == null ) { try { try { Constructor < T > constructor = type . getDeclaredConstructor ( Scope . class ) ; constructor . setAccessible ( true ) ; singleton = constructor . newInstance ( this ) ; } catch ( NoSuchMethodException e ) { //try without scope Constructor < T > constructor = type . getDeclaredConstructor ( ) ; constructor . setAccessible ( true ) ; singleton = constructor . newInstance ( ) ; } } catch ( Exception e ) { throw new UnexpectedLiquibaseException ( e ) ; } values . put ( key , singleton ) ; } return singleton ; }
Looks up the singleton object of the given type. If the singleton has not been created yet, it will be instantiated.
The singleton is a singleton based on the root scope and the same object will be returned for all child scopes of the root.
Looks up the singleton object of the given type . If the singleton has not been created yet it will be instantiated . The singleton is a singleton based on the root scope and the same object will be returned for all child scopes of the root .