Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

What is New in JAX-RS 2.1

Reactive Client API

JAX-RS 2.1 introduces RxInvoker which can help with removing InvocationCallbacks from the asynchronous client code. 

CompletionStage

Default CompletionStageRxInvoker can be accessed via Invocation.rx().

RxJava Observable

Custom RxInvokerProvider can be registered with the Client as a provider. CXF ships one such provider, org.apache.cxf.jaxrs.rx.client.ObservableRxInvokerProvider.

Registering it with the Client allows for working with RxJava Observable by doing Invocation.rx(Class<T> clazz), more specifically,

Invocation.rx(org.apache.cxf.jaxrs.rx.client.ObservableRxInvoker.class).

Please see JAX-RS RxJava for more information.

CompletableFuture as a method return value

Please see In JAX-RS 2.1 one can return CompletableFuture (or CompletionStage) from a resource method without having to deal directly with JAX-RS AsyncResponse API. 

Please see JAX-RS RxJava for more RxJava for more information about returning RxJava Observable.

Server Sent Events

JAX-RS 2.1 provides a comprehensive support for SSE.

org.apache.cxf/cxf-rt-rs-sse/3.2.0 dependency will need to be added. CXF SSE implementation current depends on Atmosphere.

SubResources as Classes

Sometimes subresource may need to have the request context information available to them. One valid and simple approach is to pass these contexts to them from the parent class which instantiates a subresource - but sometimes this approach does not work.

In JAX-RS 2.0 one can use ResourceContext to instantiate a subresource instance with the runtime taking care of injecting the contexts if needed. JAX-RS 2.1 introduces a shortcut where returning a subresource class from a subresource locator method, with the runtime istantiating the class and injecting the contexts if needed

CXF NIO Extension

Please see JAX-RS NIO for more information about this CXF 3.2.0 extension which is based on the early JAX-RS 2.1 API prototype.

...