Class StartLevelRuntimeHandler

java.lang.Object
aQute.lib.startlevel.StartLevelRuntimeHandler
All Implemented Interfaces:
Closeable, AutoCloseable

public class StartLevelRuntimeHandler extends Object implements 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 Details

    • LAUNCH_STARTLEVEL_DEFAULT

      public static 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 String 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 framework
      level - 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 framework
      startlevel - the start level to set
      ls - 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 query
      startlevel - 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(Map<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 the afterStart() method. Will return when the framework has traversed all start levels.
    • close

      public void close()
      Close this object
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • create

      public static StartLevelRuntimeHandler create(Trace logger, Map<String,String> outerConfiguration)
      Create a start level handler. If the LAUNCH_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(Object object, int defltValue)
    • absent

      public static StartLevelRuntimeHandler absent()
    • create

      public static StartLevelRuntimeHandler create(Trace reporter, Properties properties)