Thorntail

Thorntail packages the Java EE applications with the required server runtime to java-jar your application. This consists of the application code, a basic of the WildFly application server, and any essential dependencies. The java-jar can be used to run the application. It's also MicroProfile compatible.

It's well integrated with the most-used frameworks, such as Camel, Netflix OSS, Keycloak, Logstash, and Swagger. Thanks to its flexible and pluggable DNA, it lets you create your own Java EE runtime packaged as an executable JAR file (often called an Uber JAR or fat JAR), which fits the microservices approach very well. Each fat JAR is essentially a microservice that can then independently upgrade, replace, or scale. As single responsibility principle is followed by each fat JAR, only the required dependencies will be packaged for it.

Thorntail is fully compliant with the Eclipse MicroProfile specification by providing support for the following features:

  • MicroProfile
  • MicroProfile JWT RBAC Auth
  • MicroProfile Metrics
  • MicroProfile Rest Client
  • MicroProfile Config
  • MicroProfile Fault Tolerance
  • MicroProfile Health

Creating a microservice with Thorntail is very simple; just add the following settings in your Maven project file (that is, pom.xml):

<properties>   
    <version.thorntail>2.0.0.Final</version.thorntail>   
  <maven.compiler.source>1.8</maven.compiler.source>   
    <maven.compiler.target>1.8</maven.compiler.target>   
    <failOnMissingWebXml>false</failOnMissingWebXml>   
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   
</properties>   
   
<dependencyManagement>   
  <dependencies>   
   <dependency>   
   <groupId>io.thorntail</groupId>   
   <artifactId>bom-all</artifactId>   
   <version>${version.thorntail}</version>   
   <scope>import</scope>   
   <type>pom</type>   
   </dependency>   
  </dependencies>   
</dependencyManagement>   
   
<dependency>   
   <groupid>io.thorntail</groupId>   
   <artifactId>jaxrs</artifactId>   
   <version>${version.thorntail}</version>   
</dependency>   
   
<plugin>   
    <groupid>io.thorntail</groupId>   
  <artifactId>thorntail-maven-plugin</artifactId>   
  <version>${version.thorntail}</version>   
  <executions>   
   <execution>   
   <goals>   
         <goal>package</goal>   
   </goals>   
   </execution>   
  </executions>   
</plugin>   

The HelloWorldEndpoint example application is as follows:

package com.example.demo.rest; 
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
@Path("/hello")
public class HelloWorldEndpoint { @GET @Produces("text/plain") public Response doGet() { return Response.ok("Hello from Thorntail!").build(); } }

The code snippet for RestApplication is as follows:

package com.example.demo.rest; 
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/")
publicclass RestApplication extends Application {
}

Furthermore, Thorntail's website offers a bootstrap page (https://thorntail.io/generator/), where you can specify the needs for your microservice by filling in the form with all of the dependencies you need, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset