jakartaee / rest

Jakarta RESTful Web Services
Other
368 stars 121 forks source link

Support for WebSockets using java.util.stream.Stream<T> result type and @WebSockets annotation #457

Open glassfishrobot opened 10 years ago

glassfishrobot commented 10 years ago

REST over HTTP is client driven and stateless, as is the JAX-RS 2.0 API.

While this serves rather well for most cases, more and more there is a demand for asynchronous updates to recently received information, particularly using WebSockets. In addition, at time of GA of JAX-RS 2.1, Java SE 8 will be the current platform, with Java EE 8 being the next ambrella spec for JAX-RS. Java SE 8 provides a standard interface for typed asynchronous information streams in the package java.util.stream.

As WebSockets are simply and compatibly extending HTTP by a natural way to bring asynchronous updates to an HTTP enabled client, Stream is the natural way to deliver the provided updates as Java objects to the receiving party. As a consequence, utilizing WebSockets is the first-class technology to implement asynchronous updates in a RESTful HTTP environment, and Stream is the optimal interface to consume these.

As a consequence, it just makes sense to support the following combination:

@WebSockets @GET public java.util.stream.Stream get() { // Asynchronously provide T instances on demand }

Affected Versions

[2.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 10 years ago

@glassfishrobot Commented Reported by mkarg

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JAX_RS_SPEC-452