Java Magazine, Sept/Oct 2016
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2016 39 enterprise java JAX RS is the standard for developing RESTful HTTP web services in an enterprise application It ofers a productive yet powerful way of defining REST resources by annotating plain old Java objects POJOs that contain the business logic without needing to write the HTTP plumbing by hand Due to the fact that RESTful web services or HTTP services implementing some of the REST constraints are commonly used in enterprise projects and also because of its productive programming model the JAX RS standard is widely adopted among Java developers Java EE 7 comes with JAX RS 20 JSR 339 whereas Java EE 8 which is currently in progress will contain JAX RS 21 JSR 370 This article explains some of the new concepts and features the specifications update will deliver These include support for server sent events SSEs better integration with other Java EE specifications and integration of reactive programming functionality as well as non blocking I O on the client side To follow along you need some experience with JAX RS Note The specification and all the topics and examples this article covers are still subject to change This article then is a preliminary explanation of what very likely will be included in the next JAX RS version Server Sent Events SSEs are a new technology that is part of HTML5 SSEs automatically receive updates from a server via HTTP and they offer an easy to use one way streaming communication protocol that perfectly fits use cases that have broadcast updates for example social media updates stock prices or news feeds The server pushes UTF 8 text based data as content type text event stream to a client that previously connected to the streaming endpoint and therefore registered for the events The format of the events looks as follows data This is a message event namedmessage data This message has an event name id 10 data This message has an id which will be sent as last event ID if the client reconnects This approach of asynchronous events over an established connection competes with the more powerful WebSockets standard which supports bidirectional communication The main advantages of SSEs however are that they are compliant with HTTP technology because they use HTTP as the communication protocol which makes it easy to integrate them into existing networks or developer tools and they natively support event IDs and reconnects JAX RS 21 will support SSEs for both JAX RS resources and the clients The server side of SSEs The following code shows an SSEenabled JAX RS endpoint SEBASTIAN DASCHNER JAX RS next A First Glance A look at whats coming next in JAX RS 21
You must have JavaScript enabled to view digital editions.