Class Module

java.lang.Object
org.eclipse.osgi.container.Module
All Implemented Interfaces:
Comparable<Module>, BundleReference, BundleStartLevel
Direct Known Subclasses:
SystemModule

public abstract class Module extends Object implements BundleReference, BundleStartLevel, Comparable<Module>
A module represents a set of revisions installed in a module container.
Since:
3.10
  • Field Details

  • Constructor Details

    • Module

      public Module(Long id, String location, ModuleContainer container, EnumSet<Module.Settings> settings, int startlevel)
      Constructs a new module with the specified id, location and container.
      Parameters:
      id - the new module id
      location - the new module location
      container - the container for the new module
      settings - the persisted settings. May be null if there are no settings.
      startlevel - the persisted start level or initial start level.
  • Method Details

    • getId

      public final Long getId()
      Returns the module id.
      Returns:
      the module id.
    • getLocation

      public final String getLocation()
      Returns the module location
      Returns:
      the module location
    • getRevisions

      public final ModuleRevisions getRevisions()
      Returns the ModuleRevisions associated with this module.
      Returns:
      the ModuleRevisions associated with this module
    • getContainer

      public final ModuleContainer getContainer()
      Returns the module container this module is contained in.
      Returns:
      the module container.
    • getCurrentRevision

      public final ModuleRevision getCurrentRevision()
      Returns the current revision associated with this module. If the module is uninstalled then the last current revision is returned.
      Returns:
      the current revision associated with this module.
    • getState

      public final Module.State getState()
      Returns the current state of this module.
      Returns:
      the current state of this module.
    • getStartLevel

      public final int getStartLevel()
      Specified by:
      getStartLevel in interface BundleStartLevel
    • setStartLevel

      public final void setStartLevel(int startLevel)
      Specified by:
      setStartLevel in interface BundleStartLevel
    • isPersistentlyStarted

      public final boolean isPersistentlyStarted()
      Specified by:
      isPersistentlyStarted in interface BundleStartLevel
    • isActivationPolicyUsed

      public final boolean isActivationPolicyUsed()
      Specified by:
      isActivationPolicyUsed in interface BundleStartLevel
    • getLastModified

      public final long getLastModified()
      Returns the time when this module was last modified. A module is considered to be modified when it is installed, updated or uninstalled.

      The time value is a the number of milliseconds since January 1, 1970, 00:00:00 UTC.

      Returns:
      the time when this bundle was last modified.
    • lockStateChange

      protected final void lockStateChange(ModuleContainerAdaptor.ModuleEvent transitionEvent) throws BundleException
      Acquires the module lock for state changes by the current thread for the specified transition event. Certain transition events locks may be nested within other transition event locks. For example, a resolved transition event lock may be nested within a started transition event lock. A stopped transition lock may be nested within an updated, unresolved or uninstalled transition lock.
      Parameters:
      transitionEvent - the transition event to acquire the lock for.
      Throws:
      BundleException
    • unlockStateChange

      protected final void unlockStateChange(ModuleContainerAdaptor.ModuleEvent transitionEvent)
      Releases the lock for state changes for the specified transition event.
    • holdsTransitionEventLock

      public final boolean holdsTransitionEventLock(ModuleContainerAdaptor.ModuleEvent transitionEvent)
      Returns true if the current thread holds the state change lock for the specified transition event.
      Returns:
      true if the current thread holds the state change lock for the specified transition event.
    • getStateChangeOwner

      public final Thread getStateChangeOwner()
      Returns the thread that currently owns the state change lock for this module, or null if not owned.
      Returns:
      the owner, or null if not owned.
    • start

      public void start(Module.StartOptions... options) throws BundleException
      Starts this module
      Parameters:
      options - the options for starting
      Throws:
      BundleException - if an errors occurs while starting
    • stop

      public void stop(Module.StopOptions... options) throws BundleException
      Stops this module.
      Parameters:
      options - options for stopping
      Throws:
      BundleException - if an error occurs while stopping
    • compareTo

      public final int compareTo(Module o)
      Specified by:
      compareTo in interface Comparable<Module>
    • startWorker

      protected void startWorker() throws BundleException
      Performs any work associated with starting a module. For example, loading and calling start on an activator.
      Throws:
      BundleException - if there was an exception starting the module
    • stopWorker

      protected void stopWorker() throws BundleException
      Performs any work associated with stopping a module. For example, calling stop on an activator.
      Throws:
      BundleException - if there was an exception stopping the module
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setParallelActivation

      public void setParallelActivation(boolean parallelActivation)
      Set if this module should be activated in parallel with other modules that have the same start level.
      Parameters:
      parallelActivation - true if the module should be started in parallel; false otherwise
      Since:
      3.15
    • isParallelActivated

      public boolean isParallelActivated()
      Returns if this module should be activated in parallel with other modules that have the same start level.
      Returns:
      true if the module should be started in parallel; false otherwise
      Since:
      3.15
    • cleanup

      protected abstract void cleanup(ModuleRevision revision)
      The container is done with the revision and it has been completely removed. This method allows the resources behind the revision to be cleaned up.
      Parameters:
      revision - the revision to clean up