Interface SynchronizedInstaller
public interface SynchronizedInstaller
Performs various installations/configuration related operations and waits for expected states to
be met before returning. WARNING: This service should be used with extreme caution. OSGI is a
highly async framework, manually waiting for other bundle/service states to be met is typically a
sign of a code smell or poor design. This service is primarily useful for determining when the
system is in a ready state for users to interact with or testing.
This code is experimental. While this interface is functional and tested, it may change or * be removed in a future version of the library.
-
Method Summary
Modifier and TypeMethodDescriptionorg.osgi.service.cm.ConfigurationcreateManagedFactoryService(long maxWaitTime, String factoryPid, Map<String, Object> properties, String bundleLocation) Creates a Managed Service using the Managed Service Factory matching the provided factory pid.org.osgi.service.cm.ConfigurationcreateManagedFactoryService(String factoryPid, Map<String, Object> properties, String bundleLocation) Creates a Managed Service using the Managed Service Factory matching the provided factory pid.voidinstallFeatures(long maxWaitTime, EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) Installs and starts one or more features.voidinstallFeatures(String feature, String... additionalFeatures) Installs and starts one or more features.voidinstallFeatures(EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) Installs and starts one or more features.voidstartBundles(String symbolicName, String... additionalSymbolicNames) Starts the specified bundles.voidstopBundles(String symbolicName, String... additionalSymbolicNames) Stops the specified bundles.voiduninstallFeatures(long maxWaitTime, EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) Uninstalls one or more features.voiduninstallFeatures(String feature, String... additionalFeatures) Uninstalls one or more features.voiduninstallFeatures(EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) Uninstalls one or more features.voidupdateManagedService(long maxWaitTime, String servicePid, Map<String, Object> properties, String bundleLocation) Waits for Managed Service to come up before updating it's properties.voidWaits for Managed Service to come up before updating its properties.voidWaits up to 10 minutes for the system to reach a state that is ready for user operation.voidwaitForBootFinish(long maxWaitTime) Waits for boot features to be installed and all bundles to reach an Active statevoidwaitForBundles(long maxWaitTime, String... symbolicNames) Waits for installed bundles with the specified symbolic names to be in an Active before returning.voidwaitForBundles(String... symbolicNames) Waits for installed bundles with the specified symbolic names to be in an Active before returning.voidwaitForServiceToBeAvailable(long maxWaitTime, String servicePid) Waits for a service with a matching service pid to appear before returning.voidwaitForServiceToBeAvailable(String servicePid) Waits for a service with a matching service pid to appear before returning.
-
Method Details
-
waitForBootFinish
Waits up to 10 minutes for the system to reach a state that is ready for user operation.- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
waitForBootFinish
Waits for boot features to be installed and all bundles to reach an Active state- Parameters:
maxWaitTime- max period to wait, in milliseconds, for boot to finish before failing- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
createManagedFactoryService
org.osgi.service.cm.Configuration createManagedFactoryService(String factoryPid, @Nullable Map<String, Object> properties, @Nullable String bundleLocation) throws InterruptedExceptionCreates a Managed Service using the Managed Service Factory matching the provided factory pid. Waits for the service to be registered before returning For Managed Services not created from a Managed Service Factory, useupdateManagedService(String, Map, String)instead.- Parameters:
factoryPid- the factory pid of the Managed Service Factoryproperties- the service properties for the Managed ServicebundleLocation- the bundle location the configuration should be associated with. SeeConfiguration.getBundleLocation()for more details.- Returns:
- configuration of the service created
- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
createManagedFactoryService
org.osgi.service.cm.Configuration createManagedFactoryService(long maxWaitTime, String factoryPid, @Nullable Map<String, Object> properties, @Nullable String bundleLocation) throws InterruptedExceptionCreates a Managed Service using the Managed Service Factory matching the provided factory pid. Waits for the service to be registered before returning For Managed Services not created from a Managed Service Factory, useupdateManagedService(String, Map, String)instead.- Parameters:
maxWaitTime- the max time to wait, in milliseconds, for the service to appear before failingfactoryPid- the factory pid of the Managed Service Factoryproperties- the service properties for the Managed ServicebundleLocation- the bundle location the configuration should be associated with. SeeConfiguration.getBundleLocation()for more details.- Returns:
- configuration of the service created
- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
updateManagedService
void updateManagedService(String servicePid, Map<String, Object> properties, @Nullable String bundleLocation) throws InterruptedExceptionWaits for Managed Service to come up before updating its properties. Waits for the properties to be reflected in the service's Configuration. Does not guarantee the bean has received the values from the Configuration. For services created from a Managed Service Factory, usecreateManagedFactoryService(String, Map, String)instead.- Parameters:
servicePid- persistent identifier of the Managed Service to updateproperties- service configuration propertiesbundleLocation- the bundle location the configuration should be associated with. SeeConfiguration.getBundleLocation()for more details.- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
updateManagedService
void updateManagedService(long maxWaitTime, String servicePid, Map<String, Object> properties, @Nullable String bundleLocation) throws InterruptedExceptionWaits for Managed Service to come up before updating it's properties. Waits for the properties to reflected in the services Configuration. Does not guarantee the bean has received the values from the Configuration. For services created from a Managed Service Factory, usecreateManagedFactoryService(String, Map, String)instead.- Parameters:
maxWaitTime- the max time to wait, in milliseconds, for the service to appear invalid input: '&' changes to be reflected in service configuration before failingservicePid- persistent identifier of the Managed Service to startproperties- service configuration propertiesbundleLocation- the bundle location the configuration should be associated with. SeeConfiguration.getBundleLocation()for more details.- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
waitForServiceToBeAvailable
Waits for a service with a matching service pid to appear before returning.- Parameters:
servicePid- persistent identifier of the Managed Service to wait for- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
waitForServiceToBeAvailable
Waits for a service with a matching service pid to appear before returning.- Parameters:
maxWaitTime- the max time, in milliseconds, to wait for the service to appear before failingservicePid- persistent identifier of the Managed Service to wait for- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
installFeatures
Installs and starts one or more features. Waits until the state of all specified features are Started and all bundles are Active before returning.- Parameters:
feature- name of feature to be startedadditionalFeatures- names of additional features to be started- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
installFeatures
void installFeatures(EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) throws InterruptedException Installs and starts one or more features. Waits until the state of all specified features are Started and all bundles are Active before returning.- Parameters:
options- additional feature installation optionsfeature- name of feature to be startedadditionalFeatures- names of additional features to be started- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
installFeatures
void installFeatures(long maxWaitTime, EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) throws InterruptedException Installs and starts one or more features. Waits until the state of all specified features are Started and all bundles are Active before returning.- Parameters:
maxWaitTime- the max wait time, in milliseconds, for features to start and bundles to reach an Active stateoptions- additional feature installation optionsfeature- name of feature to be startedadditionalFeatures- names of additional features to be started- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
uninstallFeatures
Uninstalls one or more features. Waits for the all bundles to reach an Active state before returning- Parameters:
feature- name of feature to uninstalladditionalFeatures- names of additional features to uninstall- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
uninstallFeatures
void uninstallFeatures(EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) throws InterruptedException Uninstalls one or more features. Waits for the all bundles to reach an Active state before returning- Parameters:
options- additional options for feature uninstallsfeature- name of feature to uninstalladditionalFeatures- names of additional features to uninstall- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
uninstallFeatures
void uninstallFeatures(long maxWaitTime, EnumSet<org.apache.karaf.features.FeaturesService.Option> options, String feature, String... additionalFeatures) throws InterruptedException Uninstalls one or more features. Waits until all bundles reach an Active state before returning.- Parameters:
maxWaitTime- the max wait time, in milliseconds, for features to start and bundles to reach an Active stateoptions- additional options for feature uninstallsfeature- name of feature to be startedadditionalFeatures- names of additional features to be started- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
stopBundles
Stops the specified bundles.- Parameters:
symbolicName- symbolic name of installed bundle to stopadditionalSymbolicNames- symbolic names of additional installed bundles to stop- Throws:
SynchronizedInstallerException- if an error occurs while stopping bundles
-
startBundles
Starts the specified bundles. In the case of a fragment, the Resolved state waited for before returning.- Parameters:
symbolicName- symbolic name of installed bundle to startadditionalSymbolicNames- symbolic names of additional installed bundles to start- Throws:
SynchronizedInstallerException- if an error occurs while starting bundles
-
waitForBundles
Waits for installed bundles with the specified symbolic names to be in an Active before returning. In the case of a fragment, the Resolved state waited for before returning. If no symbolicNames are specified, this method will wait for all installed bundles to reach an Active state before returning.- Parameters:
symbolicNames- symbolic names of installed bundles to wait to reach an Active state- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-
waitForBundles
Waits for installed bundles with the specified symbolic names to be in an Active before returning. In the case of a fragment, the Resolved state waited for before returning. If no symbolicNames are specified, this method will wait for all installed bundles to reach an Active state before returning.- Parameters:
maxWaitTime- max time to wait, in milliseconds, for bundles to reach an Active statesymbolicNames- symbolic names of installed bundles to wait to reach an Active state- Throws:
SynchronizedInstallerException- if an error occurs while performing waitSynchronizedInstallerTimeoutException- if condition takes longer than max wait time to be metInterruptedException- if thread is interrupted while waiting for condition to be met
-