saker.nest Documentation TaskDoc JavaDoc Packages
public class DependencyUtils
Utility class providing functionality for working with dependencies.

The class implements the basic dependency resolution algorithm used by the repository.

Methods
public static boolean
Checks if the given constraint configuration excludes the specified bundle information for usage on the classpath.
public static boolean
Checks if the given constraint configuration excludes the specified bundle dependency.
public static boolean
Checks if the given constraint configuration excludes the specified external dependency.
public static BundleIdentifier
Generates a random bundle identifier.
public static <BK extends BundleIdentifierHolder, BC> DependencyDomainResolutionResult<BK, BC>
satisfyDependencyDomain(BK basebundle, BC basebundlecontext, BundleDependencyInformation basedependencyinfo, BiFunction<super BundleIdentifier, ? super BC, ? extends Iterable<extends Entry<extends BK, ? extends BC>>> bundleslookupfunction, BiFunction<super BK, ? super BC, ? extends BundleDependencyInformation> bundledependencieslookupfunction, DependencyResolutionLogger<super BC> logger)
Executes the dependency resolution with the given arguments.
public static <BK extends BundleIdentifierHolder, BC> DependencyResolutionResult<BK, BC>
satisfyDependencyRequirements(BK basebundle, BC basebundlecontext, BundleDependencyInformation basedependencyinfo, BiFunction<super BundleIdentifier, ? super BC, ? extends Iterable<extends Entry<extends BK, ? extends BC>>> bundleslookupfunction, BiFunction<super BK, ? super BC, ? extends BundleDependencyInformation> bundledependencieslookupfunction, DependencyResolutionLogger<super BC> logger)
public static boolean
Checks if the argument bundle supports the specified native architecture.
public static boolean
Checks if the argument bundle supports the specified saker.build system version.
public static boolean
Checks if the argument bundle supports the specified Java Runtime major version.
public static boolean
Checks if the argument bundle supports the specified Java Runtime major version.
public static boolean
Checks if the argument bundle supports the specified Nest repository version.
Checks if the given constraint configuration excludes the specified bundle information for usage on the classpath.

The method will examine the allowed classpath constraints in the bundle information, and check if the specified constraints are allowed with it.

If the argument constraint configuration object is null, false is returned.

constraintsThe constraint configuration.
bundleinfoThe bundle information.
true if the bundle should be excluded.
NullPointerExceptionIf the bundle information is null.
Checks if the given constraint configuration excludes the specified bundle dependency.

The method will check the meta-data of the dependency and examine it against the specified constraint configuration. The constraint meta-data names declared in BundleInformation will be used to determine exclusion.

If the argument constraint configuration object is null, false is returned.

constraintsThe constraint configuration.
dependencyThe dependency to examine.
true if the dependency should be excluded.
NullPointerExceptionIf the dependency is null.
Checks if the given constraint configuration excludes the specified external dependency.

The method will check the meta-data of the dependency and examine it against the specified constraint configuration. The constraint meta-data names declared in BundleInformation will be used to determine exclusion.

If the argument constraint configuration object is null, false is returned.

constraintsThe constraint configuration.
dependencyThe dependency to examine.
true if the dependency should be excluded.
NullPointerExceptionIf the dependency is null.
Generates a random bundle identifier.

The generated bundle identifier will have a random name and version assigned to it.

It is primarily to be used with DependencyUtils.satisfyDependencyRequirements to ensure that it has a root bundle identifier for resolution.

The generated bundle identifier has 128 bit of randomness (similar to UUID).

The generated random bundle identifier.
public static <BK extends BundleIdentifierHolder, BC> DependencyDomainResolutionResult<BK, BC> satisfyDependencyDomain(BK basebundle, BC basebundlecontext, BundleDependencyInformation basedependencyinfo, BiFunction<super BundleIdentifier, ? super BC, ? extends Iterable<extends Entry<extends BK, ? extends BC>>> bundleslookupfunction, BiFunction<super BK, ? super BC, ? extends BundleDependencyInformation> bundledependencieslookupfunction, DependencyResolutionLogger<super BC> logger) throws NullPointerException, IllegalArgumentException
Executes the dependency resolution with the given arguments.

The dependency resolution algorithm defines no methodology about findig the bundles and their dependency information. These functionalities must be implemented by the caller and plugged in to the dependency resolution algorithm via the argument function interface instances.

The dependency resolution algorithm is deterministic, meaning that if the inputs are the same and have the same iteration orders, it will produce the same output.

The algorithm basically works on BundleIdentifiers, however, in order to support various scenarios such as a bundle identifier occurring multiple times, the algorithm works with the type parameters of BK (bundle key) and BC (bundle context). BK type serves as the key to the bundle, that uniquely locates both the bundle identifier and its location in some arbitrary space. The BC type serves as a transient information about the found bundle that can be used to store information for further operations. The bundle context is later passed to the dependency lookup function.

In general, types such as BundleKey or similar should be used as a substitute for the BK type parameter, and BundleLookup or other information for BC. Other arbitrary client provided types may be used as well.

Both the BK and BC types should be comparable using equality.

The dependency resolution algorithm first tries to resolve all non-optional (required) dependencies. If the resolution of these succeed, then these dependencies will be pinned, and it will attempt to resolve the optional dependencies as well. However, the resolution of the optional dependencies may fail, in which case it is silently ignored by the method implementation.

The dependency resolution algorithm is exhaustive, meaning that it will not fail if there is a possible resolution of dependencies. The algorithm supports circular dependencies.

The method handles private dependencies as it is defined by the repository.

The method accepts a logger which will be called at different times during the dependency resolution to notify about the current state. If the dependency resolution fails, the caller can use the information passed to the logger to determine the cause of the failure. This method doesn't directly report the cause, and doesn't analyze the failures by itself.

BKThe bundle key type. The type should be comparable using equality.
BCThe bundle context type. The type should be comparable using equality.
basebundleThe root bundle to resolve the dependencies of. Must not be null.
If one cannot provide a root bundle identifier, as the resolution happens in a way that there's none, one can use the randomBundleIdentifier() to create a unique bundle identifier that this function accepts. Make sure to remove logging information about the generated bundle identifier not to pollute the user logs.
basebundlecontextThe bundle context for the root bundle.
basedependencyinfoThe dependency information of the root bundle that should be resolved.
bundleslookupfunctionThe function that looks up the bundles for a given bundle identifier. The bundle identifier argument doesn't contain a version qualifier. If the result iterable is backed by a Map entry set, then it is recommended that the Map returned from this function has a deterministic iteration order. (See LinkedHashMap or TreeMap.)
The returned iterable from the function may be lazily populated.
bundledependencieslookupfunctionThe function that looks up the dependency information for a bundle. The arguments for this function is the ones that were returned from the lookup function (or the root bundle key and context). The bundle identifier argument contains a version qualifier.
loggerThe dependency resolution logger or null to not use one.
The result of the dependency resolution or null if the resolution failed.
NullPointerExceptionIf the base bundle, base dependency information, bundle lookup function, or bundle dependencies lookup function arguments are null.
IllegalArgumentExceptionIf the base bundle identifier doesn't have a version qualifier.
saker.nest 0.8.1
public static <BK extends BundleIdentifierHolder, BC> DependencyResolutionResult<BK, BC> satisfyDependencyRequirements(BK basebundle, BC basebundlecontext, BundleDependencyInformation basedependencyinfo, BiFunction<super BundleIdentifier, ? super BC, ? extends Iterable<extends Entry<extends BK, ? extends BC>>> bundleslookupfunction, BiFunction<super BK, ? super BC, ? extends BundleDependencyInformation> bundledependencieslookupfunction, DependencyResolutionLogger<super BC> logger) throws NullPointerException, IllegalArgumentException, UnsupportedOperationException
Executes the dependency resolution with the given arguments.

The dependency resolution algorithm defines no methodology about findig the bundles and their dependency information. These functionalities must be implemented by the caller and plugged in to the dependency resolution algorithm via the argument function interface instances.

The dependency resolution algorithm is deterministic, meaning that if the inputs are the same and have the same iteration orders, it will produce the same output.

The algorithm basically works on BundleIdentifiers, however, in order to support various scenarios such as a bundle identifier occurring multiple times, the algorithm works with the type parameters of BK (bundle key) and BC (bundle context). BK type serves as the key to the bundle, that uniquely locates both the bundle identifier and its location in some arbitrary space. The BC type serves as a transient information about the found bundle that can be used to store information for further operations. The bundle context is later passed to the dependency lookup function.

In general, types such as BundleKey or similar should be used as a substitute for the BK type parameter, and BundleLookup or other information for BC. Other arbitrary client provided types may be used as well.

Both the BK and BC types should be comparable using equality.

The dependency resolution algorithm first tries to resolve all non-optional (required) dependencies. If the resolution of these succeed, then these dependencies will be pinned, and it will attempt to resolve the optional dependencies as well. However, the resolution of the optional dependencies may fail, in which case it is silently ignored by the method implementation.

The dependency resolution algorithm is exhaustive, meaning that it will not fail if there is a possible resolution of dependencies. The algorithm supports circular dependencies.

The method accepts a logger which will be called at different times during the dependency resolution to notify about the current state. If the dependency resolution fails, the caller can use the information passed to the logger to determine the cause of the failure. This method doesn't directly report the cause, and doesn't analyze the failures by itself.

BKThe bundle key type. The type should be comparable using equality.
BCThe bundle context type. The type should be comparable using equality.
basebundleThe root bundle to resolve the dependencies of. Must not be null.
If one cannot provide a root bundle identifier, as the resolution happens in a way that there's none, one can use the randomBundleIdentifier() to create a unique bundle identifier that this function accepts. Make sure to remove logging information about the generated bundle identifier not to pollute the user logs.
basebundlecontextThe bundle context for the root bundle.
basedependencyinfoThe dependency information of the root bundle that should be resolved.
bundleslookupfunctionThe function that looks up the bundles for a given bundle identifier. The bundle identifier argument doesn't contain a version qualifier. If the result iterable is backed by a Map entry set, then it is recommended that the Map returned from this function has a deterministic iteration order. (See LinkedHashMap or TreeMap.)
The returned iterable from the function may be lazily populated.
bundledependencieslookupfunctionThe function that looks up the dependency information for a bundle. The arguments for this function is the ones that were returned from the lookup function (or the root bundle key and context). The bundle identifier argument contains a version qualifier.
loggerThe dependency resolution logger or null to not use one.
The result of the dependency resolution or null if the resolution failed.
NullPointerExceptionIf the base bundle, base dependency information, bundle lookup function, or bundle dependencies lookup function arguments are null.
IllegalArgumentExceptionIf the base bundle identifier doesn't have a version qualifier.
UnsupportedOperationExceptionIf any of the bundle dependencies contain private dependencies. Use DependencyUtils.satisfyDependencyDomain to resolve private dependencies.
public static boolean supportsClassPathArchitecture(BundleInformation bundleinfo, String arch) throws NullPointerException
Checks if the argument bundle supports the specified native architecture.

If the architecture is null, the method will return true.

bundleinfoThe bundle information.
archThe native architecture.
true if the bundle supports the specified native architecture.
NullPointerExceptionIf the bundle information is null.
public static boolean supportsClassPathBuildSystemVersion(BundleInformation bundleinfo, String version) throws NullPointerException
Checks if the argument bundle supports the specified saker.build system version.

If the version is null, the method will return true.

bundleinfoThe bundle information.
versionThe saker.build system version.
true if the bundle supports the saker.build system version.
NullPointerExceptionIf the bundle information is null.
public static boolean supportsClassPathJreVersion(BundleInformation bundleinfo, int version) throws NullPointerException
Checks if the argument bundle supports the specified Java Runtime major version.

Same as supportsClassPathJreVersion(BundleInformation, Integer), but takes a primitive int version as the argument.

bundleinfoThe bundle information.
versionThe Java major version.
true if the bundle supports the JRE major version.
NullPointerExceptionIf the bundle information is null.
public static boolean supportsClassPathJreVersion(BundleInformation bundleinfo, Integer version) throws NullPointerException
Checks if the argument bundle supports the specified Java Runtime major version.

If the version is null, the method will return true.

bundleinfoThe bundle information.
versionThe Java major version.
true if the bundle supports the JRE major version.
NullPointerExceptionIf the bundle information is null.
public static boolean supportsClassPathRepositoryVersion(BundleInformation bundleinfo, String version) throws NullPointerException
Checks if the argument bundle supports the specified Nest repository version.

If the version is null, the method will return true.

bundleinfoThe bundle information.
versionThe Nest repository version.
true if the bundle supports the Nest repository version.
NullPointerExceptionIf the bundle information is null.