简体   繁体   中英

Dependency injection annotations RESTful service

I have a classic DAO and Service layer. For both I have interfaces. Service layer is annoteted with @WebService , then I also have layer for RESTful crud methods. I want to use Dependency injection for DAO and Services. I don't know which annotations should use to inject Service into RESTful service.

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? Which annotation should I use? I' don't use Spring Framework.

Did you try it with @Inject of JSR330 ?

Some of the frameworks that you may want to check (other than spring):

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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