openxava / documentation / Modify XavaPro code

×News: OpenXava with AI - Refine the UI (Part 2) - December 1 · Read more
Enterprise and Corporate editions of XavaPro include the complete source code, so you can modify the XavaPro code to adapt it to your needs, fix a bug, add a new feature, etc.
XavaPro source code is included in XavaPro distribution, inside a folder called source-code:

You can modify, build and install it using Maven and your favorite IDE. If you're not used to Maven, we present here a detailed guide to modify XavaPro code for your application using OpenXava Studio.

Install a JDK 8

XavaPro is compiled with Java 8 in order to work with Java 8, 11, 17 and 21. You have to install Java 8 in your computer and configure OpenXava Studio to recognize it.
First, download JDK 8 and install it on your computer. Then in OpenXava Studio open Windows > Preferences > Java > Installed JREs. Once there add the JDK 8 to the list of JREs. In this way:
Note that it is not necessary to choose it as the default one.

Import xavapro into workspace

To import the xavapro project click on File > Import...:

Now select Maven > Existing Maven Projects and click on Next:


In Root Directory browse to choose the folder where the XavaPro code is, that is, xavapro-7.x.x/source-code:


Make sure that xavapro project is checked, then click on Finish.

Finally the xavapro project with all its code is in your workspace:

Now you can modify the xavapro code at your taste.

Modify XavaPro code

First, change the version in xavapro/pom.xml to be a SNAPSHOT. Open the pom.xml inside the xavapro project and add the -SNAPSHOT suffix to the version number:

It means that it is a working version, not with fixed features but ready to be modified.

Now, it's time to modify the code. For example, edit the ProSignInHelperProvider.java code and add a extra condition in the isAuthorized() method, like this:

Then make a mvn install on xavapro, in this way:

This time it's not needed to do a mvn clean because it's the first time and target is empty, but if you get the code of a new XavaPro version you should do a mvn clean too.

Now, go to your project, edit the pom.xml, look for the xavapro dependency, and replace ${openxava.version} with your own SNAPSHOT version (7.0.2-SNAPSHOT in our example). Do not change the value of the openxava.version property (unless you are also working with your own modified version of OpenXava):

This is important, otherwise your project will not use the xavapro you have modified, but the official version from your Maven repository.

Then do a mvn clean on your project:

And then a mvn install on your project:

Congratulations! Your project is ready to run with your modified XavaPro. Try it.

Shorten modification cycle

The above steps are for the very first modification. From now on, the next modifications can be easy, just three steps:

  1. Modify xavapro code.
  2. Do a mvn install on xavapro.
  3. Do a mvn war:exploded in your project. For this you can use Run As > Build Maven ...

Even more, you can start your application in debug mode, clicking on the bug:

In this way you can modify the code in xavapro and see the result instantly, even without relaunching your application or reloading the browser. Just like magic.

Hot code reloading (new in v7.5)

Starting with version 7.5, you can shorten the modification cycle even further thanks to hot code reloading, if you use the JDK included in OpenXava Studio 7 R4. However, for XavaPro code to also be reloaded, you need to make a small modification in your launcher class:

public static void main(String[] args) throws Exception {
    AppServer.run("yourapp", "../xavapro/target/classes"); 
}

Note how we add the path to the xavapro project classes as the second argument (If you also have the OpenXava code in your environment you could add a third argument with ../openxava/target/classes). In this example, we assume that xavapro and your project are in the same directory. This way, the modification cycle is reduced to almost nothing. You just need to modify the Java code in xavapro and use your application in the browser — you don't even need to reload to see the changes.

Hot code reloading does not include web resources (JSP, HTML, CSS, etc.). For that, you’ll need to copy the files (using your operating system) from xavapro/src/main/resources/META-INF/resources to yourapp/target/yourapp. This way, you'll see the changes just by refreshing the browser. Also, it won't clutter your project because everything in target is deleted when you run mvn clean.