package com.mogo.realtime.spi;


import com.elegant.spi.AbstractDelegateManager;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.api.IRealTimeProvider;

/**
 * 提供RealTime SPI接口实例对象管理类
 */
class RealTimeProviderDelegateManager extends AbstractDelegateManager<IRealTimeProvider> {
    private static RealTimeProviderDelegateManager sInstance = null;
    private IRealTimeProvider mRealTimeProvider = null;

    public static RealTimeProviderDelegateManager getInstance() {
        if (sInstance == null) {
            synchronized (RealTimeProviderDelegateManager.class) {
                if (sInstance == null) {
                    sInstance = new RealTimeProviderDelegateManager();
                }
            }
        }
        return sInstance;
    }

    public RealTimeProviderDelegateManager() {
        loadDelegates(MoGoAiCloudClient.getInstance().getContext(), IRealTimeProvider.class, (unit, p)
                -> mRealTimeProvider = p);
    }

    public IRealTimeProvider getRealTimeProvider(){
        return mRealTimeProvider;
    }
}
