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.CloseableSupport 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.StringLAUNCH_RUNBUNDLES_ATTRSstatic java.lang.StringLAUNCH_STARTLEVEL_DEFAULTIf 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 StartLevelRuntimeHandlerabsent()voidafterStart()Called after the framework is started and the launcher is readyvoidbeforeStart(org.osgi.framework.launch.Framework systemBundle)Must be called before the framework is started.voidclose()Close this objectstatic StartLevelRuntimeHandlercreate(Trace logger, java.util.Map<java.lang.String,java.lang.String> outerConfiguration)Create a start level handler.static StartLevelRuntimeHandlercreate(Trace reporter, java.util.Properties properties)intgetBundleStartLevel(org.osgi.framework.Bundle bundle)Get a bundle's start levelintgetFrameworkStartLevel(org.osgi.framework.launch.Framework framework)Answer the current framework start levelbooleanhasStartLevels()Indicate if this class supports start levels or not.voidsetBundleStartLevel(org.osgi.framework.Bundle bundle, int startlevel)Set a bundle's start levelvoidsetDefaultStartlevel(org.osgi.framework.launch.Framework framework, int level)Set the default start level of newly installed bundlesintsetFrameworkStartLevel(org.osgi.framework.launch.Framework framework, int startlevel, org.osgi.framework.FrameworkListener... ls)Set the framework start level and return previousvoidsetStartLevel(org.osgi.framework.Bundle b)Set the start level of a bundlevoidsync()Wait for the framework to reach its start level.(package private) static inttoInt(java.lang.Object object, int defltValue)voidupdateConfiguration(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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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_DEFAULTproperty 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)
-
-