org.eclipse.osgi.framework.internal.core
Class SystemBundle

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.AbstractBundle
      extended by org.eclipse.osgi.framework.internal.core.BundleHost
          extended by org.eclipse.osgi.framework.internal.core.SystemBundle
All Implemented Interfaces:
java.lang.Comparable, KeyedElement, Bundle

public class SystemBundle
extends BundleHost

This class subclasses Bundle to provide a system Bundle so that the framework can be represented as a bundle and can access the services provided by other bundles.


Field Summary
 
Fields inherited from class org.eclipse.osgi.framework.internal.core.BundleHost
context, fragments
 
Fields inherited from class org.eclipse.osgi.framework.internal.core.AbstractBundle
bundledata, domain, framework, manifestLocalization, state, statechangeLock, stateChanging
 
Fields inherited from interface org.osgi.framework.Bundle
ACTIVE, INSTALLED, RESOLVED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED
 
Constructor Summary
protected SystemBundle(Framework framework)
          Private SystemBundle object constructor.
 
Method Summary
protected  void close()
          Close the the Bundle's file.
 java.net.URL getResource(java.lang.String name)
          Find the specified resource in this bundle.
 boolean hasPermission(java.lang.Object permission)
          Determine whether the bundle has the requested permission.
protected  boolean isUnresolved()
          Indicate SystemBundle is resolved.
protected  void load()
          Load the bundle.
protected  java.lang.Class loadClass(java.lang.String name, boolean checkPermission)
          This method loads a class from the bundle.
protected  void refresh()
          Refresh the bundle.
protected  boolean reload(AbstractBundle newBundle)
          Reload from a new bundle.
protected  void resume()
          Start the SystemBundle.
 void start()
          Start this bundle.
 void stop()
          Stop the framework.
protected  void suspend()
          Stop the SystemBundle.
protected  void suspend(boolean lock)
          Stop this bundle w/o marking is persistently stopped.
 void uninstall()
          Uninstall this bundle.
protected  boolean unload()
          Unload the bundle.
protected  void unresolvePermissions(AbstractBundle[] refreshedBundles)
          No work to do for the SystemBundle.
 void update()
          Update this bundle.
 void update(java.io.InputStream in)
          Update this bundle from an InputStream.
 
Methods inherited from class org.eclipse.osgi.framework.internal.core.BundleHost
attachFragment, createContext, getBundleLoader, getContext, getFragments, getLoaderProxy, getRegisteredServices, getResources, getServicesInUse, readyToResume, startWorker, stopWorker
 
Methods inherited from class org.eclipse.osgi.framework.internal.core.AbstractBundle
beginStateChange, checkValid, compare, compareTo, completeStateChange, createBundle, findEntries, findLocalEntryPaths, getBundleContext, getBundleData, getBundleDescription, getBundleId, getEntry, getEntryPaths, getHeaders, getHeaders, getHosts, getKey, getKeyHashCode, getLastModified, getLocation, getProtectionDomain, getResolutionFailureMessage, getResourceBundle, getStartLevel, getState, getStateChanging, getSymbolicName, getVersion, isActive, isFragment, isResolved, loadBundleActivator, loadClass, resolve, setStatus, start, stop, testStateChanging, toString, uninstallWorker, uninstallWorkerPrivileged, unresolvePermissions, updateWorker, updateWorkerPrivileged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SystemBundle

protected SystemBundle(Framework framework)
                throws BundleException
Private SystemBundle object constructor. This method creates the SystemBundle and its BundleContext. The SystemBundle's state is set to STARTING. This method is called when the framework is constructed.

Parameters:
framework - Framework this bundle is running in
Throws:
BundleException
Method Detail

load

protected void load()
Load the bundle. This methods overrides the Bundle method and does nothing.

Overrides:
load in class BundleHost

reload

protected boolean reload(AbstractBundle newBundle)
Reload from a new bundle. This methods overrides the Bundle method and does nothing.

Overrides:
reload in class BundleHost
Parameters:
newBundle -
Returns:
false

refresh

protected void refresh()
Refresh the bundle. This methods overrides the Bundle method and does nothing.

Overrides:
refresh in class BundleHost

unload

protected boolean unload()
Unload the bundle. This methods overrides the Bundle method and does nothing.

Overrides:
unload in class BundleHost
Returns:
false

close

protected void close()
Close the the Bundle's file. This method closes the BundleContext for the SystemBundle and sets the SystemBundle's state to UNINSTALLED.

Overrides:
close in class AbstractBundle

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean checkPermission)
                             throws java.lang.ClassNotFoundException
This method loads a class from the bundle.

Overrides:
loadClass in class BundleHost
Parameters:
name - the name of the desired Class.
checkPermission - indicates whether a permission check should be done.
Returns:
the resulting Class
Throws:
java.lang.ClassNotFoundException - if the class definition was not found.

getResource

public java.net.URL getResource(java.lang.String name)
Find the specified resource in this bundle. This methods returns null for the system bundle.

Specified by:
getResource in interface Bundle
Overrides:
getResource in class BundleHost
Parameters:
name - The name of the resource. See java.lang.ClassLoader.getResource for a description of the format of a resource name.
Returns:
a URL to the named resource, or null if the resource could not be found or if the caller does not have the AdminPermission, and the Java Runtime Environment supports permissions.
See Also:
Bundle.getEntry(java.lang.String), Bundle.findEntries(java.lang.String, java.lang.String, boolean)

isUnresolved

protected boolean isUnresolved()
Indicate SystemBundle is resolved.


start

public void start()
Start this bundle. This methods overrides the Bundle method and does nothing.

Specified by:
start in interface Bundle
Overrides:
start in class AbstractBundle
See Also:
Bundle.start(int)

resume

protected void resume()
Start the SystemBundle. This method launches the framework.

Overrides:
resume in class AbstractBundle

stop

public void stop()
Stop the framework. This method spawns a thread which will call framework.shutdown.

Specified by:
stop in interface Bundle
Overrides:
stop in class AbstractBundle
See Also:
Bundle.start(int)

suspend

protected void suspend()
Stop the SystemBundle. This method shuts down the framework.


suspend

protected void suspend(boolean lock)
Description copied from class: AbstractBundle
Stop this bundle w/o marking is persistently stopped. Any services registered by this bundle will be unregistered. Any services used by this bundle will be released. Any listeners registered by this bundle will be removed.

The following steps are followed to stop a bundle:

  1. If the bundle is Bundle.UNINSTALLEDthen an IllegalStateException is thrown.
  2. If the bundle is Bundle.STOPPING,Bundle.RESOLVED, or Bundle.INSTALLEDthen this method returns immediately.
  3. If the bundle is Bundle.STARTINGthen this method may wait for the bundle to reach the Bundle.ACTIVEstate before continuing. If this does not occur in a reasonable time, a BundleExceptionis thrown to indicate the bundle was unable to be stopped.
  4. The state of the bundle is set to Bundle.STOPPING.
  5. The stopmethod of the bundle's BundleActivator, if one is specified, is called. If the BundleActivatorthrows an exception, this method will continue to stop the bundle. A BundleExceptionwill be thrown after completion of the remaining steps.
  6. The bundle's listeners, if any, are removed, service's registered by the bundle, if any, are unregistered, and service's used by the bundle, if any, are released.
  7. The state of the bundle is set to Bundle.RESOLVED.
  8. A BundleEventof type BundleEvent.STOPPEDis broadcast.
Preconditons
Postconditons, no exceptions thrown
Postconditions, when an exception is thrown

Overrides:
suspend in class AbstractBundle
Parameters:
lock - true if state change lock should be held when returning from this method.

update

public void update()
Update this bundle. This method spawns a thread which will call framework.shutdown followed by framework.launch.

Specified by:
update in interface Bundle
Overrides:
update in class AbstractBundle
See Also:
AbstractBundle.stop(), AbstractBundle.start()

update

public void update(java.io.InputStream in)
Update this bundle from an InputStream. This methods overrides the Bundle method and does nothing.

Specified by:
update in interface Bundle
Overrides:
update in class AbstractBundle
Parameters:
in - The InputStream from which to read the new bundle.
See Also:
AbstractBundle.update()

uninstall

public void uninstall()
               throws BundleException
Uninstall this bundle. This methods overrides the Bundle method and throws an exception.

Specified by:
uninstall in interface Bundle
Overrides:
uninstall in class AbstractBundle
Throws:
BundleException - If the uninstall failed.
See Also:
AbstractBundle.stop()

hasPermission

public boolean hasPermission(java.lang.Object permission)
Determine whether the bundle has the requested permission. This methods overrides the Bundle method and returns true.

Specified by:
hasPermission in interface Bundle
Overrides:
hasPermission in class AbstractBundle
Parameters:
permission - The requested permission.
Returns:
true

unresolvePermissions

protected void unresolvePermissions(AbstractBundle[] refreshedBundles)
No work to do for the SystemBundle.

Parameters:
refreshedBundles - A list of bundles which have been refreshed as a result of a packageRefresh