Annotation Type Scope


  • @Target({TYPE,METHOD})
    @Retention(RUNTIME)
    @Documented
    @UseWith({SERVICE,MODULE})
    public @interface Scope
    An optional annotation that may be placed on a service building method of a module, or on the implementation class (when using service binding). The annotation overrides the default scope for services (the default being a global singleton that is instantiated on demand) for an alternate lifecycle. Alternate lifecycles are typically used to bind a service implementation to a single thread or request. Modules may define new scopes. Each scope should have a corresponding ServiceLifecycle implementation. The linkage from scope name to service lifecycle occurs via a contribution to the ServiceLifecycleSource service configuration. The annotation may also be placed directly on a service implementation class, when using service binding (via the ServiceBinder).
    See Also:
    ScopeConstants.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value
      An identifier used to look up a non-default ServiceLifecycle.