Hotswap code changes and save more than 40% of development time, JDK 11
Standard Java Hotswap is limited to in-body code changes, But DCEVM + Hotswap agent allows you to Hotswap addition, removal and modification of following changes for Java classes.
- class fields,
- anonymous classes
- static members
What it will not support:
- Addition or removal of Annotation change the super class or interface. XML changes
Benefits of DCEVM in Hybris.
- Building the code, starting the server takes average 12 to 20 mins, depending on no of extensions you have and speed of the system.
- DCEVM saves all these build and deployment timing from these many minutes to seconds, if you have changes only in java files.
- And when you are able to test your changes within a seconds, there is fair chance that you can spend good amount of time in unit testing, that means a less bugs and better code quality.
For any XMl changes and New classes:
- In case if you have to do changes in XML files and there is need to create a new class etc, then
- I suggest whenever you start your day for the work, create a design your solution identify all your new classes that needs to be created , create them with some empty body or minimal code and define them in the XML, then do the normal build and deployment.
- Once you have all the required classes loaded, then you any modify them any number of times without do Hotswap without actually deployment them with normal process.
- download DCEVM JDK
- DCEVM Opend JDK 11 from: https://github.com/TravaOpenJDK/trava-jdk-11-dcevm/releases
- Setup DCEVM JDK as JAVA_HOME and make sure you update the path too.
add below property in local.properties
tomcat.debugjavaoptions=-XX:HotswapAgent=core -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=*:5500,suspend=n
Start hybris in debug mode “hybriserver.bat debug” “./hybriserver.sh debug“
- Do Remote debug from Intellij Idea or Eclipse with properties.
5. Debug should be on, then do some code changes.
6. Compile only that class , within seconds it will do that job
7. Now this class gets recompiled and the changes gets loaded in the server, and when you refresh the home page you should be able to see message from new method getMessage3() created newly in the console.
- To setup DCEVM, you just need to download DCEVM JDK and set it as your JAVA_HOME
- Add additional property in your local.properties
- Start the server in Debug mode
- Start Remote debug in your faveraout IDE
- Recompile the modified classes to get them reloaded in the server to save the time of building and restarting the hybris server. Thats it.
Points to be Noted :
- Setup is for JDK 11,
- Tested for Hybris 2105, But should work any version which is based JDK 11.
- We have to use DCEVM Open JDK instead of Standard JDK 11.
- Eclipse or Intellij Idea.
- For Setup for JDK 8 , you can refer
- you can try “ant build” command instead of recompiling from IDE
Thanks for your time, Comments and suggestions are welcome, If any one using docker, we can do this from docker too, I will share those details next time.