Skip to content

skapral/jersey-se

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jersey Standalone

Build Status (Travis) Build status (AppVeyor) Codecov

Compact self-sufficient JAX-RS distribution based on Grizzly and Jersey.

Quick start

  1. Add Maven dependency
<dependency>
    <groupId>com.github.skapral.jersey.se</groupId>
    <artifactId>jersey-se</artifactId>
    <version>x.y.z</version>
</dependency>
  1. Define JAX-RS resource config
public class SimpleConfig extends ResourceConfig {
    /**
     * Ctor.
     */
    public SimpleConfig() {
        super(
            StatusEndpoint.class
        );
    }
}

@Path("status")
public class StatusEndpoint {
    /**
     * @return returns "OK"
     */
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String status() {
        return "OK";
    }
}
  1. Define entry point.
public static void main(String... args) throws Exception {
    new SrvGrizzlyWithJersey(
        new Cp_PORT(),
        new SimpleConfig()
    ).start();
    System.in.read(); // Server instance uses daemon threads, so hold
    // main thread until you need the server online.
}
  1. Run the instance.