Package aQute.lib.startlevel
Class StartLevelRuntimeHandler
java.lang.Object
aQute.lib.startlevel.StartLevelRuntimeHandler
- All Implemented Interfaces:
Closeable
,AutoCloseable
Support to handle start levels in a launcher. This code is related to code in
the Project Launcher. It is in aQute.lib so it can be included easily in the
Launcher, the Remote launcher, and Launchpad.
This class is not threadsafe!
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StartLevelRuntimeHandler
absent()
void
Called after the framework is started and the launcher is readyvoid
beforeStart
(org.osgi.framework.launch.Framework systemBundle) Must be called before the framework is started.void
close()
Close this objectstatic StartLevelRuntimeHandler
Create a start level handler.static StartLevelRuntimeHandler
create
(Trace reporter, Properties properties) int
getBundleStartLevel
(org.osgi.framework.Bundle bundle) Get a bundle's start levelint
getFrameworkStartLevel
(org.osgi.framework.launch.Framework framework) Answer the current framework start levelboolean
Indicate if this class supports start levels or not.void
setBundleStartLevel
(org.osgi.framework.Bundle bundle, int startlevel) Set a bundle's start levelvoid
setDefaultStartlevel
(org.osgi.framework.launch.Framework framework, int level) Set the default start level of newly installed bundlesint
setFrameworkStartLevel
(org.osgi.framework.launch.Framework framework, int startlevel, org.osgi.framework.FrameworkListener... ls) Set the framework start level and return previousvoid
setStartLevel
(org.osgi.framework.Bundle b) Set the start level of a bundlevoid
sync()
Wait for the framework to reach its start level.(package private) static int
void
updateConfiguration
(Map<String, ?> configuration) When the configuration properties have been updated
-
Field Details
-
LAUNCH_STARTLEVEL_DEFAULT
If this property is set we take on start levels, if this property is not set we ignore the startlevels completely. This is defined in aQute.bnd.osgi.Constants -
LAUNCH_RUNBUNDLES_ATTRS
-
-
Constructor Details
-
StartLevelRuntimeHandler
public StartLevelRuntimeHandler()
-
-
Method Details
-
hasStartLevels
public boolean hasStartLevels()Indicate if this class supports start levels or not.- Returns:
- true if this class supports startlevels
-
setStartLevel
public void setStartLevel(org.osgi.framework.Bundle b) Set the start level of a bundle- Parameters:
b
- the bundle
-
getFrameworkStartLevel
public int getFrameworkStartLevel(org.osgi.framework.launch.Framework framework) Answer the current framework start level- Parameters:
framework
- the framework- Returns:
- the current start level of the framework
-
setDefaultStartlevel
public void setDefaultStartlevel(org.osgi.framework.launch.Framework framework, int level) Set the default start level of newly installed bundles- Parameters:
framework
- the frameworklevel
- the default start level
-
setFrameworkStartLevel
public int setFrameworkStartLevel(org.osgi.framework.launch.Framework framework, int startlevel, org.osgi.framework.FrameworkListener... ls) Set the framework start level and return previous- Parameters:
framework
- the frameworkstartlevel
- the start level to setls
- listeners- Returns:
- the previous start level of the framework
-
getBundleStartLevel
public int getBundleStartLevel(org.osgi.framework.Bundle bundle) Get a bundle's start level- Parameters:
bundle
- the bundle to query- Returns:
- the start level > 0
-
setBundleStartLevel
public void setBundleStartLevel(org.osgi.framework.Bundle bundle, int startlevel) Set a bundle's start level- Parameters:
bundle
- the bundle to querystartlevel
- start level to set, > 0
-
beforeStart
public void beforeStart(org.osgi.framework.launch.Framework systemBundle) Must be called before the framework is started.ensure systemBundle.getState() == INIT and startlevel systemBundle == 0
- Parameters:
systemBundle
- the framework
-
updateConfiguration
When the configuration properties have been updated- Parameters:
configuration
- the configuration properties
-
afterStart
public void afterStart()Called after the framework is started and the launcher is ready -
sync
public void sync()Wait for the framework to reach its start level. Must be called after theafterStart()
method. Will return when the framework has traversed all start levels. -
close
public void close()Close this object- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
create
Create a start level handler. If theLAUNCH_STARTLEVEL_DEFAULT
property is set we create an active handler that will direct the framework properly according to the settings in Project Launcher. If not set, a dummy is returned that does not do anything- Parameters:
outerConfiguration
- the properties as set by the Project Launcher- Returns:
- an active or dummy
StartLevelRuntimeHandler
-
toInt
-
absent
-
create
-