Package org.osgi.service.cdi.annotations
Annotation Interface 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Support inline instantiation of theService
annotation. -
Optional Element Summary
-
Element Details
-
value
Class<?>[] valueOverride the interfaces under which this service is published.- Returns:
- the service types
- Default:
- {}
-