NOTE: This README it outdated!
JetRS is an implementation of the JAX-RS v2.0 Specification that runs in a Servlet Container. This project was inspired with the goal to create a better, simpler, easier to use, reliable, and debugable JAX-RS implementation using the CohesionFirst approach.
- Java 8 - The minimum required JDK version.
- Maven - The dependency management system.
- Servlet Container - A Servlet Container is needed to provide the HTTP service functionality. We recommend Jetty as the ideal starting point for any project.
-
Add the
org.jetrs:server
dependency to the POM.<dependency> <groupId>org.jetrs</groupId> <artifactId>server</artifactId> <version>2.1.0-alpha-3</version> </dependency>
-
Optionally, you can add the dependency for the
MessageBodyReader
andMessageBodyWriter
provider to integrate the JSONx RS module.<dependency> <groupId>org.jsonx</groupId> <artifactId>jaxrs</artifactId> <version>0.3.2</version> </dependency>
-
Create a
javax.ws.rs.core.Application
.@javax.ws.rs.ApplicationPath("/*") public class Application extends javax.ws.rs.core.Application { @Override public java.util.Set<Object> getSingletons() { java.util.Set<Object> singletons = new java.util.HashSet<Object>(); singletons.add(new org.jsonx.rs.JxObjectProvider()); // Optional Provider to parse and marshal JSON messages to Java beans. return singletons; } }
-
Extend
org.jetrs.server.DefaultRESTServlet
, pointing toApplication
.@WebServlet(initParams={@WebInitParam(name="javax.ws.rs.Application", value="Application")}) public class RESTServlet extends org.jetrs.server.DefaultRESTServlet { }
-
Deploy the servlet to a Servlet Container. For an easy embedded servlet container solution, see here for a solution based on Jetty. In the arguments to
new Server(8080, ...)
addRESTServlet.class
as such:new Server(8080, RESTServlet.class);
This will automatically add
RESTServlet
to the application.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE.txt file for details.