JerseyLibModulePublicReview

Request to Make JSR-311/Jersey Library Module Public

The websvc.restlib library module is currently a non-public module that allows NB end-users to create and run RESTful web services using JSR 311 - Java API for RESTful Web Services. It currently contains JAR files for JSR 311 API, Jersey (JSR 311 RI) runtime and API, Grizzly web server and other components Jersey depends on internally. We would like to make the packages for JSR 311 API, Jersey API/SPI and Grizzly web server public. The reason for this is that it opens the possibility for NB developers to create modules that can create embedded Jersey runtime and Grizzly web server to expose RESTful interfaces for the IDE. For example, a developer can create a project opener module that starts an embedded Jersey runtime and Grizzly web server. Users can then send HTTP requests using file-based URLs to the IDE to open projects. (Note: This idea comes from Paul Sandoz, paul.sandoz@sun.com, author of Jersey.) There are also the possibilities of using Jersey to turn NB into a web-based IDE that exposes a RESTful interface.

Here is an example:


import com.sun.grizzly.http.SelectorThread;
import com.sun.grizzly.tcp.Adapter;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.container.ContainerFactory;
import com.sun.jersey.api.container.grizzly.GrizzlyServerFactory;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

public class RestResourceContainer {

    @Path("/")
    public static class Resource {

        @Context
        UriInfo ui;

        @GET
        public String get() {
            return ui.getAbsolutePath().toASCIIString();
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void launch() throws Exception {
        Set<Class<?>> resourceClasses = new HashSet<Class<?>>();
        resourceClasses.add(Resource.class);
        SelectorThread st = GrizzlyServerFactory.create("http://localhost:9999/",
                ContainerFactory.createContainer(Adapter.class, resourceClasses));
        
        try {
            Client c = Client.create();
            WebResource r = c.resource("http://localhost:9999/");
            String s = r.get(String.class);
            System.out.println(s);
        } catch (UniformInterfaceException e) {
            System.out.println(e.getResponse().getStatus());
            e.printStackTrace();
        } finally {
            st.stopEndpoint();
        }
    // TODO code application logic here
    }
}


The following is the list of packages (as shown in the project.xml) we are requesting to make public:

javax.ws.rs
javax.ws.rs.core
javax.ws.rs.ext
com.sun.jersey.api
com.sun.jersey.api.client
com.sun.jersey.api.client.config
com.sun.jersey.api.container
com.sun.jersey.api.container.grizzly
com.sun.jersey.api.container.httpserver
com.sun.jersey.api.core
com.sun.jersey.api.json
com.sun.jersey.api.model
com.sun.jersey.api.representation
com.sun.jersey.api.uri
com.sun.jersey.api.view
com.sun.jersey.api.wadl
com.sun.jersey.spi
com.sun.jersey.spi.container
com.sun.jersey.spi.container.servlet
com.sun.jersey.spi.dispatch
com.sun.jersey.spi.inject
com.sun.jersey.spi.resource
com.sun.jersey.spi.service
com.sun.jersey.spi.template
com.sun.jersey.spi.uri.rules
com.sun.grizzly
com.sun.grizzly.arp
com.sun.grizzly.async
com.sun.grizzly.connectioncache.client
com.sun.grizzly.connectioncache.server
com.sun.grizzly.connectioncache.spi.concurrent
com.sun.grizzly.connectioncache.spi.transport
com.sun.grizzly.filter
com.sun.grizzly.http
com.sun.grizzly.http.algorithms
com.sun.grizzly.http.portunif
com.sun.grizzly.http.servlet
com.sun.grizzly.ssl
com.sun.grizzly.standalone
com.sun.grizzly.standalone.servlet
com.sun.grizzly.suspendable
com.sun.grizzly.tcp
com.sun.grizzly.tcp.http11
com.sun.grizzly.tcp.http11.filters
com.sun.grizzly.util.buf
com.sun.grizzly.util.collections
com.sun.grizzly.util.http
com.sun.grizzly.util.http.mapper
com.sun.grizzly.util.net
com.sun.grizzly.util.net.jsse

Note that we are currently bundling the 0.8 version of JSR 311 API and Jersey and version 1.7.3.2 of the grizzly web server.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo