@ConsumerType public class OsgiContextImpl extends Object
Modifier and Type | Field and Description |
---|---|
protected org.osgi.service.component.ComponentContext |
componentContext |
Constructor and Description |
---|
OsgiContextImpl() |
Modifier and Type | Method and Description |
---|---|
@NotNull org.osgi.framework.BundleContext |
bundleContext() |
@NotNull org.osgi.service.component.ComponentContext |
componentContext() |
<ServiceType> |
getService(@NotNull Class<ServiceType> serviceType)
Lookup a single service
|
<ServiceType> |
getServices(@NotNull Class<ServiceType> serviceType,
@Nullable String filter)
Lookup one or several services
|
<T> T |
registerInjectActivateService(T service)
Injects dependencies, activates and registers a service in the mocked
OSGi environment.
|
<T> T |
registerInjectActivateService(T service,
@Nullable Map<String,Object> properties)
Injects dependencies, activates and registers a service in the mocked
OSGi environment.
|
<T> T |
registerInjectActivateService(T service,
Object... properties)
Injects dependencies, activates and registers a service in the mocked
OSGi environment.
|
<T> T |
registerService(@Nullable Class<T> serviceClass,
T service)
Registers a service in the mocked OSGi environment.
|
<T> T |
registerService(@Nullable Class<T> serviceClass,
T service,
@Nullable Map<String,Object> properties)
Registers a service in the mocked OSGi environment.
|
<T> T |
registerService(@Nullable Class<T> serviceClass,
T service,
Object... properties)
Registers a service in the mocked OSGi environment.
|
<T> T |
registerService(T service)
Registers a service in the mocked OSGi environment.
|
protected void |
setUp()
Setup actions before test method execution
|
protected void |
tearDown()
Teardown actions after test method execution
|
protected org.osgi.service.component.ComponentContext componentContext
protected void setUp()
protected void tearDown()
@NotNull public final @NotNull org.osgi.service.component.ComponentContext componentContext()
@NotNull public final @NotNull org.osgi.framework.BundleContext bundleContext()
@NotNull public final <T> T registerService(@NotNull T service)
T
- Service typeservice
- Service instance@NotNull public final <T> T registerService(@Nullable @Nullable Class<T> serviceClass, @NotNull T service)
T
- Service typeserviceClass
- Service classservice
- Service instance@NotNull public final <T> T registerService(@Nullable @Nullable Class<T> serviceClass, @NotNull T service, @Nullable @Nullable Map<String,Object> properties)
T
- Service typeserviceClass
- Service classservice
- Service instanceproperties
- Service properties (optional)@NotNull public final <T> T registerService(@Nullable @Nullable Class<T> serviceClass, @NotNull T service, @NotNull Object... properties)
T
- Service typeserviceClass
- Service classservice
- Service instanceproperties
- Service properties (optional)@NotNull public final <T> T registerInjectActivateService(@NotNull T service)
T
- Service typeservice
- Service instance@NotNull public final <T> T registerInjectActivateService(@NotNull T service, @Nullable @Nullable Map<String,Object> properties)
T
- Service typeservice
- Service instanceproperties
- Service properties (optional)@NotNull public final <T> T registerInjectActivateService(@NotNull T service, @NotNull Object... properties)
T
- Service typeservice
- Service instanceproperties
- Service properties (optional)@Nullable public final <ServiceType> ServiceType getService(@NotNull @NotNull Class<ServiceType> serviceType)
ServiceType
- Service typeserviceType
- The type (interface) of the service.@NotNull public final <ServiceType> ServiceType[] getServices(@NotNull @NotNull Class<ServiceType> serviceType, @Nullable @Nullable String filter)
ServiceType
- Service typeserviceType
- The type (interface) of the service.filter
- An optional filter (LDAP-like, see OSGi spec)RuntimeException
- If the filter
string is not a valid OSGi service filter string.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.