Hi everyone,

I've been doing some work with JAX-RS, scoping out options for a
functional services API framework on Nakamura. It looks pretty
promising so far. Using JAX-RS with Jackson, we can get the following
benefits:

1. Ability to turn OSGi components into HTTP service endpoints, with
no extra code (ok, add annotations) or servlet dependencies

One thing we've struggled with is the amount of business logic wrapped
up into sling servlets. This makes it difficult to re-use that logic
by making service-to-service calls, and also makes it difficult to
test. JAX-RS allows us to unpack the request-scope information and
feed it into our services by parameter injection, without having to
write servlets for each service, or let servlet dependencies leak into
our business logic.

2. Automatic mapping of JSON to and for domain objects

A JAX-RS Jackson provider allows us our service methods to produce and
consume POJOs (or Peas) without having to manually generate JSON as we
currently do so often. A JAXB-compatability mapper also allows to have
more control over the JSON representation of the domain classes. This
is basically OOTB functionality for most JAX-RS implementations.

3. Documenting our APIs

There are some nice tools available that will combine information
provided by JAX-RS annotations with Javadocs to relieve much of the
plumbing involved in keeping our web service docs up to date. I
managed to extend jax-doclet to generate the following artifacts from
a mvn javadoc:aggregate : Javadoc, JAXB docs, JAX-RS docs. The cool
thing about having both JAXB and JAX-RS docs, is that the JSON schema
of domain objects that are consumed and returned are now exposed to
the web service users. Hopefully, the end result is that developers
focus on writing awesome javadocs, and the rest of the documentation
feeds from that.

There are 2 documents on oae-community with links to source code,
demos and more information about the implementations for both Apache
Wink [1] and JBoss RESTeasy [2] . For a sample of what gets generated
with the JAX-RS and JAXB docs, I've uploaded a sample package, which
demonstrates both jaxrs javadocs [3] and how they link to the jaxbdocs
[4].

Any questions, feedback or concerns are appreciated, and encouraged!

[1] https://oae-community.sakaiproject.org/content#p=lnE4vaa2mg/Apache
Wink REST Services Prototype
[2] https://oae-community.sakaiproject.org/content#p=l7e7uo9eie/JBoss
RESTeasy Services Prototype
[3] http://www.mrvisser.ca/jaxrs/jax-doclet/jaxrsdocs/overview-index.html
[4] 
http://www.mrvisser.ca/jaxrs/jax-doclet/jaxbdocs/org/sakaiproject/nakamura/samples/doclet/api/Album.html

-- 
Cheers,
Branden
_______________________________________________
oae-dev mailing list
[email protected]
http://collab.sakaiproject.org/mailman/listinfo/oae-dev

Reply via email to