Class FelixFramework
- All Implemented Interfaces:
OsgiFramework
- Author:
- Simon Thoresen Hult, gjoranv
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allowDuplicateBundles
(Collection<org.osgi.framework.Bundle> bundles) Allows this framework to install duplicates of the given collection of bundles.org.osgi.framework.BundleContext
Returns the BundleContext of this framework's system bundle.List<org.osgi.framework.Bundle>
bundles()
Returns an iterable collection of all installed bundles.List<org.osgi.framework.Bundle>
getBundles
(org.osgi.framework.Bundle requestingBundle) Returns all installed bundles that are visible to the requesting bundle.List<org.osgi.framework.Bundle>
installBundle
(String bundleLocation) Installs a bundle from the specified location.boolean
Returns true if this is a Felix based framework and not e.g.void
NOTE: This method is no longer used by the Jdisc container framework, but kept for completeness.void
start()
This method starts the framework instance.void
startBundles
(List<org.osgi.framework.Bundle> bundles, boolean privileged) Starts the givenBundle
s.void
stop()
Synchronously shut down the framework.
-
Constructor Details
-
FelixFramework
-
-
Method Details
-
start
public void start() throws org.osgi.framework.BundleExceptionDescription copied from interface:OsgiFramework
This method starts the framework instance. Before this method is called, any call toOsgiFramework.installBundle(String)
orOsgiFramework.bundles()
will generate aNullPointerException
.- Specified by:
start
in interfaceOsgiFramework
- Throws:
org.osgi.framework.BundleException
- if any error occurs
-
stop
public void stop() throws org.osgi.framework.BundleExceptionDescription copied from interface:OsgiFramework
Synchronously shut down the framework. It must be called at the end of a session to shutdown all active bundles.- Specified by:
stop
in interfaceOsgiFramework
- Throws:
org.osgi.framework.BundleException
- if any error occurs
-
installBundle
public List<org.osgi.framework.Bundle> installBundle(String bundleLocation) throws org.osgi.framework.BundleException Description copied from interface:OsgiFramework
Installs a bundle from the specified location. The specified location identifier will be used as the identity of the bundle. If a bundle containing the same location identifier is already installed, the
Bundle
object for that bundle is returned. All bundles listed in theOsgiHeader.PREINSTALL_BUNDLE
manifest header are also installed. The bundle at index 0 of the returned list matches thebundleLocation
argument.NOTE: When this method installs more than one bundle, AND one of those bundles throw an exception during installation, the bundles installed prior to throwing the exception will remain installed. To enable the caller to recover from such a situation, this method wraps any thrown exception within a
BundleInstallationException
that contains the list of successfully installed bundles.It would be preferable if this method was exception-safe (that it would roll-back all installed bundles in the case of an exception), but that can not be implemented thread-safely since an
Application
may choose to install bundles concurrently through any availableBundleContext
.- Specified by:
installBundle
in interfaceOsgiFramework
- Parameters:
bundleLocation
- the location identifier of the bundle to install- Returns:
- the list of Bundle objects installed, the object at index 0 matches the given location
- Throws:
BundleInstallationException
- if the input stream cannot be read, or the installation of a bundle failed, or the caller does not have the appropriate permissions, or the systemBundleContext
is no longer validorg.osgi.framework.BundleException
-
startBundles
public void startBundles(List<org.osgi.framework.Bundle> bundles, boolean privileged) throws org.osgi.framework.BundleException Description copied from interface:OsgiFramework
Starts the givenBundle
s. The parameterprivileged
tells the framework whether or not privileges are available, and is checked against theOsgiHeader.PRIVILEGED_ACTIVATOR
header of each Bundle being started. Any bundle that is a fragment is silently ignored.- Specified by:
startBundles
in interfaceOsgiFramework
- Parameters:
bundles
- the bundles to startprivileged
- whether or not privileges are available- Throws:
org.osgi.framework.BundleException
- if a bundle could not be started. This could be because a code dependency could not be resolved or the specified BundleActivator could not be loaded or threw an exception.
-
refreshPackages
public void refreshPackages()NOTE: This method is no longer used by the Jdisc container framework, but kept for completeness.- Specified by:
refreshPackages
in interfaceOsgiFramework
-
bundleContext
public org.osgi.framework.BundleContext bundleContext()Description copied from interface:OsgiFramework
Returns the BundleContext of this framework's system bundle. The returned BundleContext can be used by the caller to act on behalf of this bundle. This method may returnnull
if it has no valid BundleContext.- Specified by:
bundleContext
in interfaceOsgiFramework
- Returns:
- a
BundleContext
for the system bundle, ornull
-
bundles
Description copied from interface:OsgiFramework
Returns an iterable collection of all installed bundles. This method returns a list of all bundles installed in the OSGi environment at the time of the call to this method. However, since the OsgiFramework is a very dynamic environment, bundles can be installed or uninstalled at anytime.- Specified by:
bundles
in interfaceOsgiFramework
- Returns:
- an iterable collection of Bundle objects, one object per installed bundle
-
getBundles
Description copied from interface:OsgiFramework
Returns all installed bundles that are visible to the requesting bundle. Bundle visibility is controlled via implementations ofFindHook
;- Specified by:
getBundles
in interfaceOsgiFramework
-
allowDuplicateBundles
Description copied from interface:OsgiFramework
Allows this framework to install duplicates of the given collection of bundles. Duplicate detection is handled by theBundleCollisionHook
.- Specified by:
allowDuplicateBundles
in interfaceOsgiFramework
- Parameters:
bundles
- The bundles to allow duplicates of. An empty collection will prohibit any duplicates.
-
isFelixFramework
public boolean isFelixFramework()Description copied from interface:OsgiFramework
Returns true if this is a Felix based framework and not e.g. a test framework.- Specified by:
isFelixFramework
in interfaceOsgiFramework
-