Java – can I dynamically load other spring configuration files into an existing web application context?
In Tomcat 6.0 After starting my webapp in 18, I just use what is needed to initialize the system to boot spring - that is, now, database migration I do not want to load any part of the system until the migration completes successfully This prevents other beans from waiting for migration to complete before operation or even instantiation
I have a startup - appcontext with dbmigration Dao configured XML, a startupmanager of ThreadPoolExecutor, and finally a fullsystemlaunch bean I pass the configuration location list to the fullsystemlaunch bean through setter injection The fullsystemlaunch bean implements servletcontextaware and obtains a reference to the current webapplicationcontext, so I can own the configurablelistablebeanfactory Unfortunately, the bean factory isconfigurationfrozen () returns true, so by calling beanfactory Setconfiglocations (configlocations) is invalid
Can I do this, or does spring prevent me from doing so because it's a little different? This seems reasonable if understood, but it is also a bit dangerous Yes, I am willing to blow out the current context. After B / C initialization is completed, the currently loaded singleton is not required
Thank you for your help
Solution
You can use an existing context as the parent context of other contexts, but I doubt if you can replace the existing webapplicationcontext
If you use ear-war packaging, you can get out of the box (type) by loading the application context from ear and then adding an application context to the war
I'm not sure if this applies to your situation