Before enabling JRebel into your projects or workspaces, I would encourage you to download the JRebel plugins. That can be done here within the plugin section within IntelliJ. All you need to do is hit plugins and then search for JRebel. Since I already have it installed, you can see it there, but all you would do is you would hit here, click on that and you would hit install, and it will prompt you to restart your IDE with the JRebel plugin attached.
Configuring JRebel for Hybris
Now that we've installed the JRebel plugin into our IDE, in this case, we installed it into IntelliJ, we are now going to set up JRebel in a Hybris environment.
First thing you want to do is to open up the local.properties file inside of your platform home. Once we open up that file, what we're going to do is we're going to add a Tomcat Java options agent path argument.
What I'm doing here is opening up the JRebel configuration window and scrolling to standalone. Inside the standalone option, I am copying that agent path argument, and then I'm going to copy that and put that into my Tomcat Java options.
Once I have added these two agent path arguments, I'm then going to enable JRebel for every module within the Hybris project, so that I can use IntelliJ to build my application.
Using JRebel With the IDE Compiler
Now, I am going to walk through two separate ways that you can use JRebel. You can either use the IDE compiler to compile all your changes, or you can use an external build using your Ant build, and I will show both ways of doing it. So for in this case, what I'm first doing is I'm enabling JRebel for each project.
Now that I've successfully enabled JRebel for my entire Hybris workspace, I am now going to run an Ant all inside of the platform home. What this is going to do is it's going to build the entire workspace with those Rebel XMLs, and it will also update the local.properties file that I modified with the agent path argument.
Now that our Ant build has been successful, we are now going to start the Hybris project with the JRebel agent attached to the service. So as soon as you start it up, if you have properly attached the Hybris agent path argument to your environment, you will see this JRebel bander being displayed that you saw right there on the screen.
Now that the application has started up, we are then going to open up the Hybris webpage. We'll refresh that page, just so we're at that homepage of the application. Now, what we're going to do is we're just going to select one of the camera models. And what we're going to do is we're actually to update a properties file just to show that JRebel's working in our environment. And then we're going to modify the add cart to showing JRebel.
Now that we've made this change, I'm then going to save, and I'm going to then build this application. Because we enabled the project in IntelliJ, we are then going to save and compile the application so that we're updating the code. And we'll be able to see it at runtime using JRebel. This may take some time for your initial build, but after that, it should be much quicker. What we're able to see right away, we're able to see that that change has been reflected.
Using JRebel With Ant
The next way I want to show you how you can use JRebel, if you're unable to use the IntelliJ build or you're unable to use Eclipse compiler, what I'm then going to show is using just a typical Ant build. So in this case, what I'm going to do is I'm going to modify showing JRebel, but adding in with Ant build to the end of it.
Once I've made this change, I'm then going to save that file, then I'm going to go into my terminal window and I'm going to open up that platform home, and then I'm going to run an Ant build. I'm going to do this while the application is running. And what this is going to do is it's going to compile the workspace so that we're updating that code.
JRebel is going to monitor that build directory and see that a change has been made, and it's going to immediately reflect that in the running application. So that is the second way that you could actually use JRebel. And once that's complete, we'll be able to see that change reflected.
Now that the build has been completed, we're going to go back into the webpage. And as you can see, once we refresh the page, we're able to see that now it says, "Showing JRebel with Ant build." So this is two separate ways that you could use JRebel inside of a Hybris environment, and really see the benefits of your deployment process.
For more information on how to download, install, and configure JRebel for Hybris, be sure to visit our JRebel Hybris installation guide.
Learn more in our blog >> What Is SAP Hybris?
For additional reading on why JRebel can be such a big benefit to Hybris users, this whitepaper on how JRebel streamlines SAP Hybris development is worth a read.