Package aQute.lib.startlevel
Class StartLevelRuntimeHandler
- java.lang.Object
-
- aQute.lib.startlevel.StartLevelRuntimeHandler
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class StartLevelRuntimeHandler extends java.lang.Object implements java.io.Closeable
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 Modifier and Type Field Description static java.lang.String
LAUNCH_RUNBUNDLES_ATTRS
static java.lang.String
LAUNCH_STARTLEVEL_DEFAULT
If this property is set we take on start levels, if this property is not set we ignore the startlevels completely.
-
Constructor Summary
Constructors Constructor Description StartLevelRuntimeHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StartLevelRuntimeHandler
absent()
void
afterStart()
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(Trace logger, java.util.Map<java.lang.String,java.lang.String> outerConfiguration)
Create a start level handler.static StartLevelRuntimeHandler
create(Trace reporter, java.util.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
hasStartLevels()
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
toInt(java.lang.Object object, int defltValue)
void
updateConfiguration(java.util.Map<java.lang.String,?> configuration)
When the configuration properties have been updated
-
-
-
Field Detail
-
LAUNCH_STARTLEVEL_DEFAULT
public static java.lang.String 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
public static java.lang.String LAUNCH_RUNBUNDLES_ATTRS
-
-
Method Detail
-
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
public void updateConfiguration(java.util.Map<java.lang.String,?> configuration)
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
create
public static StartLevelRuntimeHandler create(Trace logger, java.util.Map<java.lang.String,java.lang.String> outerConfiguration)
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
static int toInt(java.lang.Object object, int defltValue)
-
absent
public static StartLevelRuntimeHandler absent()
-
create
public static StartLevelRuntimeHandler create(Trace reporter, java.util.Properties properties)
-
-