The WildFly application server comes with a patching mechanism which makes it very easy to upgrade existing modules of the server or add new ones.
E.g. Hibernate Validator provides patch files which let you upgrade WildFly 10.1 to the preview releases of Bean Validation 2.0.
But you also can use the patching mechanism to add your own custom libraries to WildFly, making them available to deployed applications.
Even if you only ever deploy a single application to one WildFly instance, this can be very useful,
as it results in a smaller size of your deployment unit (WAR etc.) and thus faster build and deployment times.
How are WildFly patches created, though?
Patch files are generally just ZIP files which contain the module(s) to be added or updated as well as some additional metadata.
So in theory you could create them by hand, but there’s the patch-gen tool which greatly simplifies this task.
In the following we’ll describe step by step how to create a WildFly patch using the patch-gen-maven-plugin.
As an example, we’ll produce a patch file that adds the Eclipse Collections library to a WildFly instance.
Data-centric libraries often need to access private state of classes provided by the library user.
An example is Hibernate ORM.
When the @Id annotation is given on a field of an entity, Hibernate will by default directly access fields - as opposed to calling property getters and setters - to read and write the entity’s state.
Usually, such fields are private.
Accessing them from outside code has never been a problem, though.
The Java reflection API allows to make private members accessible and access them subsequently from other classes.
With the advent of the module system in Java 9, rules for this will change a bit, though.
In the following we’ll explore the options authors of a library provided as a Java 9 module have to access private state of classes defined in other modules.
WildFly, as a compatible Java EE 7 implementation, comes with Bean Validation 1.1 and its reference implementation Hibernate Validator 5 out of the box.
In the following we’ll show you how easy it is to upgrade the server’s modules to the latest Bean Validation release, using a patch file provided by Hibernate Validator.