Class NonWorkingOsgiFramework
- java.lang.Object
-
- com.yahoo.jdisc.test.NonWorkingOsgiFramework
-
- All Implemented Interfaces:
com.yahoo.jdisc.application.OsgiFramework
public class NonWorkingOsgiFramework extends java.lang.Object implements com.yahoo.jdisc.application.OsgiFramework
- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description NonWorkingOsgiFramework()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.osgi.framework.BundleContext
bundleContext()
Returns the BundleContext of this framework's system bundle.java.util.List<org.osgi.framework.Bundle>
bundles()
Returns an iterable collection of all installed bundles.java.util.List<org.osgi.framework.Bundle>
installBundle(java.lang.String bundleLocation)
Installs a bundle from the specified location.void
refreshPackages()
This method synchronously refreshes all bundles currently loaded.void
start()
This method starts the framework instance.void
startBundles(java.util.List<org.osgi.framework.Bundle> bundles, boolean privileged)
Starts the givenBundle
s.void
stop()
This method synchronously shuts down the framework.
-
-
-
Method Detail
-
installBundle
public java.util.List<org.osgi.framework.Bundle> installBundle(java.lang.String bundleLocation)
Description copied from interface:com.yahoo.jdisc.application.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 expcetion 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 interfacecom.yahoo.jdisc.application.OsgiFramework
- 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.
-
startBundles
public void startBundles(java.util.List<org.osgi.framework.Bundle> bundles, boolean privileged)
Description copied from interface:com.yahoo.jdisc.application.OsgiFramework
Starts the given
Bundle
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 interfacecom.yahoo.jdisc.application.OsgiFramework
- Parameters:
bundles
- The bundles to start.privileged
- Whether or not privileges are available.
-
refreshPackages
public void refreshPackages()
Description copied from interface:com.yahoo.jdisc.application.OsgiFramework
This method synchronously refreshes all bundles currently loaded. Once this method returns, the class loaders of all bundles will reflect on the current set of loaded bundles.
- Specified by:
refreshPackages
in interfacecom.yahoo.jdisc.application.OsgiFramework
-
bundleContext
public org.osgi.framework.BundleContext bundleContext()
Description copied from interface:com.yahoo.jdisc.application.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 return
null
if it has no valid BundleContext.- Specified by:
bundleContext
in interfacecom.yahoo.jdisc.application.OsgiFramework
- Returns:
- A
BundleContext
for the system bundle, ornull
.
-
bundles
public java.util.List<org.osgi.framework.Bundle> bundles()
Description copied from interface:com.yahoo.jdisc.application.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 interfacecom.yahoo.jdisc.application.OsgiFramework
- Returns:
- An iterable collection of Bundle objects, one object per installed bundle.
-
start
public void start()
Description copied from interface:com.yahoo.jdisc.application.OsgiFramework
This method starts the framework instance. Before this method is called, any call to
OsgiFramework.installBundle(String)
orOsgiFramework.bundles()
will generate aNullPointerException
.- Specified by:
start
in interfacecom.yahoo.jdisc.application.OsgiFramework
-
stop
public void stop()
Description copied from interface:com.yahoo.jdisc.application.OsgiFramework
This method synchronously shuts down the framework. It must be called at the end of a session in order to shutdown all active bundles.
- Specified by:
stop
in interfacecom.yahoo.jdisc.application.OsgiFramework
-
-