Automatic configuration reinitialization in Spring

前端 未结 5 656
谎友^
谎友^ 2021-01-04 11:18

In Log4j, there is a feature wherein the system can be initialized to do a configure and watch with an interval. This allows for the log4j system to reload its properties wh

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-04 11:41

    If you would like to add context, I have done that in the following way :

    public class ApplicationContextUtil
    {
       static String[] configFiles = {"applicationContextParent.xml"};
    
       private static ApplicationContext context = null;
    
       static
       {
           context = new ClassPathXmlApplicationContext ( configFiles );
       }
    
       public static void addContext( String[] newConfigFiles )
       {
           // add the new context to the previous context
           ApplicationContext newContext =  new ClassPathXmlApplicationContext ( newConfigFiles, context );
           context = newContext;
       }   
       public static ApplicationContext getApplicationContext ()
       {
           // return the context
           return context;
       }
    }
    

    This is your context provider class. For details, you can look at my blog

提交回复
热议问题