Service Management Framework
Release 3.1

com.ibm.osg.smf.platform
Class DefaultPlatform

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

public class DefaultPlatform
extends java.lang.Object
implements Platform

A default Platform class for SMF. This class is used to provide platform specific support for SMF in an environment which supports a file system. The file system must support long file names.


Constructor Summary
DefaultPlatform(java.lang.String[] args)
          Constructor for DefaultPlatform.
 
Method Summary
 void compactStorage()
          Clean up 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 for the 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.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPlatform

public DefaultPlatform(java.lang.String[] args)
Constructor for DefaultPlatform. This constructor parses the arguments passed and remembers them for later when initialize is called.

No blank spaces should be used in the arguments to the DefaultPlatform. The options that DefaultPlatform recognizes and handles are:

Any other arguments are ignored.
Parameters:
An - array of strings containing arguments. This object cannot be used until initialize is called.
Method Detail

initialize

public void initialize(Framework framework)
Initialize 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.

getProperties

public java.util.Properties getProperties()
Return the properties object for the platform. The framework may modify this object.
Specified by:
getProperties in interface Platform
Returns:
The properties object for the platform. The properties object contains the properties from the smf.properties file.

initializeStorage

public void initializeStorage()
                       throws java.io.IOException
Initialize the persistent storage.

This method initializes the bundle persistent storage area. If a dir was specified in the -platform command line option, then it is used. If not, if the property com.ibm.osg.smf.bundledir is specifed, its value will be used as the name of the bundle directory instead of ./bundles. If reset was specified on the -platform command line option, then the storage will be cleared.

Specified by:
initializeStorage in interface Platform
Throws:
java.io.IOException - If an error occurs initializing the storage.

compactStorage

public void compactStorage()
Clean up the persistent storage.

Cleans up any deferred deletions in persistent storage.

Specified by:
compactStorage in interface Platform

mapLocationToURLConnection

public java.net.URLConnection mapLocationToURLConnection(java.lang.String location)
                                                  throws org.osgi.framework.BundleException
Map a location to a URLConnection.

This methods treats the location string as a URL.

Specified by:
mapLocationToURLConnection in interface Platform
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.
Specified by:
getInstalledBundles in interface Platform
Returns:
Vector of installed Bundles.

getStatus

public int getStatus(org.osgi.framework.Bundle bundle)
Get the status data for a bundle.
Specified by:
getStatus in interface Platform
Parameters:
bundle - Bundle to retrieve status for.
Returns:
Bundle's status.

setStatus

public void setStatus(org.osgi.framework.Bundle bundle,
                      int status)
               throws org.osgi.framework.BundleException
Set the status data for a bundle.
Specified by:
setStatus in interface Platform
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.
Specified by:
getMetadata in interface Platform
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.
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.

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.

Specified by:
installBundle in interface Platform
Parameters:
location - Bundle location.
source - URLConnection from which the bundle may be read.
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.

Specified by:
updateBundle in interface Platform
Parameters:
bundle - Bundle to update.
source - URLConnection from which the bundle may be read.
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.

Specified by:
uninstallBundle in interface Platform
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.

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.

Specified by:
getDataFile in interface Platform
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 the bundle.
Specified by:
findLibrary in interface Platform
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.

The PermissionStorage object will store permission data in the "permdata" subdirectory of the bundle storage directory assigned by initializeStorage.

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

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
Returns:
an int containing free space 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.