org.knopflerfish.framework
Class Framework

java.lang.Object
  extended by org.knopflerfish.framework.Framework

public class Framework
extends java.lang.Object

This class contains references to all common data structures inside the framework.


Field Summary
 Bundles bundles
          All bundle in this framework.
static boolean isDoubleCheckedLockingSafe
          Is it safe to use double-checked locking or not.
static int javaVersionMajor
           
static int javaVersionMicro
           
static int javaVersionMinor
           
protected static java.util.Map props
          The "System" properties for this framework instance.
static boolean UNREGISTERSERVICE_VALID_DURING_UNREGISTERING
           
 
Constructor Summary
Framework(java.lang.Object m)
          Contruct a framework.
 
Method Summary
 long getBundleId(java.lang.String location)
          Retrieve bundle id of the bundle that has the given unique location.
 java.lang.String getBundleLocation(long id)
          Retrieve location of the bundle that has the given unique identifier.
 FileTree getDataStorage(long id)
          Get private bundle data storage file handle.
static java.util.Dictionary getProperties()
           
static java.lang.String getProperty(java.lang.String key)
          Retrieve the value of the named framework property.
static boolean getProperty(java.lang.String key, boolean def)
          Retrieve the boolean value of the named framework property, with a default value.
static java.lang.String getProperty(java.lang.String key, java.lang.String def)
          Retrieve the value of the named framework property, with a default value.
 BundleContext getSystemBundleContext()
          Get the bundle context used by the system bundle.
static java.util.Properties getSystemProperties()
          Get a copy of the current system properties.
protected static void initProperties()
           
 long installBundle(java.lang.String location, java.io.InputStream in)
          Install a bundle from the given location.
 void launch(long startBundle)
          Start this Framework.
static void setProperties(java.util.Dictionary newProps)
           
static void setProperty(java.lang.String key, java.lang.String val)
           
 void shutdown()
          Stop this Framework, suspending all started contexts.
 void startBundle(long id)
          Start a bundle.
 void stopBundle(long id)
          Stop a bundle.
 void uninstallBundle(long id)
          Uninstall a bundle.
 void updateBundle(long id)
          Update a bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected static java.util.Map props
The "System" properties for this framework instance. Allways use Framework.setProperty(String,String) to add values to this map.


bundles

public Bundles bundles
All bundle in this framework.


UNREGISTERSERVICE_VALID_DURING_UNREGISTERING

public static final boolean UNREGISTERSERVICE_VALID_DURING_UNREGISTERING

javaVersionMajor

public static int javaVersionMajor

javaVersionMinor

public static int javaVersionMinor

javaVersionMicro

public static int javaVersionMicro

isDoubleCheckedLockingSafe

public static final boolean isDoubleCheckedLockingSafe
Is it safe to use double-checked locking or not. It is safe if JSR 133 is included in the running JRE. I.e., for Java SE if version is 1.5 or higher.

Constructor Detail

Framework

public Framework(java.lang.Object m)
          throws java.lang.Exception
Contruct a framework.

Throws:
java.lang.Exception
Method Detail

launch

public void launch(long startBundle)
            throws BundleException
Start this Framework. This method starts all the bundles that were started at the time of the last shutdown.

If the Framework is already started, this method does nothing. If the Framework is not started, this method will:

  1. Enable event handling. At this point, events can be delivered to listeners.
  2. Attempt to start all bundles marked for starting as described in the Bundle.start() method. Reports any exceptions that occur during startup using FrameworkErrorEvents.
  3. Set the state of the Framework to active.
  4. Broadcasting a FrameworkEvent through the FrameworkListener.frameworkStarted method.

If this Framework is not launched, it can still install, uninstall, start and stop bundles. (It does these tasks without broadcasting events, however.) Using Framework without launching it allows for off-line debugging of the Framework.

Parameters:
startBundle - If it is specified with a value larger than 0, then the bundle with that id is started. Otherwise start all suspended bundles.
Throws:
BundleException

shutdown

public void shutdown()
Stop this Framework, suspending all started contexts. This method suspends all started contexts so that they can be automatically restarted when this Framework is next launched.

If the framework is not started, this method does nothing. If the framework is started, this method will:

  1. Set the state of the Framework to inactive.
  2. Suspended all started bundles as described in the Bundle.stop() method except that the persistent state of the bundle will continue to be started. Reports any exceptions that occur during stopping using FrameworkErrorEvents.
  3. Disable event handling.


installBundle

public long installBundle(java.lang.String location,
                          java.io.InputStream in)
                   throws BundleException
Install a bundle from the given location.

Parameters:
location - The location identifier of the bundle to install.
in - The InputStream from which the bundle will be read.
Returns:
The BundleImpl object of the installed bundle.
Throws:
BundleException - If the install failed.

startBundle

public void startBundle(long id)
                 throws BundleException
Start a bundle.

Parameters:
id - Id of bundle to start.
Throws:
BundleException - If start failed.

stopBundle

public void stopBundle(long id)
                throws BundleException
Stop a bundle.

Parameters:
id - Id of bundle to stop.
Throws:
BundleException - If stop failed.

uninstallBundle

public void uninstallBundle(long id)
                     throws BundleException
Uninstall a bundle.

Parameters:
id - Id of bundle to stop.
Throws:
BundleException - If uninstall failed.

updateBundle

public void updateBundle(long id)
                  throws BundleException
Update a bundle.

Parameters:
id - Id of bundle to update.
Throws:
BundleException - If update failed.

getBundleLocation

public java.lang.String getBundleLocation(long id)
Retrieve location of the bundle that has the given unique identifier.

Parameters:
id - The identifier of the bundle to retrieve.
Returns:
A location as a string, or null if the identifier doesn't match any installed bundle.

getBundleId

public long getBundleId(java.lang.String location)
Retrieve bundle id of the bundle that has the given unique location.

Parameters:
location - The location of the bundle to retrieve.
Returns:
The unique identifier of the bundle, or -1 if the location doesn't match any installed bundle.

getDataStorage

public FileTree getDataStorage(long id)
Get private bundle data storage file handle.


getProperty

public static java.lang.String getProperty(java.lang.String key)
Retrieve the value of the named framework property.


getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String def)
Retrieve the value of the named framework property, with a default value.


getProperty

public static boolean getProperty(java.lang.String key,
                                  boolean def)
Retrieve the boolean value of the named framework property, with a default value.


setProperty

public static void setProperty(java.lang.String key,
                               java.lang.String val)

setProperties

public static void setProperties(java.util.Dictionary newProps)

getProperties

public static java.util.Dictionary getProperties()

getSystemProperties

public static java.util.Properties getSystemProperties()
Get a copy of the current system properties.


initProperties

protected static void initProperties()

getSystemBundleContext

public BundleContext getSystemBundleContext()
Get the bundle context used by the system bundle.