Package org.osgi.service.cdi.annotations
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).
@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 implementServiceFactory
orPrototypeServiceFactory
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 implementsServiceFactory
orPrototypeServiceFactory
. 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 $
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>[]
value
Override the interfaces under which this service is published.
-