Thursday, October 18, 2007

RESTing happily in Jersey

I've been working with Jersey over the last couple of months and I like what I'm seeing so far. Jersey is a REST/Web-based services framework for Java, based on the draft JSR 311 standard, nicknamed JAX-RS.

I've compared it to the other alternatives on the Java side for HTTP-based services, in particular Apache CXF, and here are the main highlights for me:
  • It's a lightweight framework that doesn't invade parts of your application where it doesn't belong. That is, it's used only in the external interface layer of classes called directly from the servlet. I really don't like frameworks that invade parts of your application where they don't belong, and I tend to stay away from these. Jersey however is well behaved and stays within its boundaries.

  • ConsumeMime and ProduceMime method annotations that also support routing of requests in addition to the URITemplates. This makes you think more about using proper media types rather than just making all your return types application/xml.

  • Hooks for Atom representation of your resources, using libraries such as ROME. Although some of my esteemed colleagues at ThoughtWorks disagree with me, I think ATOM is extremely useful when developing RESTful services, especially with its support of custom content types. No more custom collection types, and there's already a protocol for manipulating your collections.

  • WADL support, including automated generation of a WADL document describing your resources. I'm not convinced that WADL is a good idea as it seems to lead to tighter coupling of clients to resources. It also violates the REST principle of hypermedia as the engine of application state. However, it can be very useful when your architect demands an interface document for your service ;-)

  • Serialisation of JAXB objects out of the box. In other words, the classes exposing the external interface can return JAXB objects and Jersey turns them into XML or JSON (BadgerFish convention) on the wire. Yes, I know, CXF has this too.

  • It was designed as a HTTP/REST library from the beginning. This is really the biggest reason for me. The framework helps you make your service more RESTful—you don't feel like you're wrestling with the framework to make it do what you want. CXF is certainly my SOAP library of choice on the Java side (at the moment anyway) and the developers have done a very good job of adding support for Web-based services both within the confines of JAX-WS and using a non-standard API. However, the RPC-orientation of JAX-WS (which originates from WSDL) inevitably leaks in, such as the wrapped vs. unwrapped mode. Wrapping a "document" with an operation name is certainly not RESTful!

    CXF's effort is in many ways similar to what Microsoft has done with the HTTP support in WCF. I can certainly appreciate the fact that time-to-market is lower when building on top of an existing comprehensive framework, but when the abstractions of the existing framework differ fundamentally from those of the new one, the developer experience is inevitably affected.
Ok, there are some parts I don't like as much:
  • No out-of-the-box Spring integration. Spring is the IoC container of choice of much of the Java world at the moment, and any framework that integrates with it, like CXF, has a clear advantage.

  • Hard-coded dependencies mean customisation is hard. I can't easily inject my own classes to achieve the functionality I want. Also, quite a few classes are final for no apparent reason.
One of my colleagues, Gianny Damour, pointed me to CXF's effort to support JAX-RS, currently in one of their branches. This could be very interesting!

3 comments:

06zmyu4dhb said...

Slavna Studio holds offices in three international locations, and most of its work is geared towards of|in direction of} building playing video games. In phrases of slots, it supports 4 sorts (Mechanical, Video, 2D/3D, AWP), and promises to handle the total cycle of improvement for every project. Mobilots is a small studio that focuses on slots (video & arcade), but also develops video-poker and immediate sports titles. The studio creates these video games on demand, but also 1xbet boasts about its easy API integration built into all of their video games.

qwux0h8ldr said...

Only when enjoying in} the full five cash are the highest payouts accessible. Video Poker is so referred to as end result of|as a end result of} the player plays towards a machine which displays the player's playing cards on a display screen. The player places a stake and is dealt five playing cards from a normal 52-card pack. The player has one opportunity to discard any number of undesirable playing cards, and is dealt an equal number of 블랙잭 replacement playing cards from the deck. If the player then has a sufficiently good poker hand, the vendor than pays the player according to a fixed and fast|a set} scale of odds according to sort of|the sort of} hand. "Sufficiently good" often means a pair of Jacks or higher - if the player's final hand is worse than this, the stake is misplaced to the vendor.

bicm4c8q06 said...

Residents of North Korea, sadly, inhabit what is usually described as one of the most repressed nations on earth. This primarily signifies that the vast majority of the inhabitants wouldn't have the luxurious of even contemplating enjoying in} playing online or offline. This is to the extent the place a tablet was launched to the nation’s people in 2014, named the Ullim. 온라인카지노 This device was found to be filled with invasive software program and hardware that monitors the consumer and may even save browser historical past and take screen-shots of opened apps by itself. This by itself must be sufficient to dissuade most from even contemplating accessing websites that are not authorities accredited. The online on line casino giant Paddy Power did have a quick cameo in the planned meetups of North Korean chief Kim Jong-un and former basketball player Dennis Rodman back in 2014.