Service Management Framework
Release 3.1

com.ibm.osg.smf.platform
Interface Platform

All Known Implementing Classes:
DefaultPlatform, FlashBundleStore

public interface Platform

Platform interface to SMF. This class is used to provide platform specific support for SMF.

SMF will call this class to perform platform specific functions. Classes that implement Platform MUST provide a constructor that takes as a parameter an array of Strings. This array will contain arguments to be handled by the Platform. The Platform implementation may define the format and content of its arguments. The constructor should parse the arguments passed to it and remember them. The initialize method should perform the actual processing of the platform arguments.


Method Summary
 void compactStorage()
          Compact/cleanup the persistent storage for the platform.
 java.lang.String findLibrary(org.osgi.framework.Bundle bundle, java.lang.String name)
          Returns the absolute path name of a native library for a bundle.
 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()
          Return a list of the installed bundles.
 java.lang.String getMetadata(org.osgi.framework.Bundle bundle)
          Get 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()
          Return the properties object for the platform.
 int getStatus(org.osgi.framework.Bundle bundle)
          Get the status data for a bundle.
 long getTotalFreeSpace()
          Returns the total amount of free space available for bundle storage on the device.
 void initialize(Framework framework)
          Initialize the Platform object so that it is ready to be called by the framework.
 void initializeStorage()
          Initialize the persistent storage for the platform.
 BundleStorage installBundle(java.lang.String location, java.net.URLConnection source)
          Prepare to install a bundle from a URLConnection.
 java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
          Map a location to a URLConnection.
 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 status)
          Set the status data for a bundle.
 BundleStorage uninstallBundle(org.osgi.framework.Bundle bundle)
          Prepare to uninstall a bundle.
 BundleStorage updateBundle(org.osgi.framework.Bundle bundle, java.net.URLConnection source)
          Prepare to update a bundle from a URLConnection.
 

Method Detail

initialize

public void initialize(Framework framework)
Initialize the Platform object so that it is ready to be called by the framework. Handle the arguments that were passed to the constructor. This method must be called before any other Platform methods.
Parameters:
framework - The Framework object that this Platform object is supporting.

initializeStorage

public void initializeStorage()
                       throws java.io.IOException
Initialize the persistent storage for the platform.
Throws:
java.io.IOException - If the platform is unable to initialize the bundle storage.

compactStorage

public void compactStorage()
Compact/cleanup the persistent storage for the platform.

getProperties

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

mapLocationToURLConnection

public java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
                                                  throws org.osgi.framework.BundleException
Map a location to a URLConnection.
Parameters:
location - of the bundle.
Returns:
URLConnection that represents the location.
Throws:
org.osgi.framework.BundleException - if the mapping fails.

getInstalledBundles

public java.util.Vector getInstalledBundles()
Return a list of the installed bundles. This method must construct Bundle objects for all installed bundles and return a Vector containing the objects. The returned Vector becomes the property of the framework.
Returns:
Vector of installed Bundles.

getStatus

public int getStatus(org.osgi.framework.Bundle bundle)
              throws org.osgi.framework.BundleException
Get the status data for a bundle.
Parameters:
bundle - Bundle to retrieve status for.
Returns:
Bundle's status.
Throws:
org.osgi.framework.BundleException - if the methods fails.

setStatus

public void setStatus(org.osgi.framework.Bundle bundle,
                      int status)
               throws org.osgi.framework.BundleException
Set the status data for a bundle.
Parameters:
bundle - Bundle to save status for.
status - Bundle's status.
Throws:
org.osgi.framework.BundleException - if the methods fails.

getMetadata

public java.lang.String getMetadata(org.osgi.framework.Bundle bundle)
                             throws org.osgi.framework.BundleException
Get the metadata string for a bundle.
Parameters:
bundle - Bundle to retrieve metadata for.
Returns:
Bundle's metadata string.
Throws:
org.osgi.framework.BundleException - if the methods fails.

setMetadata

public void setMetadata(org.osgi.framework.Bundle bundle,
                        java.lang.String metadata)
                 throws org.osgi.framework.BundleException
Set the metadata for a bundle.
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.

installBundle

public BundleStorage installBundle(java.lang.String location,
                                   java.net.URLConnection source)
                            throws org.osgi.framework.BundleException
Prepare 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.

Parameters:
location - Bundle location.
source - URLConnection from which the bundle may be read. Any InputStreams returned from the source (URLConnections.getInputStream) must be closed by the BundleStorage object.
Returns:
BundleStorage object to be used to complete the install.
Throws:
org.osgi.framework.BundleException - if the install preparation fails.

updateBundle

public BundleStorage updateBundle(org.osgi.framework.Bundle bundle,
                                  java.net.URLConnection source)
                           throws org.osgi.framework.BundleException
Prepare 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.

Parameters:
bundle - Bundle to update.
source - URLConnection from which the updated bundle may be read. Any InputStreams returned from the source (URLConnections.getInputStream) must be closed by the BundleStorage object.
Returns:
BundleStorage object to be used to complete the update.
Throws:
org.osgi.framework.BundleException - if the update preparation fails.

uninstallBundle

public BundleStorage uninstallBundle(org.osgi.framework.Bundle bundle)
                              throws org.osgi.framework.BundleException
Prepare 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.

Parameters:
bundle - Bundle to uninstall.
Returns:
BundleStorage object to be used to complete the uninstall.
Throws:
org.osgi.framework.BundleException - if the uninstall preparation fails.

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.

A File object for the base directory of the persistent storage area can be obtained by calling this method with the empty string ("") as the parameter.

Parameters:
bundle - The bundle.
filename - The relative name of the desired file.

findLibrary

public java.lang.String findLibrary(org.osgi.framework.Bundle bundle,
                                    java.lang.String name)
Returns the absolute path name of a native library for a bundle.
Parameters:
bundle - The bundle.
name - The library name requested by Runtime.loadLibrary().
Returns:
The absolute path of the native library

getPermissionStorage

public PermissionStorage getPermissionStorage()
                                       throws java.io.IOException
Returns the PermissionStorage object which will be used to to manage the permission data.
Returns:
The PermissionStorage object for the platform.
See Also:
"org.osgi.service.permissionadmin.PermissionAdmin"

getTotalFreeSpace

public long getTotalFreeSpace()
                       throws java.io.IOException
Returns the total amount of free space available for bundle storage on the device.
Returns:
Free space available in bytes or -1 if it does not apply to this platform
Throws:
java.io.IOException - if an I/O error occurs determining the available space

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.