Background:
1, Tomcat project start-up is relatively slow, will lead to a long period of time can not provide services to the outside.
2, the number of servers is more, the update of one operation will take a long time.
Describe:
Make adjustments to the system framework, turn frequently updated features into spring jar packages, and place them on a Web site, and then the system deployed on Tomcat automatically requests the latest spring jar packages from the Web site.
Note: This is not implemented with Mbean, given the performance of the system.
Implementing Critical Code:
1, JAR Package resolution
Myclassloader = new URLClassLoader (new url[] {url},context.getclassloader ());
Thread.CurrentThread (). Setcontextclassloader (Myclassloader);
2. Use the new JAR package
Defaultlistablebeanfactory defaultlistablebeanfactory = (defaultlistablebeanfactory) Context.getautowirecapablebeanfactory ();
Defaultlistablebeanfactory.setbeanclassloader (Myclassloader);
3, the Bean loaded initialization
Simplebeandefinitionregistry Registry = new Simplebeandefinitionregistry ();
Xmlbeandefinitionreaderreader =new Xmlbeandefinitionreader ((beandefinitionregistry) registry);
Reader.loadbeandefinitions (R);
4. Bean Update
String [] beannames = Registry.getbeandefinitionnames ();
for (String n:beannames) {
Defaultlistablebeanfactory.registerbeandefinition (N,registry.getbeandefinition (n));
}