public class ServiceManagerImpl extends Object implements ServiceManager
Modifier and Type | Field and Description |
---|---|
static long |
FEATURES_AND_BUNDLES_TIMEOUT |
static long |
HTTP_ENDPOINT_TIMEOUT |
static long |
MANAGED_SERVICE_TIMEOUT |
Constructor and Description |
---|
ServiceManagerImpl(org.osgi.service.metatype.MetaTypeService metatype,
AdminConfig adminConfig) |
Modifier and Type | Method and Description |
---|---|
org.osgi.service.cm.Configuration |
createManagedService(String factoryPid,
Map<String,Object> properties)
Creates a Managed Service that is created from a Managed Service Factory.
|
org.osgi.framework.BundleContext |
getBundleContext() |
Map<String,Object> |
getMetatypeDefaults(String symbolicName,
String factoryPid) |
<S> S |
getService(Class<S> aClass) |
<S> S |
getService(org.osgi.framework.ServiceReference<S> serviceReference) |
<S> org.osgi.framework.ServiceReference<S> |
getServiceReference(Class<S> aClass) |
<S> Collection<org.osgi.framework.ServiceReference<S>> |
getServiceReferences(Class<S> aClass,
String s) |
void |
printInactiveBundles() |
void |
printInactiveBundlesInfo() |
void |
restartBundles(String... bundleSymbolicNames)
Restarts one or more bundles.
|
void |
startBundle(String bundleSymbolicName) |
void |
startFeature(boolean wait,
String... featureNames)
Installs and starts one or more features.
|
void |
startManagedService(String servicePid,
Map<String,Object> properties)
Starts a Managed Service.
|
void |
stopBundle(String bundleSymbolicName) |
void |
stopFeature(boolean wait,
String... featureNames)
Stops and uninstalls one or more features.
|
void |
stopManagedService(String servicePid)
Stops a managed service.
|
void |
waitForAllBundles() |
void |
waitForBundleUninstall(String... bundleSymbolicNames)
Waits for one or more bundle to be uninstalled.
|
void |
waitForFeature(String featureName,
Predicate<org.apache.karaf.features.FeatureState> predicate) |
void |
waitForHttpEndpoint(String path) |
void |
waitForRequiredApps(String... appNames) |
void |
waitForRequiredBundles(String symbolicNamePrefix) |
void |
waitForSourcesToBeAvailable(String restPath,
String... sources) |
public static final long MANAGED_SERVICE_TIMEOUT
public static final long FEATURES_AND_BUNDLES_TIMEOUT
public static final long HTTP_ENDPOINT_TIMEOUT
public ServiceManagerImpl(org.osgi.service.metatype.MetaTypeService metatype, AdminConfig adminConfig)
public org.osgi.framework.BundleContext getBundleContext()
getBundleContext
in interface ServiceManager
public org.osgi.service.cm.Configuration createManagedService(String factoryPid, Map<String,Object> properties) throws IOException
ServiceManager
For Managed Services not created from a Managed Service Factory, use ServiceManager.startManagedService(String, Map)
instead.
createManagedService
in interface ServiceManager
factoryPid
- the factory pid of the Managed Service Factoryproperties
- the service properties for the Managed ServiceIOException
- if access to persistent storage failspublic void startManagedService(String servicePid, Map<String,Object> properties) throws IOException
ServiceManager
For Managed Services created from a Managed Service Factory, use ServiceManager.createManagedService(String, Map)
instead.
startManagedService
in interface ServiceManager
servicePid
- persistent identifier of the Managed Service to startproperties
- service configuration propertiesIOException
- thrown if if access to persistent storage failspublic void stopManagedService(String servicePid) throws IOException
ServiceManager
stopManagedService
in interface ServiceManager
servicePid
- persistent identifier of the Managed Service to stopIOException
- thrown if if access to persistent storage failspublic void startFeature(boolean wait, String... featureNames) throws Exception
ServiceManager
startFeature
in interface ServiceManager
wait
- if true
, this method will wait until the state of all the features is
Started
and all bundles are Active
before returningfeatureNames
- names of the features to install and startException
- thrown if one of the features fails to be installed or startedpublic void stopFeature(boolean wait, String... featureNames) throws Exception
ServiceManager
stopFeature
in interface ServiceManager
wait
- if true
, this method will wait until the state of all the features is
Uninstalled
and all bundles are Active
before returningfeatureNames
- names of the features to install and startException
- thrown if one of the features fails to be installed or startedpublic void restartBundles(String... bundleSymbolicNames) throws org.osgi.framework.BundleException
ServiceManager
restartBundles
in interface ServiceManager
bundleSymbolicNames
- list of bundle symbolic names to restartorg.osgi.framework.BundleException
- if one of the bundles fails to stop or startpublic void stopBundle(String bundleSymbolicName) throws org.osgi.framework.BundleException
stopBundle
in interface ServiceManager
org.osgi.framework.BundleException
public void startBundle(String bundleSymbolicName) throws org.osgi.framework.BundleException
startBundle
in interface ServiceManager
org.osgi.framework.BundleException
public void waitForRequiredApps(String... appNames) throws InterruptedException
waitForRequiredApps
in interface ServiceManager
InterruptedException
public void waitForAllBundles() throws InterruptedException
waitForAllBundles
in interface ServiceManager
InterruptedException
public void waitForRequiredBundles(String symbolicNamePrefix) throws InterruptedException
waitForRequiredBundles
in interface ServiceManager
InterruptedException
public void waitForBundleUninstall(String... bundleSymbolicNames)
ServiceManager
waitForBundleUninstall
in interface ServiceManager
bundleSymbolicNames
- symbolic names of the bundles to wait forpublic void waitForFeature(String featureName, Predicate<org.apache.karaf.features.FeatureState> predicate) throws Exception
waitForFeature
in interface ServiceManager
Exception
public void waitForHttpEndpoint(String path) throws InterruptedException
waitForHttpEndpoint
in interface ServiceManager
InterruptedException
public void waitForSourcesToBeAvailable(String restPath, String... sources) throws InterruptedException
waitForSourcesToBeAvailable
in interface ServiceManager
InterruptedException
public Map<String,Object> getMetatypeDefaults(String symbolicName, String factoryPid)
getMetatypeDefaults
in interface ServiceManager
public void printInactiveBundles()
printInactiveBundles
in interface ServiceManager
public void printInactiveBundlesInfo()
printInactiveBundlesInfo
in interface ServiceManager
public <S> org.osgi.framework.ServiceReference<S> getServiceReference(Class<S> aClass)
getServiceReference
in interface ServiceManager
public <S> Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(Class<S> aClass, String s) throws org.osgi.framework.InvalidSyntaxException
getServiceReferences
in interface ServiceManager
org.osgi.framework.InvalidSyntaxException
public <S> S getService(org.osgi.framework.ServiceReference<S> serviceReference)
getService
in interface ServiceManager
public <S> S getService(Class<S> aClass)
getService
in interface ServiceManager
This work is licensed under a Creative Commons Attribution 4.0 International License.