开发者

How to inject a spring bean into Jersey InjectableProvider

I have just created an implementation of an InjectableProvider for Jersey, but I found to completeley setup the injectable I need support fr开发者_Go百科om a Spring factory bean. I'm looking for a way to inject that factory as a field into the provider class. I tried already using the @Component annotation, but tha failed with an IllegalState exception (No Scope registered for scope 'request'))

What is the proper way to handle that? Or is there a way to reteive the application context from Jerseys HTTPcontext?


This is way late, but I hate seeing questions unanswered.

typically, on your factory bean you should have:

@Component
public class FactoryBean(){}

and in your provider, you should use

public class Provider extends InjectableProvider<Context>{
      @InjectParam
      private FactoryBean factoryBean;
}

On first thought, you would think you should use @Autowired since it's Spring's "Component" - but since we're wiring it in a Jersey instantiated bean, Jersey's @InjectParam should be used.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜