org.knopflerfish.framework
Class SystemBundle

java.lang.Object
  extended by org.knopflerfish.framework.BundleImpl
      extended by org.knopflerfish.framework.SystemBundle
All Implemented Interfaces:
Bundle

public class SystemBundle
extends BundleImpl

Implementation of the System Bundle object.

See Also:
Bundle

Field Summary
 
Fields inherited from class org.knopflerfish.framework.BundleImpl
bactivator, bundleContext, bundleDir, lastModified
 
Fields inherited from interface org.osgi.framework.Bundle
ACTIVE, INSTALLED, RESOLVED, STARTING, STOPPING, UNINSTALLED
 
Method Summary
 java.util.Enumeration findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)
          Get bundle data.
 java.net.URL getEntry(java.lang.String name)
          Returns a URL to the specified entry in this bundle.
 java.util.Enumeration getEntryPaths(java.lang.String path)
          Returns an Enumeration of all the paths (String objects) to entries within the bundle whose longest sub-path matches the supplied path argument.
 java.util.Dictionary getHeaders()
          Get header data.
 java.util.Dictionary getHeaders(java.lang.String locale)
          Returns this bundle's Manifest headers and values localized to the specified locale.
 boolean hasPermission(java.lang.Object permission)
          Determine whether the bundle has the requested permission.
protected  void readLocalization(java.lang.String locale, java.util.Hashtable localization_entries, java.lang.String baseName)
          Reads all localization entries that affects this bundle (including its host/fragments)
 void start()
          Start this bundle.
 void stop()
          Stop this bundle.
 void stop(int exitcode)
           
 void uninstall()
          Uninstall this bundle.
 void update(java.io.InputStream in)
          Update this bundle.
 
Methods inherited from class org.knopflerfish.framework.BundleImpl
getBundleContext, getBundleId, getCertificates, getLastModified, getLocation, getRegisteredServices, getResource, getResources, getServicesInUse, getState, getSymbolicName, loadClass, toString, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

hasPermission

public boolean hasPermission(java.lang.Object permission)
Description copied from class: BundleImpl
Determine whether the bundle has the requested permission.

Specified by:
hasPermission in interface Bundle
Overrides:
hasPermission in class BundleImpl
Parameters:
permission - The permission to verify.
Returns:
true if this bundle has the specified permission or the permissions possessed by this bundle imply the specified permission; false if this bundle does not have the specified permission or permission is not an instanceof java.security.Permission.
See Also:
Bundle.hasPermission(java.lang.Object)

start

public void start()
           throws BundleException
Start this bundle.

Specified by:
start in interface Bundle
Overrides:
start in class BundleImpl
Throws:
BundleException - If this bundle could not be started. This could be because a code dependency could not be resolved or the specified BundleActivator could not be loaded or threw an exception.
See Also:
Bundle.start()

stop

public void stop()
          throws BundleException
Stop this bundle.

Specified by:
stop in interface Bundle
Overrides:
stop in class BundleImpl
Throws:
BundleException - If this bundle's BundleActivator could not be loaded or threw an exception.
See Also:
Bundle.stop()

stop

public void stop(int exitcode)
          throws BundleException
Throws:
BundleException

update

public void update(java.io.InputStream in)
            throws BundleException
Update this bundle.

Specified by:
update in interface Bundle
Overrides:
update in class BundleImpl
Parameters:
in - The InputStream from which to read the new bundle.
Throws:
BundleException - If the provided stream cannot be read or the update fails.
See Also:
Bundle.update()

uninstall

public void uninstall()
               throws BundleException
Uninstall this bundle.

Specified by:
uninstall in interface Bundle
Overrides:
uninstall in class BundleImpl
Throws:
BundleException - If the uninstall failed. This can occur if another thread is attempting to change the bundle's state and does not complete in a timely manner.
See Also:
Bundle.uninstall()

getHeaders

public java.util.Dictionary getHeaders()
Get header data. Simulate EXPORT-PACKAGE.

Specified by:
getHeaders in interface Bundle
Overrides:
getHeaders in class BundleImpl
Returns:
A Dictionary object containing this bundle's Manifest headers and values.
See Also:
Bundle.getHeaders()

getHeaders

public java.util.Dictionary getHeaders(java.lang.String locale)
Description copied from interface: Bundle
Returns this bundle's Manifest headers and values localized to the specified locale.

This method performs the same function as Bundle.getHeaders() except the manifest header values are localized to the specified locale.

If a Manifest header value starts with "%", it must be localized according to the specified locale. If a locale is specified and cannot be found, then the header values must be returned using the default locale. Localizations are searched for in the following order:

   bn + "_" + Ls + "_" + Cs + "_" + Vs
   bn + "_" + Ls + "_" + Cs
   bn + "_" + Ls
   bn + "_" + Ld + "_" + Cd + "_" + Vd
   bn + "_" + Ld + "_" + Cd
   bn + "_" + Ld
   bn
 
Where bn is the bundle localization basename, Ls, Cs and Vs are the specified locale (language, country, variant) and Ld, Cd and Vd are the default locale (language, country, variant). If null is specified as the locale string, the header values must be localized using the default locale. If the empty string ("") is specified as the locale string, the header values must not be localized and the raw (unlocalized) header values, including any leading "%", must be returned.

This method must continue to return Manifest header information while this bundle is in the UNINSTALLED state, however the header values must only be available in the raw and default locale values.

Specified by:
getHeaders in interface Bundle
Overrides:
getHeaders in class BundleImpl
Parameters:
locale - The locale name into which the header values are to be localized. If the specified locale is null then the locale returned by java.util.Locale.getDefault is used. If the specified locale is the empty string, this method will return the raw (unlocalized) manifest headers including any leading "%".
Returns:
A Dictionary object containing this bundle's Manifest headers and values.
See Also:
Bundle.getHeaders(String locale)

findEntries

public java.util.Enumeration findEntries(java.lang.String path,
                                         java.lang.String filePattern,
                                         boolean recurse)
Get bundle data. Get resources from bundle or fragment jars.

Specified by:
findEntries in interface Bundle
Overrides:
findEntries in class BundleImpl
Parameters:
path - The path name in which to look. A specified path of "/" indicates the root of the bundle. Path is relative to the root of the bundle and must not be null.
filePattern - The file name pattern for selecting entries in the specified path. The pattern is only matched against the last element of the entry path and it supports substring matching, as specified in the Filter specification, using the wildcard character ("*"). If null is specified, this is equivalent to "*" and matches all files.
recurse - If true, recurse into subdirectories. Otherwise only return entries from the given directory.
Returns:
An enumeration of URL objects for each matching entry, or null if an entry could not be found or if the caller does not have the appropriate AdminPermission[this,RESOURCE], and the Java Runtime Environment supports permissions. The URLs are sorted such that entries from this bundle are returned first followed by the entries from attached fragments in ascending bundle id order. If this bundle is a fragment, then only matching entries in this fragment are returned.
See Also:
Bundle.findEntries(java.lang.String, java.lang.String, boolean)

getEntry

public java.net.URL getEntry(java.lang.String name)
Description copied from interface: Bundle
Returns a URL to the specified entry in this bundle. The bundle's classloader is not used to search for the specified entry. Only the contents of the bundle is searched for the specified entry. A specified path of "/" indicates the root of the bundle.

Specified by:
getEntry in interface Bundle
Overrides:
getEntry in class BundleImpl
Parameters:
name - The name of the entry. See java.lang.ClassLoader.getResource for a description of the format of a resource name.
Returns:
A URL to the specified entry, or null if no entry could be found or if the caller does not have the appropriate AdminPermission[this,RESOURCE] and the Java Runtime Environment supports permissions.

getEntryPaths

public java.util.Enumeration getEntryPaths(java.lang.String path)
Description copied from interface: Bundle
Returns an Enumeration of all the paths (String objects) to entries within the bundle whose longest sub-path matches the supplied path argument. The bundle's classloader is not used to search for entries. Only the contents of the bundle is searched. A specified path of "/" indicates the root of the bundle.

Returned paths indicating subdirectory paths end with a "/". The returned paths are all relative to the root of the bundle.

Specified by:
getEntryPaths in interface Bundle
Overrides:
getEntryPaths in class BundleImpl
Parameters:
path - The path name for which to return entry paths.
Returns:
An Enumeration of the entry paths (String objects) or null if no entry could be found or if the caller does not have the appropriate AdminPermission[this,RESOURCE] and the Java Runtime Environment supports permissions.

readLocalization

protected void readLocalization(java.lang.String locale,
                                java.util.Hashtable localization_entries,
                                java.lang.String baseName)
Reads all localization entries that affects this bundle (including its host/fragments)

Overrides:
readLocalization in class BundleImpl
Parameters:
locale - locale == "" the bundle.properties will be read o/w it will read the files as described in the spec.
localization_entries - will append the new entries to this dictionary
baseName - the basename for localization properties, null will choose OSGi default