/*
 * common - com.bxl.common.util - ApplicationContextProvider        
 *
 * @author Bao Xiaolu
 * @contact baoxiaolumail@gmail.com
 * @date 2017/2/8
 * 
 * Copyright © https://github.com/CharlotteBao
 * All rights reserved.
 */
package com.bxl.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Spring 上下文提供者
 * <br>
 *     how to use:
 *     <pre>
 *         TestBean tb = ApplicationContextProvider.getApplicationContext().getBean(TestBean.class);
 *     </pre>
 *
 * @since 1.1.0
 */
public class ApplicationContextProvider implements ApplicationContextAware {

    private static ApplicationContext context;

    public static ApplicationContext getApplicationContext() { return context; }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

    }
}

@@ -438,19 +438,204 @@
 g %E4%B8%8A%E4%B8%8B%E6%96%87%E6%8F%90%E4%BE%9B%E8%80%85
+.
 %0A *
+ %E6%8F%90%E4%BE%9B%E6%89%8B%E5%8A%A8%E4%BB%8ESpring%E4%B8%8A%E4%B8%8B%E6%96%87%E4%B8%AD%E8%8E%B7%E5%8F%96Bean%E7%9A%84%E6%94%AF%E6%8C%81.%0A * %3Cbr%3E%0A *     how to define:%0A *     %3Cpre%3E%0A *         %3Cbean class=%22com.bxl.common.util.ApplicationContextProvider%22  lazy-init=%22false%22 /%3E%0A *     %3C/pre%3E%0A *    
  %3Cbr%3E%0A *
@@ -990,16 +990,59 @@
 text() %7B
+%0A        checkApplicationContext();%0A       
  return 
@@ -1049,16 +1049,20 @@
 context;
+%0A   
  %7D%0A%0A    
@@ -1172,16 +1172,265 @@
 ption %7B%0A
+        context = applicationContext;%0A    %7D%0A%0A    private static void checkApplicationContext() %7B%0A        if (context == null)%0A            throw new IllegalStateException(%22applicaitonContext%E6%9C%AA%E6%B3%A8%E5%85%A5,%E8%AF%B7%E5%9C%A8applicationContext.xml%E4%B8%AD%E5%AE%9A%E4%B9%89ApplicationContextProvider%22);
 %0A    %7D%0A%7D

update ApplicationContextProvider