简体   繁体   English

适用于Java的轻量级REST库

[英]Lightweight REST library for Java

I'm looking for a light version of REST for a Java web application I'm developing. 我正在为我正在开发的Java Web应用程序寻找一个轻量级的REST。

I've looked at RESTlet (www.restlet.org) and the REST plugin for Struts 2, but I haven't made up my mind. 我看过RESTlet(www.restlet.org)和Struts 2的REST插件,但我还没有下定决心。 I'm leaning towards RESTlet, as it seems to be lighter. 我倾向于RESTlet,因为它看起来更轻。

Has anyone implemented a RESTful layer without any of the the frameworks or with the frameworks? 有没有人实现RESTful层没有任何框架或框架?

Any performance issues that you've seen because of the new web layer? 您是否因为新的网络层而遇到任何性能问题?

Did the introduction of REST added unmanageable or unreasonable complexity to your project? REST的引入是否为您的项目增加了难以管理或不合理的复杂性? (Some complexity is understandable, but what I mean is just plain overkilling your design just to add REST) (有些复杂性是可以理解的,但我的意思是仅仅为了添加REST而过分夸大你的设计)

I'm a huge fan of JAX-RS - I think they've done a great job with that specification. 我是JAX-RS的忠实粉丝 - 我认为他们在该规范方面做得很好。 I use it on a number of projects and its been a joy to work with. 我在许多项目中使用它,并且很高兴与之合作。

JAX-RS lets you create REST resources using POJOs with simple annotations dealing with the URI mappings, HTTP methods and content negotiation all integrated nicely with dependency injection. JAX-RS允许您使用POJO创建REST资源,其中简单的注释处理URI映射,HTTP方法和内容协商,所有这些都与依赖注入很好地集成。 There's no complex APIs to learn; 没有复杂的API需要学习; just the core REST concepts (URIs, headers/response codes and content negotiation) are required. 只需要核心REST概念(URI,标题/响应代码和内容协商)。 FWIW JAX-RS is quite Rails-ish from the controller point of view 从控制器的角度来看,FWIW JAX-RS非常Rails-ish

There are a number of JAX-RS implementations out there - see this thread for a discussion . 有很多JAX-RS实现 - 请参阅此主题进行讨论

My personal recommendation is to use Jersey as its got the biggest, most active community behind it, has the best features at the time of writing (WADL support, implicit views, spring integration, nice REST client API); 我个人的建议是使用Jersey作为其拥有的最大,最活跃的社区,在撰写本文时具有最佳功能(WADL支持,隐式视图,Spring集成,漂亮的REST客户端API); though if you are using JBoss/SEAM you might find RESTeasy integrates a little better. 虽然如果您使用JBoss / SEAM,您可能会发现RESTeasy集成更好一些。

I'm a big fan of Restlet, but I usually use it to implement apps whose primary role is to be a RESTful web service. 我的Restlet的忠实粉丝,但我通常用它来实现应用程序,其主要作用是成为一个RESTful Web服务。 It sounds like you're looking to add a RESTful API to an existing application. 听起来您正在寻找将RESTful API添加到现有应用程序。 If that's the case, JAX-RS's (or Enunciate's) annotation-based approach might be a better fit for your project. 如果是这种情况,JAX-RS(或Enunciate)基于注释的方法可能更适合您的项目。

As for Restlet, I can tell you that I've been very impressed with the developers and the community; 至于Restlet,我可以告诉你,我对开发人员和社区印象非常深刻; they're very active, engaged, responsive, and committed to a stable, efficient, reliable, and effective framework. 他们非常积极,参与,反应迅速,致力于建立一个稳定,高效,可靠和有效的框架。 My single favorite aspect of the framework is that it is a ground-up implementation of the REST paradigm; 我最喜欢的框架是它是REST范式的基础实现; therefore there is no impedance-mismatch between a Restlet app's external API and internal implementation. 因此,Restlet应用程序的外部API与内部实现之间不存在阻抗不匹配。 I also really like how flexible it is - it can run inside a Java application container/server such as JBoss, Tomcat, Jetty, etc, or standalone, with an embedded HTTP server library. 我也非常喜欢它的灵活性 - 它可以在Java应用程序容器/服务器(如JBoss,Tomcat,Jetty等)内运行,也可以独立运行,具有嵌入式HTTP服务器库。

Well, I've used Enunciate quite a bit. 好吧,我已经使用了相当多的Enunciate。 It uses simple annotations to provide either REST and/or SOAP endpoints. 它使用简单的注释来提供REST和/或SOAP端点。

http://enunciate.codehaus.org http://enunciate.codehaus.org

Plus, Ryan Heaton has always provided top-notch support for things, too. 此外,Ryan Heaton也一直为事物提供一流的支持。

You know there is a new JCP API for Accessing RESTful Services, also: 您知道有一个用于访问RESTful服务的新JCP API,还有:

JAX-RS JCP311 https://jsr311.dev.java.net/ JAX-RS JCP311 https://jsr311.dev.java.net/

The open source version is called Project Jersey 开源版本称为Project Jersey

I am working on a REST API for gliffy.com and we ended up rolling our own. 我正在为gliffy.com开发一个REST API,最后我们自己动手了。 We didn't want to have to bring in Struts 2, Spring, or any other framework. 我们不想引入Struts 2,Spring或任何其他框架。 I looked at RESTLet and found it incredibly confusing and over complicated. 我看着RESTLet,发现它令人难以置信的混乱和复杂。

Apache has an implementation of the JAX-RS spec, but it is not finalized and also has some oddities to it. Apache有一个JAX-RS规范的实现,但它没有最终确定,也有一些奇怪之处。 We're tentatively planning to open source our solution, but that's not for a few months. 我们暂时计划开源我们的解决方案,但这不是几个月。

Rolling your own is easy, though. 不过,滚动你自己很容易。 The Servlet Specification gives you everything you need, and you can easily connect to a database via Hibernate (see http://www.naildrivin5.com/daveblog5000/?p=39 for how to set up JPA without using EJB3). Servlet规范为您提供了所需的一切,您可以通过Hibernate轻松连接到数据库(有关如何在不使用EJB3的情况下设置JPA,请参阅http://www.naildrivin5.com/daveblog5000/?p=39 )。

I found restlet to be a really elegant architecture. 我发现restlet是一个非常优雅的建筑。 I'm working in the .net world so it was not an option for me, but I was able to build my own framework following the same basic principles of restlet. 我在.net世界工作,所以它不适合我,但我能够按照相同的restlet基本原则构建自己的框架。 I have found the conversion of our WCF contract-based SOA application to REST based one has significantly simplified the application, 我发现将基于WCF合同的SOA应用程序转换为基于REST的应用程序已经大大简化了应用程序,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM