JKFramework Service

JK-Framework Service helps to start developing microservice in Java in no time, with zero-config.

Dependency

Most likely, you will NOT need to add the direct dependency of this project, since its already included in the parent projects or the other framework projects. However, if you need to, the dependency is

<!-- https://mvnrepository.com/artifact/com.jalalkiswani/jk-framework-core -->
<dependency>
    <groupId>com.jalalkiswani</groupId>
    <artifactId>jk-framework-service</artifactId>
    <version>7.0.0-M6</version>
</dependency>

Basic Usage

  1. Create Maven Project with JK-App-Service as the Parent.

  2. Your REST controllers should extends JKAbstractRestController, for example:

package com.app.person;

import com.jk.services.server.JKAbstractRestController;

import jakarta.ws.rs.*;

@Path("/example")
public class Controller extends JKAbstractRestController{

	@GET
	@Path("hello")
	public String sayHello() {
		return "Hello from uncle Jalal";
	}

	@GET
	@Path("/hello/{name}")
	public String sayHelloWithPathParam(@PathParam(value = "name") String name) {
		return "Hello, " + name;
	}

	@POST
	@Path("/hello")
	//The Model class should contains name and age instance variables with setters and getters
	public String sayHelloWithBody(Model p) {
		return "Hello, " + p.getName() + ", your age is: " + p.getAge();
	}
}
  1. Create an App class that should contain @ApplicationPath("app") annotation, and extends JKServiceConfig, for example:

package com.app;

import com.jk.services.server.JKServiceConfig;
import com.jk.web.embedded.JKWebApplication;

import jakarta.ws.rs.ApplicationPath;

@ApplicationPath("app")
public class App extends JKServiceConfig{

	/**
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		JKWebApplication.run(8080,false);
	}

}

Benefits

Using JKFramework-Service, you will get many benefits, following are some of them:

  • All dependencies and configurations needed to develop Jakarta EE 10 microservices using Java.

  • Context synchronization filters

  • Default Exception Handler that publish exceptions to the confgired Unified Logging Service.

  • Tuned proper configurations to Jersey and JSON handlers.

  • Set of utility services such as

    • Info Service: available at /util/info url, which shows all the current available controllers and endpoints details.

    • Config Service: available at /util/config url, which allows reloading config and the retrieval of (password masked) configrations .

    • HeaderS ervice: available at /util/headers url, which allows to show clients header sent to server, usefull for debugging purposes.

    • Log Service: available at /util/log url, which show [password masked] server logs.

    • Ping Service: available at /util/ping url.

    • Hi Service: available at /util/hi url.

All critical endpoints are disabled by default, check the Configurations section for more information.

Also, be sure to set jk.service.allowed.ip property in your configuration which is a while-list of the IP addresses that are allowed to access these utility services.

Configurations

For the list of available confiurations of Service project, check Configuration Section