Class ModuleContainer

java.lang.Object
org.eclipse.osgi.container.ModuleContainer
All Implemented Interfaces:
EventListener, DebugOptionsListener

public final class ModuleContainer extends Object implements DebugOptionsListener
A container for installing, updating, uninstalling and resolve modules.
Since:
3.10
  • Constructor Details

    • ModuleContainer

      public ModuleContainer(ModuleContainerAdaptor adaptor, ModuleDatabase moduledataBase)
      Constructs a new container with the specified adaptor, module database.
      Parameters:
      adaptor - the adaptor for the container
      moduledataBase - the module database
  • Method Details

    • getAdaptor

      public ModuleContainerAdaptor getAdaptor()
      Returns the adaptor for this container
      Returns:
      the adaptor for this container
    • getModules

      public List<Module> getModules()
      Returns the list of currently installed modules sorted by module id.
      Returns:
      the list of currently installed modules sorted by module id.
    • getModule

      public Module getModule(long id)
      Returns the module installed with the specified id, or null if no such module is installed.
      Parameters:
      id - the id of the module
      Returns:
      the module with the specified id, or null of no such module is installed.
    • getModule

      public Module getModule(String location)
      Returns the module installed with the specified location, or null if no such module is installed.
      Parameters:
      location - the location of the module
      Returns:
      the module with the specified location, or null of no such module is installed.
    • createRequirement

      public static Requirement createRequirement(String namespace, Map<String,String> directives, Map<String,?> attributes)
      Creates a synthetic requirement that is not associated with any module revision. This is useful for calling FrameworkWiring.findProviders(Requirement).
      Parameters:
      namespace - the requirement namespace
      directives - the requirement directives
      attributes - the requirement attributes
      Returns:
      a synthetic requirement
    • toString

      public static String toString(Capability capability)
      Generates a human readable string representation of the the given capability, mapping the namespace to well-known header names.
      Parameters:
      capability - the Capability for which a string representation is desired
      Since:
      3.19
    • toString

      public static String toString(Requirement requirement)
      Generates a human readable string representation of the the given requirement, mapping the namespace to well-known header names.
      Parameters:
      requirement - the Requirement for which a string representation is desired
      Since:
      3.19
    • install

      public Module install(Module origin, String location, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException
      Installs a new module using the specified location. The specified builder is used to create a new revision which will become the current revision of the new module.

      If a module already exists with the specified location then the existing module is returned and the builder is not used.

      Parameters:
      origin - the module performing the install, may be null.
      location - The location identifier of the module to install.
      builder - the builder used to create the revision to install.
      revisionInfo - the revision info for the new revision, may be null.
      Returns:
      a new module or a existing module if one exists at the specified location.
      Throws:
      BundleException - if some error occurs installing the module
    • update

      public void update(Module module, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException
      Updates the specified module with a new revision. The specified builder is used to create a new revision which will become the current revision of the new module.
      Parameters:
      module - the module to update
      builder - the builder used to create the revision for the update.
      revisionInfo - the revision info for the new revision, may be null.
      Throws:
      BundleException - if some error occurs updating the module
    • uninstall

      public void uninstall(Module module) throws BundleException
      Uninstalls the specified module.
      Parameters:
      module - the module to uninstall
      Throws:
      BundleException - if some error occurs uninstalling the module
    • getFrameworkWiring

      public FrameworkWiring getFrameworkWiring()
      Returns the FrameworkWiring for this container
      Returns:
      the framework wiring for this container.
    • getFrameworkStartLevel

      public FrameworkStartLevel getFrameworkStartLevel()
      Returns the FrameworkStartLevel for this container
      Returns:
      the framework start level for this container
    • resolve

      public ResolutionReport resolve(Collection<Module> triggers, boolean triggersMandatory)
      Attempts to resolve the current revisions of the specified modules.
      Parameters:
      triggers - the modules to resolve or null to resolve all unresolved current revisions.
      triggersMandatory - true if the triggers must be resolved. This will result in a ResolutionException if set to true and one of the triggers could not be resolved.
      Returns:
      A resolution report for the resolve operation
      See Also:
    • resolveDynamic

      public ModuleWire resolveDynamic(String dynamicPkgName, ModuleRevision revision)
      Attempts to resolve the specified dynamic package name request for the specified revision.
      Parameters:
      dynamicPkgName - the package name to attempt a dynamic resolution for
      revision - the module revision the dynamic resolution request is for
      Returns:
      the new resolution wire establishing a dynamic package resolution or null if a dynamic wire could not be established.
    • refresh

      public ResolutionReport refresh(Collection<Module> initial)
      Refreshes the specified collection of modules.
      Parameters:
      initial - the modules to refresh or null to refresh the removal pending.
      Returns:
      a resolution report for the resolve operation that may have occurred during the refresh operation.
      See Also:
    • getDependencyClosure

      public Collection<Module> getDependencyClosure(Collection<Module> initial)
      Returns the dependency closure of for the specified modules.
      Parameters:
      initial - The initial modules for which to generate the dependency closure
      Returns:
      A collection containing a snapshot of the dependency closure of the specified modules, or an empty collection if there were no specified modules.
    • getRemovalPending

      public Collection<ModuleRevision> getRemovalPending()
      Returns the revisions that have non-current, in use module wirings.
      Returns:
      A collection containing a snapshot of the revisions which have non-current, in use ModuleWirings, or an empty collection if there are no such revisions.
    • getStartLevel

      public int getStartLevel()
      Return the active start level value of this container. If the container is in the process of changing the start level this method must return the active start level if this differs from the requested start level.
      Returns:
      The active start level value of the Framework.
    • setInitialModuleStates

      public void setInitialModuleStates() throws BundleException
      Sets all the module states uninstalled except for the system module.
      Throws:
      BundleException
    • optionsChanged

      public void optionsChanged(DebugOptions options)
      Description copied from interface: DebugOptionsListener
      Notifies this listener that an option-path for its plug-in has changed. This method is also called initially by the DebugOptions implementation when the listener is registered as a service. This allows the listener to obtain the initial set of debug options without the need to acquire the debug options service.
      Specified by:
      optionsChanged in interface DebugOptionsListener
      Parameters:
      options - a reference to the DebugOptions
    • store

      public void store(DataOutputStream stream, boolean persistWirings) throws IOException
      Writes the data for this container in a format suitable for using the ModuleDatabase.load(DataInputStream) method.
      Parameters:
      stream - the stream to use
      persistWirings - true if wirings should be persisted
      Throws:
      IOException - if there is any problem storing to the stream
      Since:
      3.19
      See Also: