Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Vestige: Java Application Manager

DZone's Guide to

Vestige: Java Application Manager

Check out Vestige, a framework that works with JDKs 6-10 and makes it easier to bring dynamic updating to your Java projects. See how it works and how to get started.

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Vestige is a framework that installs, runs, and updates Java SE applications. The idea is to bring portability to Java server applications (POP, CARDDAV, RESTful ...).

You may say that Java is already portable, and it is, but the glue that links the OS-specific to the JVM is not. What is needed for a Java server application includes:

  • Portable installation (creating rpm, DEB, EXE, DMG are tedious).

  • Automatic start with computer/user session.

  • A directory shared with the user (configuration, log) and one only for the application (cache, TMP).

  • A working internet configuration (to download application updates, access web services) even with a PAC proxy configured.

Vestige brings all that. Like other frameworks, it uses the Maven resolver (previously known as Eclipse Aether) to download and execute applications from your .m2/repository folder. Unlike existing frameworks, Vestige can hack dependencies to replace or add or remove any dependency. Also, it lets you choose between one classloader (the classpath mode) and one classloader per JAR (the platform mode). The platform mode allows for faster classloading (because it searches in only one JAR) and class sharing between applications.

Vestige runs on JVM 6 to 10. When starting on JVM 9 or above, it uses JPMS (previously known as Jigsaw) and creates one module layer per classloader to keep class sharing between applications enabled.

I ported some applications to Vestige:

  • Tomcat, a web server.

  • Felix, one OSGi implementation

  • H2, a database

Running Tomcat or Felix in Vestige is not really useful though, because the part that changes most often is the functional part, and the functional part is located in a WAR in the webapp folder for Tomcat and some bundle in OSGi — so no class sharing for functional parts.

However, if we could publish a WAR without its lib directory in a Maven repository, Tomcat could evolve and use the Vestige Maven SPI to share classes between the web app and with other applications running on the Vestige JVM.

Vestige was dedicated to Java SE applications and tries to limit the constraints necessary to port an application. An application doesn't need to depend on any Vestige dependency, you just have to create a Callable:

package fr.gaellalire.vestige.helloworld;

public class HelloWorld implements Callable<Void> {

    public HelloWorld(final File base, final File data) {
    }

    public Void call() throws Exception {
        try {
            synchronized (this) {
                wait();
            }
        } catch (InterruptedException e) {
            // exit
        }
        return null;
    }

}


And an XML:

<application xmlns="http://gaellalire.fr/vestige/APPLICATION" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://gaellalire.fr/vestige/APPLICATION http://gaellalire.fr/vestige/application-1.0.0.xsd" javaSpecificationVersion="1.6">
  <launcher class="fr.gaellalire.vestige.helloworld.HelloWorld">
    <mavenResolver groupId="fr.gaellalire.vestige.helloworld" artifactId="helloworld" version="1.0.0-SNAPSHOT" />
  </launcher>
  <configurations>
    <permissions>
      <permission type="java.security.AllPermission" />
    </permissions>
  </configurations>
</application>


Porting to OSGi or JPMS is a tedious task: You have to manage your import/export packages/modules. Porting to Vestige is much simpler. You just have to remove all JVM-wide operations (System.exit, System.setProperty and shutdown hooks). If you do not remove them, the application will run, but it may interfere with other application behavior.

If you want to run in platform mode and share your classes between applications, you will have to make all static variables immutable (final is not enough) and use the thread context class loader to perform IOC.

Vestige provides an SPI to both static (application stopped) and dynamic (application running) updates. Dynamic updating is terribly hard to achieve (blocking operations should be banned), but it's possible. See demo1 version 1.1.0 and 2.0.0 in http://gaellalire.fr/vestige/demo1-src.zip

There is a terribly slow wiki here to get more information.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:
java 10 ,java 6 ,java ,modularity ,maven ,vestige ,java framework

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}