Annotation Type ServiceContextResource


  • @Documented
    @Retention(RUNTIME)
    @Target({METHOD,FIELD})
    public @interface ServiceContextResource
    Annotates a field or a setter method for injecting a service context into a service instance.

    It is guaranteed that context will be injected before calling the Service.init() method.

    Here is how injection would typically happen:

     public class MyServiceImpl implements MyService {
          ...
          @ServiceContextResource
          private ServiceContext ctx;
          ...
     }
     
    or attach the same annotation to the method:
     public class MyServiceImpl implements MyService {
         ...
         private ServiceContext ctx;
         ...
         @ServiceContextResource
         public void setServiceContext(ServiceContext ctx) {
              this.ctx = ctx;
         }
         ...
     }
     
    See Also:
    Service, ServiceContext