add api context and logout

This commit is contained in:
dirgantarasiahaan
2023-05-25 15:39:36 +07:00
parent f0dfef725a
commit c4700af832
8 changed files with 377 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package com.iconplus.smartproc.helper.context;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class ContextProvider implements ApplicationContextAware {
private static ApplicationContext CONTEXT;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
CONTEXT = applicationContext;
}
/**
* Get a Spring bean by type.
**/
public static <T> T getBean(Class<T> beanClass) {
return CONTEXT.getBean(beanClass);
}
/**
* Get a Spring bean by name.
**/
public static Object getBean(String beanName) {
return CONTEXT.getBean(beanName);
}
}