@Retention(value=RUNTIME) @Target(value={TYPE,CONSTRUCTOR,METHOD,PARAMETER}) @Repeatable(value=Services.class) @Inherited public @interface Service
@Service annotation is to be used for test classes or methods annotated
with the @OSGi annotation. Note that tests using this annotation are
expected to be run within an OSGi environment. It is a repeatable annotation and can
be used to specify a number of different services using the service
type and an optional LDAP filter expression.
Collection or List of the service type for optional
and multiple references (0..n).
cardinality
attribute in order to require or not the presence of at least one service instance, thus
achieving cardinalities (0..1) and (1..n).
service type need not be specified, it can
be inferred from the parameter's type. However, it may still be useful to specify a filter expression.ServiceCardinality| Modifier and Type | Optional Element and Description |
|---|---|
ServiceCardinality |
cardinality
Whether or not injection fails in the absence of a suitable service.
|
String |
filter
An optional filter expression conforming to the LDAP filter syntax used in OSGi
Filters. |
Class<?> |
value
The type of the service to be injected.
|
public abstract Class<?> value
public abstract String filter
Filters.public abstract ServiceCardinality cardinality
ServiceCardinalityCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.