OSGi™ Core
Release 5

org.osgi.framework.startlevel
Interface FrameworkStartLevel

All Superinterfaces:
BundleReference

public interface FrameworkStartLevel
extends BundleReference

Query and modify the start level information for the framework. The start level object for the framework can be obtained by calling bundle.adapt(FrameworkStartLevel.class) on the system bundle. Only the system bundle can be adapted to a FrameworkStartLevel object.

The system bundle associated with this FrameworkStartLevel object can be obtained by calling BundleReference.getBundle().

ThreadSafe
Consumers of this API must not implement this interface

Method Summary
 int getInitialBundleStartLevel()
          Return the initial start level value that is assigned to a Bundle when it is first installed.
 int getStartLevel()
          Return the active start level value of the Framework.
 void setInitialBundleStartLevel(int startlevel)
          Set the initial start level value that is assigned to a Bundle when it is first installed.
 void setStartLevel(int startlevel, FrameworkListener... listeners)
          Modify the active start level of the Framework and notify when complete.
 
Methods inherited from interface org.osgi.framework.BundleReference
getBundle
 

Method Detail

getStartLevel

int getStartLevel()
Return the active start level value of the Framework. If the Framework is in the process of changing the start level this method must return the active start level if this differs from the requested start level.

Returns:
The active start level value of the Framework.

setStartLevel

void setStartLevel(int startlevel,
                   FrameworkListener... listeners)
Modify the active start level of the Framework and notify when complete.

The Framework will move to the requested start level. This method will return immediately to the caller and the start level change will occur asynchronously on another thread. The specified FrameworkListener s are notified, in the order specified, when the start level change is complete. When the start level change completes normally, each specified FrameworkListener will be called with a Framework event of type FrameworkEvent.STARTLEVEL_CHANGED. If the start level change does not complete normally, each specified FrameworkListener will be called with a Framework event of type FrameworkEvent.ERROR.

If the specified start level is higher than the active start level, the Framework will continue to increase the start level until the Framework has reached the specified start level. At each intermediate start level value on the way to and including the target start level, the Framework must:

  1. Change the active start level to the intermediate start level value.
  2. Start bundles at the intermediate start level whose autostart setting indicate they must be started. They are started as described in the Bundle.start(int) method using the Bundle.START_TRANSIENT option. The Bundle.START_ACTIVATION_POLICY option must also be used if BundleStartLevel.isActivationPolicyUsed() returns true for the bundle.
When this process completes after the specified start level is reached, the Framework will fire a Framework event of type FrameworkEvent.STARTLEVEL_CHANGED to announce it has moved to the specified start level.

If the specified start level is lower than the active start level, the Framework will continue to decrease the start level until the Framework has reached the specified start level. At each intermediate start level value on the way to and including the specified start level, the framework must:

  1. Stop bundles at the intermediate start level as described in the Bundle.stop(int) method using the Bundle.STOP_TRANSIENT option.
  2. Change the active start level to the intermediate start level value.
When this process completes after the specified start level is reached, the Framework will fire a Framework event of type FrameworkEvent.STARTLEVEL_CHANGED to announce it has moved to the specified start level.

If the specified start level is equal to the active start level, then no bundles are started or stopped, however, the Framework must fire a Framework event of type FrameworkEvent.STARTLEVEL_CHANGED to announce it has finished moving to the specified start level. This event may arrive before this method returns.

Parameters:
startlevel - The requested start level for the Framework.
listeners - Zero or more listeners to be notified when the start level change has been completed. The specified listeners do not need to be otherwise registered with the framework. If a specified listener is already registered with the framework, it will be notified twice.
Throws:
java.lang.IllegalArgumentException - If the specified start level is less than or equal to zero.
java.lang.SecurityException - If the caller does not have AdminPermission[System Bundle,STARTLEVEL] and the Java runtime environment supports permissions.

getInitialBundleStartLevel

int getInitialBundleStartLevel()
Return the initial start level value that is assigned to a Bundle when it is first installed.

Returns:
The initial start level value for Bundles.
See Also:
setInitialBundleStartLevel(int)

setInitialBundleStartLevel

void setInitialBundleStartLevel(int startlevel)
Set the initial start level value that is assigned to a Bundle when it is first installed.

The initial bundle start level will be set to the specified start level. The initial bundle start level value will be persistently recorded by the Framework.

When a Bundle is installed via BundleContext.installBundle, it is assigned the initial bundle start level value.

The default initial bundle start level value is 1 unless this method has been called to assign a different initial bundle start level value.

This method does not change the start level values of installed bundles.

Parameters:
startlevel - The initial start level for newly installed bundles.
Throws:
java.lang.IllegalArgumentException - If the specified start level is less than or equal to zero.
java.lang.SecurityException - If the caller does not have AdminPermission[System Bundle,STARTLEVEL] and the Java runtime environment supports permissions.

OSGi™ Core
Release 5

Copyright © OSGi Alliance (2000, 2012). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0