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,@FactoryComponentor@Dependentbean - The provided service can be of any scope. The bean can either implementServiceFactoryorPrototypeServiceFactoryor use@Bundleor@Prototypeto set it's service scope. If none of those options are used the service is a singleton scope service.@ApplicationScopedbean - The provided service is a singleton scope service unless the bean implementsServiceFactoryorPrototypeServiceFactory. It cannot use@Bundleor@Prototypeto set it's service scope. Use of those annotations in this case will result in a definition error.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSupport inline instantiation of theServiceannotation. -
Optional Element Summary
Optional Elements
-
Element Details
-
value
Class<?>[] valueOverride the interfaces under which this service is published.- Returns:
- the service types
- Default:
- {}
-