class DefaultServiceContext implements ServiceContext {

    @Override
    public <T> T getService(Class<T> serviceType, Supplier<T> supplier) {
        T service = (T)singletons.get(serviceType);
        if(service!=null){
            return service;
        }
        Collection<T> services = loadServices(serviceType, null);
        if (services.isEmpty() && supplier!=null){
            T instance = supplier.get();
            if(instance instanceof ClassloaderAware){
                ((ClassloaderAware)instance).init(this.classLoader);
            }
            register(serviceType, instance, true);
            return instance;
        }
        T t = getServiceWithHighestPriority(services, serviceType);
        if(t!=null) {
            this.singletons.put(serviceType, t);
        }
        return t;
    }

}