Java Reference
In-Depth Information
@GET
@ZipResult
@Path("getListOfAllStudentsGzip")
public List<Student> getListOfAllStudentsGzip()
{
TypedQuery<Student> query =
em.createQuery("SELECT s FROM Student s",
Student.class);
return query.getResultList();
}
The following code is an example of the declaration of @ZipResult annotation:
@NameBinding
@Target({ ElementType.TYPE, ElementType.METHOD
})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface ZipResult {}
The following code shows the implementation of the ReaderInterceptor inter-
face (on the client side) that will decompress the data compressed by the server with
the MyGzipWriterJaxRsInterceptor class:.
public class MyGzipReaderJaxRsInterceptor
implements ReaderInterceptor {
@Override
public Object
aroundReadFrom(ReaderInterceptorContext
context) throws IOException {
try (InputStream inputStream =
context.getInputStream();) {
context.setInputStream(new
GZIPInputStream(inputStream));
return
context.proceed();
}
Search WWH ::




Custom Search