Maven Coordinates
To enable Jersey (JAX-RS) Support add the following dependency to your project’s pom.xml (see Managing Dependencies).
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver-jersey</artifactId>
</dependency>content_copy
JAX-RS Support
You can register a Jersey (JAX-RS) application at a context root using the JerseySupport class.
Registering a Jersey Application
To register a Jersey application at a context root, use the JerseySupport class and its JerseySupport.Builder builder.
JerseySupport can register the JAX-RS resources directly.
Jersey (JAX-RS)
HelloWorld resource@Path("/")
public class HelloWorld {
@GET
@Path("hello")
public Response hello() {
return Response.ok("Hello World!").build();
}
}content_copy
Registering the
HelloWorld resourceRouting.builder()
.register("/jersey",
JerseySupport.builder()
.register(HelloWorld.class)
.build())
.build();content_copy
- Register the Jersey application at
/jerseycontext root - The Jersey
Applicationstays hidden and consists of a singleHelloWorldresource class
As a result, an HTTP GET request to /jersey/hello would yield a Hello World! response string.
Registering a JAX-RS Application
You can also register the JAX-RS Application object.
Register the
HelloWorld resourceRouting.builder()
.register("/jersey",
JerseySupport.builder(new MyApplication())
.build())
.build();content_copy
- Register the Jersey application at
/jerseycontext root MyApplicationhandles requests made to /jersey context root.
Accessing WebServer Internals from a JAX-RS Application
You can inject WebServer request and response objects into your JAX-RS application using @Context.
Injection of WebServer internal objects
@Path("/")
@RequestScoped
public class HelloWorld {
@Context
private ServerRequest request;
@Context
private ServerResponse response;
}content_copy