Class ModuleDependencyUtil
java.lang.Object
eu.cloudnetservice.driver.impl.module.ModuleDependencyUtil
Utility to find dependencies of a module, ensure that they are loaded and that there is no circular dependency.
- Since:
- 4.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCreating an instance of this helper class is not allowed, results inUnsupportedOperationException. -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NonNull eu.cloudnetservice.driver.module.ModuleWrapperassociatedModuleWrapper(@NonNull eu.cloudnetservice.driver.module.ModuleDependency dependency, @NonNull eu.cloudnetservice.driver.module.ModuleProvider provider, @NonNull eu.cloudnetservice.driver.module.ModuleWrapper dependencyHolder) Gets the associated module wrapper to a module dependency or throws an exception if the wrapper is not present.private static voidcheckDependencyVersion(@NonNull eu.cloudnetservice.driver.module.ModuleWrapper requiringModule, @NonNull eu.cloudnetservice.driver.module.ModuleDependency dependency, @NonNull Matcher dependencyVersion, @NonNull Matcher moduleVersion) Validates that the dependency of the module is compatible with the actual running module.collectDependencies(@NonNull eu.cloudnetservice.driver.module.ModuleWrapper caller, @NonNull eu.cloudnetservice.driver.module.ModuleProvider moduleProvider) Collects all first-level module dependencies of a module.private static voidvisitDependencies(@NonNull Deque<eu.cloudnetservice.driver.module.ModuleWrapper> visitedNodes, @NonNull Collection<eu.cloudnetservice.driver.module.ModuleDependency> dependencies, @NonNull eu.cloudnetservice.driver.module.ModuleWrapper originalSource, @NonNull eu.cloudnetservice.driver.module.ModuleWrapper dependencyHolder, @NonNull eu.cloudnetservice.driver.module.ModuleProvider moduleProvider) Visits all dependencies of a module and ensures that there is no circular dependency to the root calling module.
-
Field Details
-
SEMVER_PATTERN
-
-
Constructor Details
-
ModuleDependencyUtil
private ModuleDependencyUtil()Creating an instance of this helper class is not allowed, results inUnsupportedOperationException.- Throws:
UnsupportedOperationException- on invocation
-
-
Method Details
-
collectDependencies
@NonNull public static @NonNull Set<eu.cloudnetservice.driver.module.ModuleWrapper> collectDependencies(@NonNull @NonNull eu.cloudnetservice.driver.module.ModuleWrapper caller, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleProvider moduleProvider) Collects all first-level module dependencies of a module.- Parameters:
caller- the module that needs its dependencies collected.moduleProvider- the provider which loaded the calling module.- Returns:
- a set of all dependencies which need to be enabled before the caller can be enabled.
- Throws:
eu.cloudnetservice.driver.module.ModuleDependencyNotFoundException- if a module dependency is missing.eu.cloudnetservice.driver.module.ModuleDependencyOutdatedException- if the running module can not provide the minimum required version.NullPointerException- if caller or moduleProvider is null.
-
visitDependencies
private static void visitDependencies(@NonNull @NonNull Deque<eu.cloudnetservice.driver.module.ModuleWrapper> visitedNodes, @NonNull @NonNull Collection<eu.cloudnetservice.driver.module.ModuleDependency> dependencies, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleWrapper originalSource, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleWrapper dependencyHolder, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleProvider moduleProvider) Visits all dependencies of a module and ensures that there is no circular dependency to the root calling module.- Parameters:
visitedNodes- all yet visited modules.dependencies- all dependencies to check.originalSource- the original caller which requested the check-dependencyHolder- the module of which the dependencies are checked currently.moduleProvider- the module provider which originally loaded the dependencies.- Throws:
eu.cloudnetservice.driver.module.ModuleDependencyNotFoundException- if a module dependency is missing.eu.cloudnetservice.driver.module.ModuleDependencyOutdatedException- if the running module can not provide the minimum required version.NullPointerException- if visitedNodes, dependencies, originalSource, dependencyHolder or moduleProvider is null.
-
associatedModuleWrapper
@NonNull private static @NonNull eu.cloudnetservice.driver.module.ModuleWrapper associatedModuleWrapper(@NonNull @NonNull eu.cloudnetservice.driver.module.ModuleDependency dependency, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleProvider provider, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleWrapper dependencyHolder) Gets the associated module wrapper to a module dependency or throws an exception if the wrapper is not present.- Parameters:
dependency- the dependency to get the associated wrapper with.provider- the module provider from which the requesting module came.dependencyHolder- the holder which needs the dependency to be present.- Returns:
- the associated module wrapper with the given module dependency.
- Throws:
eu.cloudnetservice.driver.module.ModuleDependencyNotFoundException- if a module dependency is missing.eu.cloudnetservice.driver.module.ModuleDependencyOutdatedException- if the running module can not provide the minimum required version.NullPointerException- if dependency, provider or dependencyHolder is null.
-
checkDependencyVersion
private static void checkDependencyVersion(@NonNull @NonNull eu.cloudnetservice.driver.module.ModuleWrapper requiringModule, @NonNull @NonNull eu.cloudnetservice.driver.module.ModuleDependency dependency, @NonNull @NonNull Matcher dependencyVersion, @NonNull @NonNull Matcher moduleVersion) Validates that the dependency of the module is compatible with the actual running module. This only checks for the major and minor version of the module as a patch version should only patch bugs not add new features nor contain breaking changes.- Parameters:
requiringModule- the module which holds the dependency.dependency- the dependency which gets checked.dependencyVersion- a matcher for the semver versioning of the dependency.moduleVersion- a matcher for the semver versioning of the running module.- Throws:
eu.cloudnetservice.driver.module.ModuleDependencyOutdatedException- if the running module can not provide the minimum required version.NullPointerException- if requiringModule, dependency, dependencyVersion or moduleVersion is null.
-