Service Management Framework
Release 3.1

com.ibm.osg.smf.platform.flash
Class FlashBundleStore

java.lang.Object
  |
  +--com.ibm.osg.smf.platform.flash.FlashBundleStore
All Implemented Interfaces:
Platform

public class FlashBundleStore
extends java.lang.Object
implements Platform

Provides an implementation of a Bundle Store which stores bundles and bundle information in Flash memory.

The options that the FlashBundleStore recognizes and handles are:

(c) Copyright IBM Corp. 1999, 2002


Field Summary
static java.lang.String DATA_DIR
          The name of the data subdirectory in the bundles local store.
static java.lang.String DEFAULT_FLASH_FILE
           
static int DEFAULT_FLASH_FILE_SIZE_MB
           
 
Constructor Summary
FlashBundleStore(java.lang.String[] args)
          Creates and prepares the flash bundle store according to the options.
 
Method Summary
 void compactStorage()
          Cleans the persistent storage.
 java.lang.String findLibrary(org.osgi.framework.Bundle bundle, java.lang.String name)
          Returns the absolute path name of a native library or null if not found.
 java.io.File getDataFile(org.osgi.framework.Bundle bundle, java.lang.String filename)
          Creates a File object for a file in the persistent storage area provided for the bundle by the framework.
 java.util.Vector getInstalledBundles()
          Returns an array of all installed Bundles.
 java.lang.String getMetadata(org.osgi.framework.Bundle bundle)
          Returns the metadata string for a bundle.
 PermissionStorage getPermissionStorage()
          Returns the PermissionStorage object which will be used to to manage the permission data.
 java.util.Properties getProperties()
          Returns the properties object for the platform.
 int getStatus(org.osgi.framework.Bundle bundle)
          Returns the given bundle's status as recorded in the bundle management information.
 long getTotalFreeSpace()
          Returns the total amount of free space available for bundle storage on the device.
 void initialize(Framework fw)
          Initializes the Platform object so that it is ready to be called by the framework.
 void initializeStorage()
          Initializes the bundle's data storage.
 BundleStorage installBundle(java.lang.String location, java.net.URLConnection source)
          Prepares to install a bundle from a URLConnection.
 java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
          Maps a location to an InputStream.
 void setMetadata(org.osgi.framework.Bundle bundle, java.lang.String metadata)
          Set the metadata for a bundle.
 void setStatus(org.osgi.framework.Bundle bundle, int newStatus)
          Updates the status of the given bundle.
 BundleStorage uninstallBundle(org.osgi.framework.Bundle bundle)
          Prepares to uninstall a bundle.
 BundleStorage updateBundle(org.osgi.framework.Bundle bundle, java.net.URLConnection source)
          Prepares to update a bundle from a URLConnection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_DIR

public static final java.lang.String DATA_DIR
The name of the data subdirectory in the bundles local store.

DEFAULT_FLASH_FILE

public static final java.lang.String DEFAULT_FLASH_FILE

DEFAULT_FLASH_FILE_SIZE_MB

public static final int DEFAULT_FLASH_FILE_SIZE_MB
Constructor Detail

FlashBundleStore

public FlashBundleStore(java.lang.String[] args)
Creates and prepares the flash bundle store according to the options.
The options that FlashPlatform recognizes and handles are: Any other arguments are ignored.
Parameters:
An - array of strings containing arguments in the form of key=value pairs.
Method Detail

initialize

public void initialize(Framework fw)
Initializes the Platform object so that it is ready to be called by the framework. This method must be called before any other Platform methods.
Specified by:
initialize in interface Platform
Parameters:
framework - The Framework object that this Platform object is supporting.

initializeStorage

public void initializeStorage()
Initializes the bundle's data storage.
Specified by:
initializeStorage in interface Platform
Following copied from interface: com.ibm.osg.smf.platform.Platform
Throws:
java.io.IOException - If the platform is unable to initialize the bundle storage.

compactStorage

public void compactStorage()
Cleans the persistent storage.
Specified by:
compactStorage in interface Platform

findLibrary

public java.lang.String findLibrary(org.osgi.framework.Bundle bundle,
                                    java.lang.String name)
Returns the absolute path name of a native library or null if not found.
Specified by:
findLibrary in interface Platform
Parameters:
bundle - the bundle
name - the library name
Returns:
the absolute path of the native library

getDataFile

public java.io.File getDataFile(org.osgi.framework.Bundle bundle,
                                java.lang.String filename)
Creates a File object for a file in the persistent storage area provided for the bundle by the framework. If the platform does not have file system support, this method will return null.
Specified by:
getDataFile in interface Platform
Parameters:
bundle - the bundle
filename - the path name of the file
Returns:
The file

getStatus

public int getStatus(org.osgi.framework.Bundle bundle)
              throws org.osgi.framework.BundleException
Returns the given bundle's status as recorded in the bundle management information.
Specified by:
getStatus in interface Platform
Parameters:
bundle - the bundle whose status is required
Throws:
org.osgi.framework.BundleException - if the status for the given bundle cannot be retrieved

getMetadata

public java.lang.String getMetadata(org.osgi.framework.Bundle bundle)
                             throws org.osgi.framework.BundleException
Returns the metadata string for a bundle.
Specified by:
getMetadata in interface Platform
Parameters:
bundle - the bundle to retrieve metadata for
Throws:
org.osgi.framework.BundleException - if the methods fails.

getInstalledBundles

public java.util.Vector getInstalledBundles()
Returns an array of all installed Bundles.
Specified by:
getInstalledBundles in interface Platform
Following copied from interface: com.ibm.osg.smf.platform.Platform
Returns:
Vector of installed Bundles.

getPermissionStorage

public PermissionStorage getPermissionStorage()
                                       throws java.io.IOException
Returns the PermissionStorage object which will be used to to manage the permission data.

The PermissionStorage object will store permission data in the flash master element .

Specified by:
getPermissionStorage in interface Platform
Returns:
The PermissionStorage object for the FlashBundleStore platform.

getProperties

public java.util.Properties getProperties()
Returns the properties object for the platform. These properties in the returned object supplement the System properties. The framework may modify this object.
Specified by:
getProperties in interface Platform
Returns:
The properites object for the platform.

getTotalFreeSpace

public long getTotalFreeSpace()
                       throws java.io.IOException
Returns the total amount of free space available for bundle storage on the device.
Specified by:
getTotalFreeSpace in interface Platform
Throws:
java.io.IOException - if an I/O error occurs determining the available space

installBundle

public BundleStorage installBundle(java.lang.String location,
                                   java.net.URLConnection source)
                            throws org.osgi.framework.BundleException
Prepares to install a bundle from a URLConnection.

To complete the install, modify and then commit will be called on the returned BundleStorage object. If either of these methods throw a BundleException or some other error occurs, then undo will be called on the BundleStorage object to undo the change to persistent storage.

Specified by:
installBundle in interface Platform
Parameters:
location - Bundle location.
source - URLConnection from which the bundle may be read.
Throws:
org.osgi.framework.BundleException - if the install preparation fails.

mapLocationToURLConnection

public java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
                                                  throws org.osgi.framework.BundleException
Maps a location to an InputStream.
Specified by:
mapLocationToURLConnection in interface Platform
Parameters:
location - of the bundle.
Returns:
InputStream that represents the location.
Throws:
org.osgi.framework.BundleException - if the mapping fails

setStatus

public void setStatus(org.osgi.framework.Bundle bundle,
                      int newStatus)
               throws org.osgi.framework.BundleException
Updates the status of the given bundle.
Specified by:
setStatus in interface Platform
Parameters:
bundle - the com.ibm.osg.smf.Bundle whose status is to be set
newStatus - the Bundle's status
Throws:
org.osgi.framework.BundleException - if there is a problem updating the store's tables to reflect the change in bundle status

setMetadata

public void setMetadata(org.osgi.framework.Bundle bundle,
                        java.lang.String metadata)
                 throws org.osgi.framework.BundleException
Set the metadata for a bundle.
Specified by:
setMetadata in interface Platform
Parameters:
bundle - Bundle to save metadata for
metadata - Bundle's metadata string
Throws:
org.osgi.framework.BundleException - if the methods fails.
java.lang.NullPointerException - if the metadata is null.

uninstallBundle

public BundleStorage uninstallBundle(org.osgi.framework.Bundle bundle)
                              throws org.osgi.framework.BundleException
Prepares to uninstall a bundle.

To complete the uninstall, modify and then commit will be called on the returned BundleStorage object. If either of these methods throw a BundleException or some other error occurs, then undo will be called on the BundleStorage object to undo the change to persistent storage.

Specified by:
uninstallBundle in interface Platform
Parameters:
bundle - Bundle to uninstall.
Throws:
org.osgi.framework.BundleException - if the uninstall preparation fails.

updateBundle

public BundleStorage updateBundle(org.osgi.framework.Bundle bundle,
                                  java.net.URLConnection source)
                           throws org.osgi.framework.BundleException
Prepares to update a bundle from a URLConnection.

To complete the update, modify and then commit will be called on the returned BundleStorage object. If either of these methods throw a BundleException or some other error occurs, then undo will be called on the BundleStorage object to undo the change to persistent storage.

Specified by:
updateBundle in interface Platform
Parameters:
bundle - Bundle to update
source - URLConnection from which the bundle may be read
Throws:
org.osgi.framework.BundleException - if the update preparation fails.

Service Management Framework
Release 3.1

Licensed Materials - Property of IBM. (C) Copyright IBM Corp. 2000, 2002 All Rights Reserved. IBM is a registered trademark of IBM Corp.