RESTful Webservices on Google App Engine

后端 未结 3 605
忘掉有多难
忘掉有多难 2021-01-01 05:21

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<

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 06:04

    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:

    
    jersey
    com.sun.jersey.spi.container.servlet.ServletContainer
    
    com.sun.jersey.config.property.packages
    ***package-with-your-classes***;org.codehaus.jackson.jaxrs
    
    1
    
    

    Configurator:

    @Provider
    public class JAXBContextResolver implements ContextResolver {
    private AnnoxAnnotationReader annotationReader;
    private JAXBContext context;
    private Class[] classTypes = new Class[] { .. all your classes .. };
    
    public JAXBContextResolver() {
    annotationReader = new AnnoxAnnotationReader();
    Map properties = new HashMap();
    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

提交回复
热议问题