1. Introduction
Spring-loaded is an agent based on javaagent implementation, and more javaagent can refer to:
java proxy-javassist:http://my.oschina.net/outofmemory/blog/309283
Official website: https://github.com/spring-projects/spring-loaded
Current Latest version: 1.2.4. RELEASE
2. Description
Currently the latest version of 1.2.4. release implementation of the monitoring jar package update mechanism, the implementation of the Hot update jar package, the current version of the official provided on Linux can run very well, but there are bugs in Windows, the official website has been proposed: https://github.com/ spring-projects/spring-loaded/issues/145. If you want to test on Windows, you can manually change the source code.
3. Parameters
-dspringloaded=watchjars=main.jar:other.jar
The Watchjars option, which listens for multiple jars before using: Detach
4. Example
take win for example, here need to manually change the source code, compile
Test Catalog:
Lib:Springloaded-1.2.4.release.jar
Main-0.0.1-snapshot.jar is a test jar package, usually a game logic jar package, which tests
Package Org.main;import java.util.concurrent.timeunit;/** * Hello world! * */public class App {public static void main (string[] args) throws Interruptedexception {Reload Reload = new Reload () ; while (true) {reload.load (); TimeUnit.SECONDS.sleep (2);}}
Package Org.main;public class Reload {public void load () {System.out.println ("load ...");}}
Run.bat:
java-javaagent:lib/springloaded-1.2.4.release.jar-noverify-dspringloaded=verbose;explain;watchjars= Main-0.0.1-snapshot.jar-jar Main-0.0.1-snapshot.jarpause
Run Run.bat
d:\springloaded\win>java-javaagent:lib/springloaded-1.2.4.release.jar-noverify-dspringloaded=verbose; Explain;watchjars=main-0.0.1-snapshot.jar-jar MAIN-0.0.1-SNAPSHOT.JARSL: [verbose mode on] all configuration is: VERBOSE;EXPLAIN;WATCHJARS=MAIN-0.0.1-SNAPSHOT.JARSL: [explain mode on] Reporting on the decision making process within Sp ringloaded2015-9-16 16:55:32 org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=org/main/app Classloader=launcher$appclassloader Typeregistry=typeregistry (id=1325628529 , Loader=sun.misc.launcher$appclassloader) ====remainingprefix=====jar:file:/d:/springloaded/win/ Main-0.0.1-snapshot.jar====jarname=====main-0.0.1-snapshot.jar2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor preprocess Info: [explanation] Based on the name, type org/main/ APP is considered to be reloadable2015-9-16 16:55:32 org.springsource.loaded.ReloadableType <init> Info: New Reloadable Type:org.main.aPP (allocatedid=0) typeregistry (id=1325628529,loader=sun.misc.launcher$appclassloader) 2015-9-16 16:55:32 Org.springsource.loaded.agent.Watcher AddFile Info: now watching d:\springloaded\win\main-0.0.1-SNAPSHOT.jar2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry getreloadabletype Info: >typeregistry.getreloadabletype ( typeregistryid=0,typeid=0) 2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry getreloadabletype Info: < Typeregistry.getreloadabletype (typeregistryid=0,typeid=0) returning org.main.app2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded preprocessing:classname=org/ Springsource/loaded/ssmgr Classloader=launcher$appclassloader Typeregistry=typeregistry (id=1325628529,loader= Sun.misc.launcher$appclassloader) 2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry couldbereloadable Info: Whynotreloadable? The type org/springsource/loaded/ssmgr is using a package name ' org/springsource/loaded/' which is considered infrastructUre and types within it is not made reloadable2015-9-16 16:55:32 org.springsource.loaded.agent.SpringLoadedPreProcessor Logpreprocess Info: springloaded preprocessing:classname=java/lang/interruptedexception classloader=null typeRegistry =null2015-9-16 16:55:32 org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=org/main/reload Classloader=launcher$appclassloader Typeregistry=typeregistry (id= 1325628529,loader=sun.misc.launcher$appclassloader) 2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor preprocess Info: [explanation] Based on the name, type org/main/ Reload is considered to bereloadable2015-9-16 16:55:32 org.springsource.loaded.ReloadableType <init> Info: New Reloadable type:org.main.Reload (allocatedid=1) typeregistry (id=1325628529,loader=sun.misc.launcher$ Appclassloader) 2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry getreloadabletype Info: > Typeregistry.getreloadabletype (Typeregistryid=0,typeid=1) 2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry getreloadabletype Info: < Typeregistry.getreloadabletype (typeregistryid=0,typeid=1) returning org.main.reload2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded preprocessing:classname=org/ Springsource/loaded/ismgr Classloader=launcher$appclassloader Typeregistry=typeregistry (id=1325628529,loader= Sun.misc.launcher$appclassloader) 2015-9-16 16:55:32 org.springsource.loaded.TypeRegistry couldbereloadable Info: Whynotreloadable? The type org/springsource/loaded/ismgr is using a package name ' org/springsource/loaded/' which is considered infrastructu Re and types within it is not made reloadableload ..... 2015-9-16 16:55:32 org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=java/util/concurrent/timeunit classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Information:springloaded preprocessing:classname=java/util/concurrent/timeunit$1 Classloader=null typeRegistry=null2015-9-16 16:55:32 org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded preprocessing: Classname=java/util/concurrent/timeunit$2 classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=java /util/concurrent/timeunit$3 classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=java /util/concurrent/timeunit$4 classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=java /util/concurrent/timeunit$5 classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded preprocessing:classname=java/util/concurrent/timeunit$6 classloader=null typeregistry=null2015-9-16 16:55:32 Org.springsource.loaded.agent.SpringLoadedPreProcessor logpreprocess Info: springloaded Preprocessing:classname=java /util/concurrent/timeunit$7 classloader=null typeregistry=nullload.....load.....load .....
Modify the class file in the jar to reload load .... Change to reload .... RePack and overwrite the current jar and observe the log:
2015-9-16 16:57:32 Org.springsource.loaded.agent.Watcher Run Info: Observed last modification time change for d:\ Springloaded\win\main-0.0.1-snapshot.jar (lastscantime=1442393851501) 2015-9-16 16:57:32 Org.springsource.loaded.agent.Watcher ... Omit Reload.....reload .....
Hot Update Complete!
Reference: http://www.blogjava.net/landon/archive/2015/07/01/425994.html
Spring-loaded implementing Hot updates