简体   繁体   English

依赖注入注释RESTful服务

[英]Dependency injection annotations RESTful service

I have a classic DAO and Service layer. 我有一个经典的DAO和服务层。 For both I have interfaces. 对于两个我都有接口。 Service layer is annoteted with @WebService , then I also have layer for RESTful crud methods. 服务层以@WebService ,然后我还拥有RESTful原始方法的层。 I want to use Dependency injection for DAO and Services. 我想对DAO和服务使用依赖注入。 I don't know which annotations should use to inject Service into RESTful service. 我不知道应该使用哪些批注将Service注入RESTful服务。

Here is snippet: 这是代码段:

 @Path("/items")
  public class ItemsResource{

      @Context
      UriInfo uriInfo;
      @Context
      Request request;

          //annotations....
      private IService itemService;

       public ItemsResource(IService itemService){
       this.itemService=itemService;
        }
            //methods...

So my question is how would I inject itemService into my RESTful service? 所以我的问题是如何将itemService注入我的RESTful服务中? Which annotation should I use? 我应该使用哪个注释? I' don't use Spring Framework. 我不使用Spring Framework。

Did you try it with @Inject of JSR330 ? 您是否使用JSR330的 @Inject尝试了它?

Some of the frameworks that you may want to check (other than spring): 您可能要检查的一些框架(春季除外):

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM