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 ServiceManagerpublic org.osgi.service.cm.Configuration createManagedService(String factoryPid, Map<String,Object> properties) throws IOException
ServiceManagerFor Managed Services not created from a Managed Service Factory, use ServiceManager.startManagedService(String, Map) instead.
createManagedService in interface ServiceManagerfactoryPid - 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
ServiceManagerFor Managed Services created from a Managed Service Factory, use ServiceManager.createManagedService(String, Map) instead.
startManagedService in interface ServiceManagerservicePid - 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
ServiceManagerstopManagedService in interface ServiceManagerservicePid - persistent identifier of the Managed Service to stopIOException - thrown if if access to persistent storage failspublic void startFeature(boolean wait,
String... featureNames)
throws Exception
ServiceManagerstartFeature in interface ServiceManagerwait - 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
ServiceManagerstopFeature in interface ServiceManagerwait - 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
ServiceManagerrestartBundles in interface ServiceManagerbundleSymbolicNames - 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 ServiceManagerorg.osgi.framework.BundleExceptionpublic void startBundle(String bundleSymbolicName) throws org.osgi.framework.BundleException
startBundle in interface ServiceManagerorg.osgi.framework.BundleExceptionpublic void waitForRequiredApps(String... appNames) throws InterruptedException
waitForRequiredApps in interface ServiceManagerInterruptedExceptionpublic void waitForAllBundles()
throws InterruptedException
waitForAllBundles in interface ServiceManagerInterruptedExceptionpublic void waitForRequiredBundles(String symbolicNamePrefix) throws InterruptedException
waitForRequiredBundles in interface ServiceManagerInterruptedExceptionpublic void waitForBundleUninstall(String... bundleSymbolicNames)
ServiceManagerwaitForBundleUninstall in interface ServiceManagerbundleSymbolicNames - symbolic names of the bundles to wait forpublic void waitForFeature(String featureName, Predicate<org.apache.karaf.features.FeatureState> predicate) throws Exception
waitForFeature in interface ServiceManagerExceptionpublic void waitForHttpEndpoint(String path) throws InterruptedException
waitForHttpEndpoint in interface ServiceManagerInterruptedExceptionpublic void waitForSourcesToBeAvailable(String restPath, String... sources) throws InterruptedException
waitForSourcesToBeAvailable in interface ServiceManagerInterruptedExceptionpublic Map<String,Object> getMetatypeDefaults(String symbolicName, String factoryPid)
getMetatypeDefaults in interface ServiceManagerpublic void printInactiveBundles()
printInactiveBundles in interface ServiceManagerpublic void printInactiveBundlesInfo()
printInactiveBundlesInfo in interface ServiceManagerpublic <S> org.osgi.framework.ServiceReference<S> getServiceReference(Class<S> aClass)
getServiceReference in interface ServiceManagerpublic <S> Collection<org.osgi.framework.ServiceReference<S>> getServiceReferences(Class<S> aClass, String s) throws org.osgi.framework.InvalidSyntaxException
getServiceReferences in interface ServiceManagerorg.osgi.framework.InvalidSyntaxExceptionpublic <S> S getService(org.osgi.framework.ServiceReference<S> serviceReference)
getService in interface ServiceManagerpublic <S> S getService(Class<S> aClass)
getService in interface ServiceManagerThis work is licensed under a Creative Commons Attribution 4.0 International License.