tags:

views:

1631

answers:

6
+7  Q: 

REST in Java

I'm looking for a light version of REST for a Java web application I'm developing.

I've looked at RESTlet (www.restlet.org) and the REST plugin for Struts 2, but I haven't made up my mind. I'm leaning towards RESTlet, as it seems to be lighter.

Has anyone implemented a RESTful layer without any of the the frameworks or with the frameworks?

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? (Some complexity is understandable, but what I mean is just plain overkilling your design just to add REST)

+1  A: 

Well, I've used Enunciate quite a bit. It uses simple annotations to provide either REST and/or SOAP endpoints.

http://enunciate.codehaus.org

Plus, Ryan Heaton has always provided top-notch support for things, too.

Dustin
+1  A: 

I am working on a REST API for gliffy.com and we ended up rolling our own. We didn't want to have to bring in Struts 2, Spring, or any other framework. I looked at RESTLet and found it incredibly confusing and over complicated.

Apache has an implementation of the JAX-RS spec, but it is not finalized and also has some oddities to it. 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).

davetron5000
+1  A: 

I found restlet to be a really elegant architecture. 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. I have found the conversion of our WCF contract-based SOA application to REST based one has significantly simplified the application,

Darrel Miller
+3  A: 

You know there is a new JCP API for Accessing RESTful Services, also:

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

The open source version is called Project Jersey

eckes
Jersey[1] is an implementation of JSR-311. It's available for download by itself or as part of Glassfish[3], Sun's Open Source application server. Restlet[4]'s upcoming 2.0 release also implements JSR-311. [1] https://jersey.dev.java.net/ [2] http://jsr311.dev.java.net/ [3] http://glassfish.dev.java.net/ [4] http://restlet.org/
Avi Flax
+9  A: 

I'm a huge fan of JAX-RS - I think they've done a great job with that specification. 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. There's no complex APIs to learn; just the core REST concepts (URIs, headers/response codes and content negotiation) are required. FWIW JAX-RS is quite Rails-ish from the controller point of view

There are a number of JAX-RS implementations out there - see this thread for a discussion.

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); though if you are using JBoss/SEAM you might find RESTeasy integrates a little better.

James Strachan
+6  A: 

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. It sounds like you're looking to add a RESTful API to an existing application. If that's the case, JAX-RS's (or Enunciate's) annotation-based approach might be a better fit for your project.

As for Restlet, I can tell you that I've been very impressed with the developers and the community; 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; therefore there is no impedance-mismatch between a Restlet app's external API and internal implementation. 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.

Avi Flax