Annotation Type Service


@Documented @Qualifier @Retention(RUNTIME) @Target({FIELD,METHOD,TYPE,TYPE_USE}) public @interface Service
Annotation used to specify that a bean should be published as a service.

The behavior of this annotation depends on it's usage:

  • on the bean type - publish the service using all implemented interfaces. If there are no implemented interfaces use the bean class.
  • on the bean's type_use(s) - publish the service using the collected interface(s).
Use of @Service on both type and type_use will result in a definition error.

Where this annotation is used affects how service scopes are supported:

  • @SingleComponent, @FactoryComponent or @Dependent bean - The provided service can be of any scope. The bean can either implement ServiceFactory or PrototypeServiceFactory or use @Bundle or @Prototype to set it's service scope. If none of those options are used the service is a singleton scope service.
  • @ApplicationScoped bean - The provided service is a singleton scope service unless the bean implements ServiceFactory or PrototypeServiceFactory. It cannot use @Bundle or @Prototype to set it's service scope. Use of those annotations in this case will result in a definition error.
Author:
$Id: acf4490d7b9207e098cda72e016f02de85df3f4d $
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Support inline instantiation of the Service annotation.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Override the interfaces under which this service is published.
  • Element Details

    • value

      Class<?>[] value
      Override the interfaces under which this service is published.
      Returns:
      the service types
      Default:
      {}