Monday, September 29, 2014

Let's Talk JAX-RS.next!


Marek Potociar
JAX-RS specification lead
Oracle, Cloud Application Foundation
Also does Jersey

What to expect in JAX-RS in Java EE 8.

JAX-RS:
  • Improvement over servlets for web services.
  • Started 2008.
  • JAX-RS 2.0 released in Java EE 7

Next in Java EE 8:
  • Performance
  • Better integration in container
  • Hypermedia improvements

Server-sent events - standard http connect, server push stream async.
Ajax long polling - not standard but is technique. Manual reconnect.
Server-sent events - standard api and format. Html5 compliant. Seamless reconnect.
Websocket- new http protocol. Decouples request and response.

Server-sent events :
  • Streaming async. Events
  • Same infrastructure
  • Fits ajax and html5

Async http request / response cycle: Client connects, invokes resource, async response. On invoke, can respond, pass response stream info.

In Jersey new SseBroadcaster, constructs with and return EventOutput with info.
New Outboundevent (uses builder api)
Broadcaster.broadcast(event)

Client: EventSource javascript api, override onEvent receives event with data. Also have pull model.


Non-blocking I/O:
  • Servlet 3.1 leveraged.
  • Register callback in which you respond to data.
  • Must be backward compatible.

Reactive programming model:
  • Customer logs in and gets destination suggestions, weather, etc. Orchestrated.
  • Can be resource intensive. To solve, get cust details, async get concurrent destinations, weather, etc.
  • Hard to read and maintain, callback hell
  • Best is Reactive client composing dataflows. E.g Rxjava, java 8, guava.

Declarative security:
  • JAX-RS has no security. Planned for Java EE 8. Oauth 2 used a lot now.
  • Looking for decoupled declarative annotation based. @denyAll at controller level and @rolesAllowed on methods.

MVC integration:
  • Controversial. Different flavors in mvc
  • Separate spec.
  • Write mvc in view response. Spring mvc popular, action oriented with templates.
  • New framework will build on JAX-RS, probably facelets. @template(name=page.jsp) on resource method.

Jsonb binding
  • Object mapping.
  • Still jsr


Context Dependency Injection (CDI) alignment:
  • Java EE context and injection alignment.
  • Will take time, JAX-RS older than CDI.
  • Runs outside Java EE container.
  • Want to run on small devices.
  • CDIi making changes, eg modular, portable.

No comments:

Post a Comment