jersey - Dropwizard: dropwizard-guicey sub-resource locators -
i'm migrating application jersey2/hk2 dropwizard. i'm using dropwizard-guicey integrate guice application while maintaining of hk2 bindings/features.
dropwizard-guicey binds resources in singleton scope default, leaves me wondering -- suggested way bind sub-resources in situation? in jersey, can simple
@path("{pathparamid}/sub-resource") public class<mysubresource> mysubresource() { return mysubresource.class; }
but subresource class looks this
public class mysubresource { private string id; public mysubresource(@pathparam("pathparamid") id) { this.id = id; } }
it doesn't seem dropwizard able pick on dependencies guice binds in mysubresource, since resources managed jersey.
what i'm looking per-request bindings jersey gives default resources , guice injection beneath level.
in example, root resource managed guice (installed resource installer) , sub resource created hk (per request).
to use guice services in sub resource need enable hk guice bridge:
- add
org.glassfish.hk2:guice-bridge:2.5.0-b32
dependency - enable bridge option
.option(guiceyoptions.usehkbridge, true)
.
i add complete demo samples repo. shows how case implemented pure guice.
Comments
Post a Comment