/*    */ package com.picc.grab.config;
/*    */ 
/*    */ import org.springframework.beans.BeansException;
/*    */ import org.springframework.context.ApplicationContext;
/*    */ import org.springframework.context.ApplicationContextAware;
/*    */ import org.springframework.stereotype.Component;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Component
/*    */ public class SpringContextHolder
/*    */   implements ApplicationContextAware
/*    */ {
/*    */   private static ApplicationContext applicationContext;
/*    */   
/*    */   public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
/* 21 */     SpringContextHolder.applicationContext = applicationContext;
/*    */   }
/*    */   
/*    */   public static ApplicationContext getApplicationContext() {
/* 25 */     assertApplicationContext();
/* 26 */     return applicationContext;
/*    */   }
/*    */ 
/*    */   
/*    */   public static <T> T getBean(String beanName) {
/* 31 */     assertApplicationContext();
/* 32 */     return (T)applicationContext.getBean(beanName);
/*    */   }
/*    */   
/*    */   public static <T> T getBean(Class<T> requiredType) {
/* 36 */     assertApplicationContext();
/* 37 */     return (T)applicationContext.getBean(requiredType);
/*    */   }
/*    */   
/*    */   private static void assertApplicationContext() {
/* 41 */     if (applicationContext == null)
/* 42 */       throw new RuntimeException("applicaitonContext属性为null,请检查是否注入了SpringContextHolder!"); 
/*    */   }
/*    */ }


/* Location:              C:\Users\Administrator\Desktop\ROOT\WEB-INF\classes\!\com\picc\grab\config\SpringContextHolder.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */