Easiest frameworks to implement Java REST web services [closed]
Asked Answered
G

10

29

What are the best frameworks for implementing both client and server REST frameworks in Java? I've been struggling a little to find an easy to use solution.

Update: Both Jersey and Restlet seem like good options. We'll probably use Restlet but we'll experiment with both.

Glomma answered 30/9, 2009 at 2:14 Comment(1)
meta.stackexchange.com/questions/71068/…Delija
G
20

Restlet sounds like it should provide what you're looking for:

  • Support for client and server (in a relatively symmetric api)
  • Smart url binding
  • mime type understanding (given accepted mime types, it will ask your resources for their representation in that type)
  • Supports JAX-RS annotations (just like Jersey)
Gravante answered 30/9, 2009 at 2:22 Comment(1)
+1 I've had excellent results with Restlet in a large production application.Enlighten
B
24

Jersey is really easy for both. To write web services, you use annotations:

@Path("/helloworld")
public class HelloWorldResource {

    // The Java method will process HTTP GET requests
    @GET
    // The Java method will produce content identified by the MIME Media
    // type "text/plain"
    @Produces("text/plain")
    public String helloWorld() {
        // Return some cliched textual content
        return "Hello World";
    }
}

For a client:

Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/helloworld");
String s = webResource.get(String.class);
System.out.println(s); // prints Hello World
Bloch answered 30/9, 2009 at 3:58 Comment(1)
+1 for Jersey, the JAX-RS (JSR 311) Reference Implementation. Also have a look at java.sun.com/javaone/2009/articles/gen_restful.jspHey
G
20

Restlet sounds like it should provide what you're looking for:

  • Support for client and server (in a relatively symmetric api)
  • Smart url binding
  • mime type understanding (given accepted mime types, it will ask your resources for their representation in that type)
  • Supports JAX-RS annotations (just like Jersey)
Gravante answered 30/9, 2009 at 2:22 Comment(1)
+1 I've had excellent results with Restlet in a large production application.Enlighten
W
6

Take a look at dropwizard too.

Wakayama answered 11/7, 2012 at 7:28 Comment(0)
P
3

Restlet also support annotations in its 2.0 version, both on the client and server-side. The JAX-RS API is also supported as an extension.

Here is a simple example for server-side:

public class HelloWorldResource extends ServerResource {

    @Get
    public String represent() {
        return "hello, world";
    }

}

On the client-side:

// Outputting the content of a Web page  
new ClientResource("http://www.restlet.org").get().write(System.out);

For further documentation, check this page.

People answered 30/9, 2009 at 8:4 Comment(2)
Restlet looks promising, but the documentation is disappointing.Chilton
The "Restlet in Action" book will be published by Manning in September 2012. It has a comprehensive coverage. Next, we will improve the tutorial and Javadocs (versions 2.2 and 3.0)People
N
2

There's JBoss' new RESTEasy library. It appears to be under rapid development since its initial launch. I've no idea if it's any good; it's on my 'check it out' list.

Nether answered 30/9, 2009 at 12:20 Comment(0)
F
1

I haven't used it personally but some teams that I work with are using Spring 3 MVC. REST in Spring 3: @MVC looks like a good blog post overview. The RESTful features include "URI Templates", "Content Negotiation", "HTTP Method Conversion", "ETag support" and more.

Edit: Also, see this question: Can anyone recommend a Java web framework that is based on MVC and supports REST ?

Flaherty answered 30/9, 2009 at 12:37 Comment(0)
W
1

You could take a look at the CXF JAX-RS implementation. For complete list of its features check the CXF web site for JAX-RS. The community behind the project seems to be very active (July 2013). An indication of that is the number of messages per day in the CXF mailing lists.

Wheels answered 23/2, 2012 at 14:42 Comment(0)
M
0

I can recommend Apache wink, a new framework still in incubation mode, but very mature and high quality.

http://incubator.apache.org/wink/

It implements the JAX-RS specification, it has both client & server framework for REST development. Apache is standing behind this project - that's always a good sign (and a good license :-) )

What I love most about this framework is the intuitive integration with Spring, it's very useful if you want your framework to be easily configured and extended.

Matrimony answered 8/2, 2010 at 17:50 Comment(1)
BTW, Restlet is also distributed under Apache Public License, in addition with other licensing options (EPL, LGPL 2.1 and 3.0, CDDL) :)People
S
0

UPDATE: Xydra Restless is not longer maintained +++ If your are using Goolge AppEngine before they release a "reserve instance" feature, you might consider Xydra Restless which has few features but loads fast.

Starshaped answered 18/10, 2010 at 16:45 Comment(0)
A
-1

My favourite is Spring MVC, you have support for both, client and server side... And you have Android support too =)

For example, you can see a example of Spring Android here

Airing answered 23/2, 2012 at 14:59 Comment(1)
The Android link is to Javier's own blog, that seems not online anymore.Gothic

© 2022 - 2024 — McMap. All rights reserved.