org.eclipse.osgi.internal.resolver
Class StateHelperImpl

java.lang.Object
  extended by org.eclipse.osgi.internal.resolver.StateHelperImpl
All Implemented Interfaces:
StateHelper

public final class StateHelperImpl
extends java.lang.Object
implements StateHelper

An implementation for the StateHelper API. Access to this implementation is provided by the PlatformAdmin. Since this helper is a general facility for state manipulation, it should not be tied to any implementation details.


Field Summary
 
Fields inherited from interface org.eclipse.osgi.service.resolver.StateHelper
ACCESS_DISCOURAGED, ACCESS_ENCOURAGED, VISIBLE_INCLUDE_ALL_HOST_WIRES, VISIBLE_INCLUDE_EE_PACKAGES
 
Constructor Summary
StateHelperImpl()
           
 
Method Summary
 int getAccessCode(BundleDescription bundle, ExportPackageDescription export)
          Returns the access code that the specified BundleDescription has to the specified ExportPackageDescription.
 BundleDescription[] getDependentBundles(BundleDescription[] bundles)
          Returns all bundles in the state depending on the given bundles.
static StateHelper getInstance()
           
 BundleDescription[] getPrerequisites(BundleDescription[] bundles)
          Returns all the prerequisite bundles in the state for the given bundles.
 VersionConstraint[] getUnsatisfiedConstraints(BundleDescription bundle)
          Returns all unsatisfied constraints in the given bundle.
 VersionConstraint[] getUnsatisfiedLeaves(BundleDescription[] bundles)
          Returns all unsatisfied constraints in the given bundles that have no possible supplier.
 ExportPackageDescription[] getVisiblePackages(BundleDescription bundle)
          Returns a list of all packages that the specified bundle has access to which are exported by other bundles.
 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.
 boolean isResolvable(BundleSpecification specification)
          Returns whether the given bundle specification constraint is resolvable.
 boolean isResolvable(HostSpecification specification)
          Returns whether the given host specification constraint is resolvable.
 boolean isResolvable(ImportPackageSpecification constraint)
          Returns whether the given package specification constraint is resolvable.
 java.lang.Object[][] sortBundles(BundleDescription[] toSort)
          Sorts the given array of resolved bundles in pre-requisite order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateHelperImpl

public StateHelperImpl()
Method Detail

getDependentBundles

public BundleDescription[] getDependentBundles(BundleDescription[] bundles)
Description copied from interface: StateHelper
Returns all bundles in the state depending on the given bundles. The given bundles appear in the returned array.

Specified by:
getDependentBundles in interface StateHelper
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
See Also:
StateHelper

getPrerequisites

public BundleDescription[] getPrerequisites(BundleDescription[] bundles)
Description copied from interface: StateHelper
Returns all the prerequisite bundles in the state for the given bundles. The given bundles appear in the returned array.

Specified by:
getPrerequisites in interface StateHelper
Parameters:
bundles - the inital set of bundles
Returns:
an array containing bundle descriptions for the given leaves and their prerequisite bundles in the state.

getUnsatisfiedLeaves

public VersionConstraint[] getUnsatisfiedLeaves(BundleDescription[] bundles)
Description copied from interface: StateHelper
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.

Specified by:
getUnsatisfiedLeaves in interface StateHelper
Parameters:
bundles - the bundles to examine
Returns:
an array containing all unsatisfied leaf constraints for the given bundles

getUnsatisfiedConstraints

public VersionConstraint[] getUnsatisfiedConstraints(BundleDescription bundle)
Description copied from interface: StateHelper
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.

Specified by:
getUnsatisfiedConstraints in interface StateHelper
Parameters:
bundle - the bundle to examine
Returns:
an array containing all unsatisfied constraints for the given bundle
See Also:
StateHelper

isResolvable

public boolean isResolvable(ImportPackageSpecification constraint)
Description copied from interface: StateHelper
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).

Specified by:
isResolvable in interface StateHelper
Parameters:
constraint - the package specification constraint to be examined
Returns:
true if the constraint can be resolved, false otherwise
See Also:
StateHelper

isResolvable

public boolean isResolvable(BundleSpecification specification)
Description copied from interface: StateHelper
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).

Specified by:
isResolvable in interface StateHelper
Parameters:
specification - the bundle specification constraint to be examined
Returns:
true if the constraint can be resolved, false otherwise
See Also:
StateHelper

isResolvable

public boolean isResolvable(HostSpecification specification)
Description copied from interface: StateHelper
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).

Specified by:
isResolvable in interface StateHelper
Parameters:
specification - the host specification constraint to be examined
Returns:
true if the constraint can be resolved, false otherwise
See Also:
StateHelper

sortBundles

public java.lang.Object[][] sortBundles(BundleDescription[] toSort)
Description copied from interface: StateHelper
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.

Specified by:
sortBundles in interface StateHelper
Parameters:
toSort - an array of bundles to be sorted
Returns:
any cycles found

getVisiblePackages

public ExportPackageDescription[] getVisiblePackages(BundleDescription bundle)
Description copied from interface: StateHelper
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)

Specified by:
getVisiblePackages in interface StateHelper
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

public ExportPackageDescription[] getVisiblePackages(BundleDescription bundle,
                                                     int options)
Description copied from interface: StateHelper
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.)

Specified by:
getVisiblePackages in interface StateHelper
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.
See Also:
StateHelper.VISIBLE_INCLUDE_EE_PACKAGES, StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES

getAccessCode

public int getAccessCode(BundleDescription bundle,
                         ExportPackageDescription export)
Description copied from interface: StateHelper
Returns the access code that the specified BundleDescription has to the specified ExportPackageDescription.

Specified by:
getAccessCode in interface StateHelper
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:
StateHelper.ACCESS_ENCOURAGED, StateHelper.ACCESS_DISCOURAGED

getInstance

public static StateHelper getInstance()


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.