Class RunResolution

java.lang.Object
biz.aQute.resolve.RunResolution

public class RunResolution extends Object
Provides a simple way to resolve a project or bndrun file with support for the BndEditModel. Static methods are used to resolve and then this class holds the different aspects of the result. Either with an exception or the required and optional wiring.

The resolution also then provides convenience methods to link it to the projects

  • Field Details

    • project

      public final aQute.bnd.build.Project project
    • properties

      public final aQute.bnd.osgi.Processor properties
    • required

      public final Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> required
    • optional

      public final Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> optional
    • exception

      public final Exception exception
    • log

      public final String log
    • runstartlevel

      public final aQute.bnd.help.instructions.ResolutionInstructions.RunStartLevel runstartlevel
  • Method Details

    • resolve

      public static RunResolution resolve(aQute.bnd.build.Project project, aQute.bnd.osgi.Processor actualProperties, Collection<ResolutionCallback> callbacks)
      The main workhorse to resolve
      Parameters:
      project - used for reporting errors
      actualProperties - the actual properties used for resolving. This can be the project in builders that do not use the BndEditModel, otherwise it is generally the BndEditModel.
      callbacks - any callbacks
      Returns:
      a Resolution
    • resolve

      public static RunResolution resolve(aQute.bnd.build.Project project, aQute.bnd.osgi.Processor actualProperties, Collection<ResolutionCallback> callbacks, ResolverLogger resolverLogger)
      The main workhorse to resolve
      Parameters:
      project - used for reporting errors
      actualProperties - the actual properties used for resolving. This can be the project in builders that do not use the BndEditModel, otherwise it is generally the BndEditModel.
      callbacks - any callbacks
      resolverLogger - an optional Logger for the resolve Process. The Logger needs to be closed manually.
      Returns:
      a Resolution
    • resolve

      public static RunResolution resolve(aQute.bnd.build.Project project, Collection<ResolutionCallback> callbacks)
      The secondary workhorse to resolve. This can be used if there is no interactive editing. In that case the properties to resolve are in the project and we can use the project both for the domain and the properties.
      Parameters:
      project - used for reporting errors and the properties for the resolve operations
      callbacks - any callbacks
      Returns:
      a Resolution
    • isOK

      public boolean isOK()
      Check if the resolution is ok, that is, there was no exception.
      Returns:
      true if there was no exception
    • updateBundles

      public boolean updateBundles(aQute.bnd.build.model.BndEditModel model)
      Update the BndEditModel with the calculated set of runbundles. Use the ResolutionInstructions.runstartlevel(RunStartLevel).order to order the bundles. Do not update it if the list has not changed. In that case return false (no changes)

      If the ResolutionInstructions.runstartlevel(RunStartLevel).order is then merge the list with the previous one.

      return true if the list was changed

      Parameters:
      model - the edit model to update
      Returns:
      true if there were changes
    • updateBundles

      public void updateBundles(aQute.bnd.build.Project project)
    • sortByDependencies

      public List<org.osgi.resource.Resource> sortByDependencies(Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> resolution)
      Sort the resources based on their dependencies. Least dependent bundles are first. This method uses a toplogical sort. If there are cycles then clearly the topological sort is not perfect.
      Parameters:
      resolution - the required wiring
      Returns:
      a topologically sorted list of resources
    • getGraph

      public Map<org.osgi.resource.Resource,List<org.osgi.resource.Resource>> getGraph(Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> resolution)
      Turn the wiring into a a->b map.
      Parameters:
      resolution - the wiring
      Returns:
      a map where the vertices are connected to other vertices.
    • getRunBundles

      public List<aQute.bnd.build.model.clauses.VersionedClause> getRunBundles()
      Get a list of ordered run bundles.
      Returns:
      a list of ordered bundles
    • getResolvedRunBundles

      public List<aQute.bnd.osgi.BundleId> getResolvedRunBundles()
      Gets the resolution result as a list of bundle ids that represent the new -runbundles
      Returns:
      the BundleIds of the bundles in the resolution
    • getRunBundlesAsString

      public String getRunBundlesAsString()
      Return the current -runbundles.
      Returns:
      a non-null string in parameters format
    • getOrderedResources

      public List<org.osgi.resource.Resource> getOrderedResources(Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> resolution, aQute.bnd.help.instructions.ResolutionInstructions.Runorder runorder)
    • getOrderedResources

      public List<org.osgi.resource.Resource> getOrderedResources()
    • dot

      public String dot(String name)
    • getContainers

      public List<aQute.bnd.build.Container> getContainers() throws Exception
      Get a list of runbundles as containers
      Throws:
      Exception
    • reportException

      public RunResolution reportException()
    • report

      public String report(boolean optionals)
    • getRequired

      public Map<org.osgi.resource.Resource,List<org.osgi.resource.Wire>> getRequired()
    • cache

      public void cache()
      Cache this resolution for the given project. A cache can be retrieved with getCached(Project project). This requires a real resolution
    • getRunBundles

      public static aQute.bnd.result.Result<String> getRunBundles(aQute.bnd.build.Project project, boolean resolveIfNecessary)
      Get the run bundles from the cache and resolve if necessary. The run bundles
      Parameters:
      project - the project to get the run bundles from
      resolveIfNecessary - if true, call resolve
      Returns:
      a result, where the value can be null
    • asResult

      public aQute.bnd.result.Result<RunResolution> asResult()
      Return a result based on the isOk status. If OK, the result is a resolution, otherwise it is an error string.
      Returns:
      a result based on isOk
    • clearCache

      public static void clearCache(aQute.bnd.build.Workspace ws)