Search code examples
web-servicesgoogle-app-enginejerseyrestlet

RESTful Webservices on Google App Engine


First of all I need to say that I'm not so experienced in Google App Engine.

I know that it is possible that we deploy RESTful Web-services (JERSEY) on GAE

And also I know that RESTLET has a version specifically for GAE.

I want to take advice from those who have worked with both approaches that which one is better.

For example is configuring the GAE application for JERSEY too difficult or struggling??? Or for example has using RESTLET any disadvantages? Or is it too thick (RESTLET)?

Thanks


Solution

  • I started one year ago to develop an app with Jersey and Google App Engine. Great experience from my side, but I have never worked with Restlet ..

    I try here to summarize the main difficulties I found in GAE integration:

    • Jersey version: 1.6 works
    • I suggest you to use Jackson (version 1.7.1) for json representation

    web.xml fragment:

    <servlet>
    <servlet-name>jersey</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>***package-with-your-classes***;org.codehaus.jackson.jaxrs</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    

    Configurator:

    @Provider
    public class JAXBContextResolver implements ContextResolver<JAXBContext> {
    private AnnoxAnnotationReader annotationReader;
    private JAXBContext context;
    private Class<?>[] classTypes = new Class[] { .. all your classes .. };
    
    public JAXBContextResolver() {
    annotationReader = new AnnoxAnnotationReader();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(JAXBRIContext.ANNOTATION_READER, annotationReader);      
    try {
        this.context = JAXBContext.newInstance(classTypes, properties);
    } catch (JAXBException e) {
        ..  
    }
    public JAXBContext getContext(Class<?> objectType) {
        return context;
    }
    

    .. as you can see I use Annox to avoid annotations inside my model classes!

    Hope it helps! Michele Orsi