public class StartLevelManager extends Object implements EventDispatcher<Object,Object,org.eclipse.osgi.framework.internal.core.StartLevelEvent>, StartLevel
Modifier and Type | Field and Description |
---|---|
protected static EventManager |
eventManager |
protected int |
initialBundleStartLevel
The initial bundle start level for newly installed bundles
|
protected static Map<Object,Object> |
startLevelListeners |
Modifier | Constructor and Description |
---|---|
protected |
StartLevelManager(Framework framework)
This constructor is called by the Framework
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanup() |
protected void |
decFWSL(int decToSL,
AbstractBundle[] shutdown)
Decrement the active startlevel by one
|
void |
dispatchEvent(Object listener,
Object listenerObject,
int eventAction,
org.eclipse.osgi.framework.internal.core.StartLevelEvent event)
This method is the call back that is called once for each listener.
|
int |
getBundleStartLevel(Bundle bundle)
Return the assigned start level value for the specified Bundle.
|
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.
|
protected void |
incFWSL(int incToSL,
AbstractBundle[] launchBundles)
Increment the active startlevel by one
|
protected void |
initialize() |
boolean |
isBundleActivationPolicyUsed(Bundle bundle)
Returns whether the specified bundle's autostart setting indicates that
the activation policy declared in the bundle's manifest must be used.
|
boolean |
isBundlePersistentlyStarted(Bundle bundle)
Return the persistent state of the specified bundle.
|
protected void |
saveActiveStartLevel(int newSL)
This method is used within the package to save the actual active startlevel value for the framework.
|
protected void |
setBundleSL(org.eclipse.osgi.framework.internal.core.StartLevelEvent startLevelEvent)
Set the bundle's startlevel to the new value
This may cause the bundle to start or stop based on the active framework startlevel
|
void |
setBundleStartLevel(Bundle bundle,
int newSL)
Assign a start level value to the specified Bundle.
|
void |
setInitialBundleStartLevel(int startlevel)
Set the initial start level value that is assigned
to a Bundle when it is first installed.
|
void |
setStartLevel(int newSL)
Modify the active start level of the Framework.
|
void |
setStartLevel(int newSL,
Bundle callerBundle,
FrameworkListener... listeners)
Modify the active start level of the Framework.
|
protected void |
shutdown()
Internal method to shut down the framework synchronously by setting the startlevel to zero
and calling the StartLevelListener worker calls directly
This method does not return until all bundles are stopped and the framework is shut down.
|
protected static EventManager eventManager
protected int initialBundleStartLevel
protected StartLevelManager(Framework framework)
protected void initialize()
protected void cleanup()
public int getInitialBundleStartLevel()
getInitialBundleStartLevel
in interface StartLevel
setInitialBundleStartLevel(int)
public void setInitialBundleStartLevel(int startlevel)
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.
setInitialBundleStartLevel
in interface StartLevel
startlevel
- The initial start level for newly installed bundles.IllegalArgumentException
- If the specified start level is less than or
equal to zero.SecurityException
- if the caller does not have the
AdminPermission and the Java runtime environment supports
permissions.public int getStartLevel()
getStartLevel
in interface StartLevel
public void setStartLevel(int newSL, Bundle callerBundle, FrameworkListener... listeners)
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.
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, starting bundles at each start level which are persistently marked to be started as described in the Bundle.start method. At each intermediate start level value on the way to and including the target start level, the framework must:
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 stopping bundles at each start level as described in the Bundle.stop method except that their persistently recorded state indicates that they must be restarted in the future. At each intermediate start level value on the way to and including the specified start level, the framework must:
If the specified start level is equal to the active start level, then no bundles are started or stopped, however, the Framework must broadcast a Framework event of type FrameworkEvent.STARTLEVEL_CHANGED to announce it has finished moving to the specified start level. This event may arrive before the this method return.
newSL
- The requested start level for the Framework.IllegalArgumentException
- If the specified start level is less than or
equal to zero.SecurityException
- If the caller does not have the
AdminPermission and the Java runtime environment supports
permissions.public void setStartLevel(int newSL)
StartLevel
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.
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:
Bundle.start(int)
method using the
Bundle.START_TRANSIENT
option. The
Bundle.START_ACTIVATION_POLICY
option must also be used if
StartLevel.isBundleActivationPolicyUsed(Bundle)
returns true
for the bundle.
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:
Bundle.stop(int)
method using the Bundle.STOP_TRANSIENT
option.
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 return.
setStartLevel
in interface StartLevel
newSL
- The requested start level for the Framework.protected void shutdown()
protected void saveActiveStartLevel(int newSL)
newSL
- - the new startlevel to savepublic boolean isBundlePersistentlyStarted(Bundle bundle)
This method returns the persistent state of a bundle. The persistent state of a bundle indicates whether a bundle is persistently marked to be started when it's start level is reached.
isBundlePersistentlyStarted
in interface StartLevel
bundle
- The bundle whose autostart setting is to be examined.IllegalArgumentException
- If the specified bundle has been uninstalled.Bundle.START_TRANSIENT
public boolean isBundleActivationPolicyUsed(Bundle bundle)
StartLevel
The autostart setting of a bundle indicates whether the bundle's declared activation policy is to be used when the bundle is started.
isBundleActivationPolicyUsed
in interface StartLevel
bundle
- The bundle whose autostart setting is to be examined.true
if the bundle's autostart setting indicates the
activation policy declared in the manifest must be used.
false
if the bundle must be eagerly activated.Bundle.START_ACTIVATION_POLICY
public int getBundleStartLevel(Bundle bundle)
getBundleStartLevel
in interface StartLevel
bundle
- The target bundle.IllegalArgumentException
- If the specified bundle has been uninstalled.public void setBundleStartLevel(Bundle bundle, int newSL)
The specified bundle will be assigned the specified start level. The start level value assigned to the bundle will be persistently recorded by the Framework. If the new start level for the bundle is lower than or equal to the active start level of the Framework, the Framework will start the specified bundle as described in the Bundle.start method if the bundle is persistently marked to be started. The actual starting of this bundle must occur asynchronously. If the new start level for the bundle is higher than the active start level of the Framework, the Framework will stop the specified bundle as described in the Bundle.stop method except that the persistently recorded state for the bundle indicates that the bundle must be restarted in the future. The actual stopping of this bundle must occur asynchronously.
setBundleStartLevel
in interface StartLevel
bundle
- The target bundle.newSL
- The new start level for the specified Bundle.IllegalArgumentException
- If the specified bundle has been uninstalled or
if the specified start level is less than or equal to zero, or the specified bundle is
the system bundle.SecurityException
- if the caller does not have the
AdminPermission and the Java runtime environment supports
permissions.public void dispatchEvent(Object listener, Object listenerObject, int eventAction, org.eclipse.osgi.framework.internal.core.StartLevelEvent event)
dispatchEvent
in interface EventDispatcher<Object,Object,org.eclipse.osgi.framework.internal.core.StartLevelEvent>
listener
- This listener must be cast to the appropriate listener
class for the events created by this source and the appropriate listener method
must then be called.listenerObject
- This is the optional object that was passed to
EventListeners.addListener when the listener was added to the EventListeners.eventAction
- This value was passed to the ListenerQueue object via one of its
dispatchEvent* method calls. It can provide information (such
as which listener method to call) so that this method
can complete the delivery of the event to the listener.event
- This object was passed to the ListenerQueue object via one of its
dispatchEvent* method calls. This object was created by the event source and
is passed to this method. It should contain all the necessary information (such
as what event object to pass) so that this method
can complete the delivery of the event to the listener.protected void incFWSL(int incToSL, AbstractBundle[] launchBundles)
protected void decFWSL(int decToSL, AbstractBundle[] shutdown)
decToSL
- - the startlevel value to set the framework toprotected void setBundleSL(org.eclipse.osgi.framework.internal.core.StartLevelEvent startLevelEvent)
startLevelEvent
- - the event requesting change in bundle startlevelCopyright © 2007–2018 The Apache Software Foundation. All rights reserved.