Pustike Web

Pustike Web provides API for creating application using RESTful Web Services with a central servlet DispatcherServlet, having an API similar to JAX-RS. Applications developed using this library can be deployed in any Servlet container like other web frameworks.

The WebServletContextListener and a DispatcherServlet need to be declared and mapped according to the Servlet specification by using Java configuration or in web.xml. During servlet context initialization, the dependency injector should be configured using the ServletModule and other application specific modules. Application modules register resource controller classes annotated with @Path specifying relative path to the context. The DispatcherServlet delegates incoming client requests, by matching their request path pattern, to the respective controller class which does the actual processing.

Controller methods can retrieve data from the servlet request by declaring parameter annotations with respective keys. It also includes the JSON data reader/writer with java object mapping that supports option to use specified fields only, based on requested data context.

Following are some of its key features:

  • RESTful web services using a central servlet DispatcherServlet with an API similar to JAX-RS.
  • Provides resource class or method level annotation @Path to specify the relative path.
  • Specify the HTTP request type of a resource using: @GET, @PUT, @POST, @DELETE, @HEAD.
  • Specify the accepted request media type using @Consumes.
  • Specify the response media type with @Produces (used for content negotiation).
  • Annotation based method parameter to pull information out of the servlet request: @PathParam, @QueryParam, @BeanParam, @CookieParam, @FormParam, @HeaderParam, JsonParam. A default value can be specified using @DefaultValue which is used when the key is not found.
  • Integration with Pustike Inject during servlet context initialization.
  • Scopes: RequestScope and SessionScope are made available for binding resource classes when configuring the injector.
  • Static resource servlet to serve files or user defined static content.
  • Support for JSON - object mapping with option to output selected fields only, based on user defined context.
  • Requires Java 11 and it has dependencies to servlet-api and pustike-inject, json libraries.

Documentation:

  • User Guide is included in the project’s README.md file.
  • Latest API docs are accessible here.

Download:

The most recent release is v0.8.0 (2021-01-25), and it is available from Maven central repository.

Download the latest-jar or configure this dependency in Maven build:

<dependency>
    <groupId>io.github.pustike</groupId>
    <artifactId>pustike-web</artifactId>
    <version>0.8.0</version>
</dependency>

Or, download the latest JAR(~60kB) from Maven Central.

License: This library is published under the Apache License, Version 2.0