April 24, 2015

JAX-RS Kryo Message Body providers are placed to Jersey incubator

I have good news, mine JAX-RS Kryo support has been moved to Jersey incubator.

You can just add dependency on the module and your application can produce and consume application/x-kryo entities:


<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-kryo</artifactId>
    <version>${jersey.version}</version>
</dependency>

Original GitHub repository has been updated to use Jersey module. And as a bonus I've added two ways how to try it.

This is true since Jersey 2.18. The version was not released yet in time of writing this blog post. So you need to use 2.18-SNAPSHOT version and add Maven snapshot repository to your project:


<repositories>
    <repository>
        <id>java.net.snapshot</id>
        <url>https://maven.java.net/content/repositories/snapshots/</url>
    </repository>
</repositories>

Grizzly it

Maven packaging of this demo application is war. But it is possible to run the application using Grizzly HTTP container:

mvn exec:java

You can enable FINEST logging using logging.properties:

mvn exec:java -Djava.util.logging.config.file=target/test-classes/logging.properties

Jetty it

Or you can run it as common webapp using Jetty container:

mvn jetty:run-war

Again, you can enable FINEST logging using logging.properties:

mvn jetty:run-war -Djava.util.logging.config.file=target/test-classes/logging.properties

Check it

GET method is available at URL http://localhost:8080/, check it using curl:


curl -v http://localhost:8080/

Response should look like:


> GET / HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 20
< Content-Type: application/x-kryo
< Server: Jetty(8.1.16.v20140903)
<
Salzbur�*Wolfgan�

Origin

The Jersey Kryo support started as a "friday project". Evolution of the Kryo support shows list of previous blog posts:
  1. JAX-RS Kryo support introduced
  2. Performance report of JAX-RS Kryo support