A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
738 B

  1. package org.ros.chatto.logged;
  2. import org.springframework.beans.BeansException;
  3. import org.springframework.context.ApplicationContext;
  4. import org.springframework.context.ApplicationContextAware;
  5. import org.springframework.stereotype.Service;
  6. import lombok.extern.slf4j.Slf4j;
  7. @Service
  8. @Slf4j
  9. public class BeanUtil implements ApplicationContextAware {
  10. private static ApplicationContext context;
  11. @Override
  12. public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  13. context = applicationContext;
  14. }
  15. public static <T> T getBean(Class<T> beanClass) {
  16. log.debug("Instantiating class {}", beanClass.getName());
  17. return context.getBean(beanClass);
  18. }
  19. }