Interface OsgiContainerManager
- All Known Implementing Classes:
FelixOsgiContainerManager
public interface OsgiContainerManager
Manages the OSGi container and handles any interactions with it
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddBundleListener(org.osgi.framework.BundleListener listener) That is shortcut to access SystemBundle.org.osgi.framework.Bundle[]Gets a list of installed bundlesGets a list of host component registrationsorg.osgi.framework.ServiceReference[]Gets a list of service referencesorg.osgi.util.tracker.ServiceTrackergetServiceTracker(String interfaceClassName) Gets a service tracker to follow a service registered under a certain interface.org.osgi.util.tracker.ServiceTrackergetServiceTracker(String interfaceClassName, org.osgi.util.tracker.ServiceTrackerCustomizer serviceTrackerCustomizer) Gets a service tracker to follow a service registered under a certain interface with aServiceTrackerCustomizerattached for customizing tracked service objects.org.osgi.framework.BundleinstallBundle(File file, ReferenceMode referenceMode) Installs a bundle into a running OSGI container.booleanvoidremoveBundleListener(org.osgi.framework.BundleListener listener) That is shortcut to access SystemBundle.voidstart()Starts the OSGi containervoidstop()Stops the OSGi container
-
Method Details
-
start
void start()Starts the OSGi container- Throws:
OsgiContainerException- If the container cannot be started
-
stop
void stop()Stops the OSGi container- Throws:
OsgiContainerException- If the container cannot be stopped
-
installBundle
Installs a bundle into a running OSGI container.- Parameters:
file- The bundle file to install.referenceMode- specifies whether the container may install a reference to, rather than copy, the bundle file.- Returns:
- The installed bundle.
- Throws:
OsgiContainerException- If the bundle cannot be loaded- Since:
- 4.0.0
-
isRunning
boolean isRunning()- Returns:
- If the container is running or not
-
getBundles
org.osgi.framework.Bundle[] getBundles()Gets a list of installed bundles- Returns:
- An array of bundles
-
getRegisteredServices
org.osgi.framework.ServiceReference[] getRegisteredServices()Gets a list of service references- Returns:
- An array of service references
-
getHostComponentRegistrations
List<HostComponentRegistration> getHostComponentRegistrations()Gets a list of host component registrations- Returns:
- A list of host component registrations
-
getServiceTracker
Gets a service tracker to follow a service registered under a certain interface. Will return a newServiceTrackerinstance for every call, so don't call more than necessary. Any providedServiceTrackerinstances will be opened before returning and automatically closed on shutdown.- Parameters:
interfaceClassName- The interface class as a String- Returns:
- A service tracker to follow all instances of that interface
- Throws:
IllegalStateException- If the OSGi container is not running- Since:
- 2.1
-
getServiceTracker
org.osgi.util.tracker.ServiceTracker getServiceTracker(String interfaceClassName, org.osgi.util.tracker.ServiceTrackerCustomizer serviceTrackerCustomizer) Gets a service tracker to follow a service registered under a certain interface with aServiceTrackerCustomizerattached for customizing tracked service objects. Will return a newServiceTrackerinstance for every call, so don't call more than necessary. Any providedServiceTrackerinstances will be opened before returning and automatically closed on shutdown.- Parameters:
interfaceClassName- The interface class as a StringserviceTrackerCustomizer- service tracker customizer for the created service tracker- Returns:
- A service tracker to follow all instances of that interface
- Throws:
IllegalStateException- If the OSGi container is not running- Since:
- 2.13
-
addBundleListener
void addBundleListener(org.osgi.framework.BundleListener listener) That is shortcut to access SystemBundle. -
removeBundleListener
void removeBundleListener(org.osgi.framework.BundleListener listener) That is shortcut to access SystemBundle.
-