Welcome to the default
Application of the Aries JAX-RS Whiteboard
If you are seeing this page it means that you've successfully deployed the Aries JAX-RS Whiteboard!
If you want more information about JAX-RS you can find out more about it here.
What you should do now is deploy an JAX-RS resource as an OSGi service. Let's take a look at a couple of examples which will use OSGi Declarative Services specification as the means of creating the OSGi services.
The first example will simply add a resource (a.k.a. an endpoint).
import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@Component(
property = {
JaxRSWhiteboardConstants.JAX_RS_APPLICATION_SELECT + "=(osgi.jaxrs.name=.default)",
JaxRSWhiteboardConstants.JAX_RS_RESOURCE + "=true"
},
service = ExampleAddon.class
)
public class ExampleAddon {
@GET
@Path("/{name}")
public String sayHello(@PathParam("name") String name) {
return "Hello " + name;
}
}
The next example is an extension
which implements a javax.ws.rs.container.ContainerRequestFilter
.
import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
@Component(
property = {
JaxRSWhiteboardConstants.JAX_RS_APPLICATION_SELECT + "=(osgi.jaxrs.name=.default)",
JaxRSWhiteboardConstants.JAX_RS_EXTENSION + "=true"
}
)
@Provider
public class ExampleFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext)
throws IOException {
System.out.println("FILTERED!");
}
}