java - How can I mix Guice and Jersey injection? -


i've seen the following question on how inject @context dependencies jersey resource constructors. question different -- i'd inject @pathparam string. have class resembling following:

@path("foo/{fooid}/bar") public class barresource {   @inject   public barresource(@pathparam("fooid") string foo, service service) {     ...   }   ... } 

the service injected fine guice, path segment null. surprises me; if assumed guice loudly explode complaining unresolvable dependency.

how can inject path parameter in manner? prefer avoid field injection purposes of keeping these resource classes unit-testable.

it appears @pathparam not acceptable default constructor argument. new feature document states

the arguments allowed in resource class constructor depends on resource provider used create instance of resource class [...]. default per-request resource classes can use combination of parameters annotated uriparam, uriparam, queryparam, matrixparam, headerparam or httpcontext.

you provide own resource provider processes @pathparam annotation.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -