Piranha 20.1.2 released!

Piranha 20.1.2 has been released :)

In total 59 issues were done for this release, which mostly included work for Piranha Micro, but also includes improvements for Servlet compatibility among others. Note that Piranha is a work in progress and not yet ready for regular use, let alone production usage.

Piranha itself is an upcoming Jakarta EE and MicroProfile runtime, currently in its early stages of development. Piranha's main goal is to use Jakarta APIs as much as possible as a library, using a flat class loader, and no concept of deploying applications, in other words without being an application server.

Piranha Micro however builds on the core Piranha foundation to deliver something that comes closer to a server; it can run a single application in archive form, albeit it can't undeploy and redeploy (this is on purpose). Specifically for embedded use it features an isolated class loader. Contrary to a traditional application server where an isolating class loader is used to run multiple applications in separation from each other, its purpose in Piranha is to isolate the archive from the application and all its classes and config files that embeds Piranha.

The jar files with Jakarta EE APIs and their implementations (for example the Jakarta Faces API and the Mojarra implementation) are handled in a somewhat unique way in Piranha Micro. The native method it internally uses is to load these via Maven, as demonstrated by the following snippet of internal code:

// Resolve all the dependencies that make up a Piranha runtime configuration

ConfigurableMavenResolverSystem mavenResolver = Maven.configureResolver();

configuration.getRepositoriesList().stream().forEach(repoUrl ->
    mavenResolver.withRemoteRepo(createRepo(repoUrl)));

JavaArchive[] piranhaArchives = 
    mavenResolver
         .workOffline(configuration.isOffline())
         .resolve(configuration.getMergedDependencies())
         .withTransitivity()
         .as(JavaArchive.class);

// Make all those dependencies available to the Piranha class loader
ClassLoader piranhaClassLoader = getPiranhaClassLoader(piranhaArchives);
This means Piranha Micro is very flexible where it loads its own jars from. They can come from Maven central, an alternative remote repo, a local repo on the filesystem, the local .m2, etc. In Piranha 20.1.2 just a single Uber-jar is downloaded this way, but we'll refine this in the coming versions.

A related feature of Piranha is that jars loaded this way do not need to be stored and/or extracted on the filesystem first, but are loaded in-memory and directly passed to the custom class loader. Piranha Micro uses ShrinkWrap archives for this, which has the additional advantages that when archives are created programmatically for embedded usage, Piranha Micro can run these directly.

Due to the early stage of development, Piranha Micro is currently only readily available via its Maven Arquillian connector. It can be seen in action in the Java EE 7 Samples project. For instance by cloning the project and typing the following:

cd jaspic
mvn clean install -Ppiranha-embedded-micro

Arjan Tijms

Comments

Popular posts from this blog

Jakarta EE Survey 2022

Implementing container authentication in Java EE with JASPIC

Counting the rows returned from a JPA query