package com.tsi.app.common.app;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Component
public class AppContextProvider implements ApplicationContextAware {
    private static ApplicationContext applicationContext;
    private static String applicationId;
    private static Environment environment;

    private AppContextProvider() {
    }

    @Override
    public void setApplicationContext(ApplicationContext ctx) throws BeansException {
        applicationContext = ctx;
        applicationId = ctx.getId();
        environment = ctx.getEnvironment();
    }

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }
    public static String getApplicationId() {
        return applicationId;
    }
    public static Environment getApplicationEnvironment() {
        return environment;
    }
}
