Interface StateHelper


  • public interface StateHelper
    A helper class that provides convenience methods for manipulating state objects. PlatformAdmin provides an access point for a state helper.

    This interface is not intended to be implemented by clients.

    Since:
    3.1
    See Also:
    PlatformAdmin.getStateHelper()
    Restriction:
    This interface is not intended to be implemented by clients.
    • Field Detail

      • ACCESS_ENCOURAGED

        static final int ACCESS_ENCOURAGED
        Indicates that access is encouraged to an ExportPackageDescription.
        See Also:
        Constant Field Values
      • ACCESS_DISCOURAGED

        static final int ACCESS_DISCOURAGED
        Indicates that access is discouraged to an ExportPackageDescription.
        See Also:
        Constant Field Values
      • VISIBLE_INCLUDE_EE_PACKAGES

        static final int VISIBLE_INCLUDE_EE_PACKAGES
        An option to include packages available from the execution environment when getting the visible packages of a bundle. For example, when running on a J2SE 1.4 VM the system bundle will export the javax.xml.parsers package as part of the execution environment. When this option is used then any packages from the execution environment which the bundle is wired to will be included.
        See Also:
        getVisiblePackages(BundleDescription, int), Constant Field Values
      • VISIBLE_INCLUDE_ALL_HOST_WIRES

        static final int VISIBLE_INCLUDE_ALL_HOST_WIRES
        An option to get all visible packages that a host bundle is currently wired to. This includes packages wired to as a result of a dynamic import and packages wired to as a result of additional constraints specified by a fragment bundle. Using this option with a fragment will cause an empty array to be returned.
        Since:
        3.6
        See Also:
        getVisiblePackages(BundleDescription, int), Constant Field Values
    • Method Detail

      • getDependentBundles

        BundleDescription[] getDependentBundles​(BundleDescription[] bundles)
        Returns all bundles in the state depending on the given bundles. The given bundles appear in the returned array.
        Parameters:
        bundles - the initial set of bundles
        Returns:
        an array containing bundle descriptions for the given roots and all bundles in the state that depend on them
      • getPrerequisites

        BundleDescription[] getPrerequisites​(BundleDescription[] bundles)
        Returns all the prerequisite bundles in the state for the given bundles. The given bundles appear in the returned array.
        Parameters:
        bundles - the inital set of bundles
        Returns:
        an array containing bundle descriptions for the given leaves and their prerequisite bundles in the state.
        Since:
        3.2
      • getUnsatisfiedConstraints

        VersionConstraint[] getUnsatisfiedConstraints​(BundleDescription bundle)
        Returns all unsatisfied constraints in the given bundle. Returns an empty array if no unsatisfied constraints can be found.

        Note that a bundle may have no unsatisfied constraints and still not be resolved.

        Parameters:
        bundle - the bundle to examine
        Returns:
        an array containing all unsatisfied constraints for the given bundle
      • getUnsatisfiedLeaves

        VersionConstraint[] getUnsatisfiedLeaves​(BundleDescription[] bundles)
        Returns all unsatisfied constraints in the given bundles that have no possible supplier. Returns an empty array if no unsatisfied leaf constraints can be found.

        The returned constraints include only the unsatisfied constraints in the given state that have no possible supplier (leaf constraints). There may be additional unsatisfied constraints in the given bundles but these will have at least one possible supplier. In this case the possible supplier of the constraint is not resolved for some reason. For example, a given state only has Bundles X and Y installed and Bundles X and Y have the following constraints:

         Bundle X requires Bundle Y
         Bundle Y requires Bundle Z

        In this case Bundle Y has an unsatisfied constraint leaf on Bundle Z. This will cause Bundle X's constraint on Bundle Y to be unsatisfied as well because the bundles are involved in a dependency chain. Bundle X's constraint on Bundle Y is not considered a leaf because there is a possible supplier Y in the given state.

        Note that a bundle may have no unsatisfied constraints and still not be resolved.

        Parameters:
        bundles - the bundles to examine
        Returns:
        an array containing all unsatisfied leaf constraints for the given bundles
        Since:
        3.2
      • isResolvable

        boolean isResolvable​(ImportPackageSpecification specification)
        Returns whether the given package specification constraint is resolvable. A package specification constraint may be resolvable but not resolved, which means that the bundle that provides it has not been resolved for some other reason (e.g. another constraint could not be resolved, another version has been picked, etc).
        Parameters:
        specification - the package specification constraint to be examined
        Returns:
        true if the constraint can be resolved, false otherwise
      • isResolvable

        boolean isResolvable​(BundleSpecification specification)
        Returns whether the given bundle specification constraint is resolvable. A bundle specification constraint may be resolvable but not resolved, which means that the bundle that provides it has not been resolved for some other reason (e.g. another constraint could not be resolved, another version has been picked, etc).
        Parameters:
        specification - the bundle specification constraint to be examined
        Returns:
        true if the constraint can be resolved, false otherwise
      • isResolvable

        boolean isResolvable​(HostSpecification specification)
        Returns whether the given host specification constraint is resolvable. A host specification constraint may be resolvable but not resolved, which means that the bundle that provides it has not been resolved for some other reason (e.g. another constraint could not be resolved, another version has been picked, etc).
        Parameters:
        specification - the host specification constraint to be examined
        Returns:
        true if the constraint can be resolved, false otherwise
      • sortBundles

        Object[][] sortBundles​(BundleDescription[] toSort)
        Sorts the given array of resolved bundles in pre-requisite order. If A requires B, A appears after B. Fragments will appear after all of their hosts. Constraints contributed by fragments will be treated as if contributed by theirs hosts, affecting their position. This is true even if the fragment does not appear in the given bundle array.

        Unresolved bundles are ignored.

        Parameters:
        toSort - an array of bundles to be sorted
        Returns:
        any cycles found
      • getVisiblePackages

        ExportPackageDescription[] getVisiblePackages​(BundleDescription bundle)
        Returns a list of all packages that the specified bundle has access to which are exported by other bundles.

        Same as calling getVisiblePackages(bundle, 0)

        Parameters:
        bundle - a bundle to get the list of packages for.
        Returns:
        a list of all packages that the specified bundle has access to which are exported by other bundles.
      • getVisiblePackages

        ExportPackageDescription[] getVisiblePackages​(BundleDescription bundle,
                                                      int options)
        Returns a list of all packages that the specified bundle has access to which are exported by other bundles. This takes into account all constraint specifications (Import-Package, Require-Bundle etc). A deep dependency search is done for all packages which are available through the required bundles and any bundles which are reexported. This method also takes into account all directives which may be specified on the constraint specifications (e.g. uses, x-friends etc.)
        Parameters:
        bundle - a bundle to get the list of packages for.
        options - the options for selecting the visible packages
        Returns:
        a list of all packages that the specified bundle has access to which are exported by other bundles.
        Since:
        3.3
        See Also:
        VISIBLE_INCLUDE_EE_PACKAGES, VISIBLE_INCLUDE_ALL_HOST_WIRES
      • getAccessCode

        int getAccessCode​(BundleDescription bundle,
                          ExportPackageDescription export)
        Returns the access code that the specified BundleDescription has to the specified ExportPackageDescription.
        Parameters:
        bundle - the bundle to find the access code for
        export - the export to find the access code for
        Returns:
        the access code to the export.
        See Also:
        ACCESS_ENCOURAGED, ACCESS_DISCOURAGED