Google App Engine上的RESTful Web服务 [英] RESTful Webservices on Google App Engine

查看:102
本文介绍了Google App Engine上的RESTful Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我需要说的是,我在Google App Engine方面的经验不足。

我知道我们有可能部署RESTful GAE上的Web服务(JERSEY)



另外我知道 RESTLET 有专门针对GAE的版本。

>

我想从采用这两种方法的人那里得到建议,哪一个更好。例如,配置
$ b

GAERS申请JERSEY太困难或挣扎?
或者例如使用RESTLET有什么缺点?或者它太厚了(RESTLET)?



谢谢 一年前我开始开发一款与泽西岛和谷歌App Engine的应用程序。来自我身边的丰富经验,但我从来没有与Restlet合作过。



我在这里总结我在GAE集成中遇到的主要困难:




  • 泽西岛版本:1.6 works

  • 我建议您使用Jackson(版本1.7.1) >


web.xml片段:

 <的; servlet> 
< servlet-name>球衣< / 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-class ***; org.codehaus.jackson.jaxrs< / param-value>
< / init-param>
<加载启动> 1< /加载启动>
< / servlet>

配置器:

  @Provider 
public class JAXBContextResolver implements ContextResolver< JAXBContext> {
私人AnnoxAnnotationReader annotationReader;
私有JAXBContext上下文;
private Class<?> [] classTypes = new Class [] {.. all your classes ..};

public JAXBContextResolver(){
annotationReader = new AnnoxAnnotationReader();
地图< String,Object> properties = new HashMap< String,Object>();
properties.put(JAXBRIContext.ANNOTATION_READER,annotationReader);
尝试{
this.context = JAXBContext.newInstance(classTypes,properties);
} catch(JAXBException e){
..
}
public JAXBContext getContext(Class<?> objectType){
return context;

..你可以看到我使用Annox来避免模型类中的注释!



希望它有帮助!
Michele Orsi


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

解决方案

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

这篇关于Google App Engine上的RESTful Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆