a jax-rs router plugin for play java apps
Scala Java
Switch branches/tags
Nothing to show
Latest commit 791af4b Jul 10, 2013 @pk11 bump version
Failed to load latest commit information.
conf turn project into a play plugin to avoid reloading issues in dev mode Jul 9, 2013
public initial version Mar 14, 2013
test initial version Mar 14, 2013
LICENSE.md initial version Mar 14, 2013
README.md bump version Jul 10, 2013


play-jaxrs is providing an alternative router for play 2.1.2 (and above) java apps by implementing (a subset of) the JAX-RS specification on top of play.


use this router instead of the built-in one if you are interested in a native java solution that also significantly improves build times. The price you will need to pay for this is lack of reverse routing and compile time routing checks.

play-jaxrs tradeoffs

  • using reflection for action dispatching instead of matching generated route rules

  • since there are no router files to compile and sbt can not invalidate big parts of the object graph, compile times are significantly better than using the standard solution

  • only supports java projects for two reasons:

    • annotations are primary used in java
    • scala users already have a very scala-centric routing solution
  • route definitions are provided inline. Some people prefer this over an external DSL, especially in a backend service-only context

  • reflection based dispatching means no reverse routing or compile time checks for route matching

  • since there is no route file, assets controller is configured via the config file

what's supported?


  • @ApplicationPath on your Global class can define a context (think servlet context)

  • @Path works both on classes and methods

  • URI parts can be captured (i.e. /user/id/{id})

  • the captured field can only be a String i.e.

    public static Result id(@PathParam("id") String id) {
  • @QueryParam captured as com.google.common.base.Optional i.e.
public static Result id(@PathParam("id") String id, @QueryParam("foo") Optional<String> foo) {
    return ok("id=" + id + " query=" + foo.or("booo"));
  • @Provides
  • @Consumes

plus all the standard play features should be working (i.e. action composition, dependency injection, assets serving etc.).


How to install

you can install play-jaxrs in three easy steps:

  1. delete conf/routes

  2. in project/Build.scala add

"org.pk11" %% "jax-rs" % "0.6"

to your project/Build.scala file's app dependencies section.

  1. also

resolvers += "pk11" at "http://pk11-scratch.googlecode.com/svn/trunk"

should be part of your settings

  1. edit conf/play.plugins 1500:org.pk11.jaxrs.RouterPlugin

  2. finally, set it up in your Global class:

   public play.api.mvc.Handler onRouteRequest(RequestHeader request) {
     return Play.application().plugin(org.pk11.jaxrs.RouterPlugin.class).handlerFor(this, request);

and that's it.

How to hack

after cloning and cd-ing into the main directory

run the spec

$ play test


$ play -Djaxrs=only publish-local


Published under The MIT License, see LICENSE