Class PluginResolver
Plugins are published as thin JARs. Each one carries a precomputed list of its runtime
dependencies in META-INF/para/plugin-deps.txt, generated at build time by
maven-dependency-plugin:list. This class fetches a plugin JAR, reads that manifest
without executing anything, then downloads each listed artifact into the plugin folder where
Para.getParaClassLoader() can see it.
Every downloaded artifact is checksum-verified before it is moved into place. SHA-256 is preferred, SHA-1 is accepted as a fallback for artifacts that predate SHA-256 publication, and a download is discarded if neither digest is available. Files are written to a temporary location and atomically renamed, so a partial or corrupt download can never become visible to the classloader.
The plugin folder is a flat classpath, so at most one version of any given library is kept. When two plugins disagree about a version, the higher one wins and the lower one is removed. This keeps the classpath deterministic regardless of the order plugins were installed in.
Version conflicts are resolved per artifact, not per library. Installing
para-search-lucene after para-search-elasticsearch therefore leaves the Lucene
modules that only Elasticsearch needs at the version Elasticsearch asked for, and upgrades only
the modules both plugins declare. For the official plugins this means Lucene patch versions can
coexist, which is safe because a patch release of the same Lucene minor version is binary
compatible.
- Author:
- Alex Bogdanovski [[email protected]]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe outcome of resolving a single plugin. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a resolver that writes into the configured plugin folder.PluginResolver(Path pluginFolder) Creates a resolver that writes into the given folder.PluginResolver(Path pluginFolder, String repositoryUrl) Creates a resolver that writes into the given folder and fetches from the given repository. -
Method Summary
Modifier and TypeMethodDescriptionresolvePlugin(String groupId, String artifactId, String version) Downloads a plugin and all of its runtime dependencies into the plugin folder.
-
Constructor Details
-
PluginResolver
public PluginResolver()Creates a resolver that writes into the configured plugin folder. -
PluginResolver
Creates a resolver that writes into the given folder.- Parameters:
pluginFolder- the destination folder for plugins and their dependencies
-
PluginResolver
Creates a resolver that writes into the given folder and fetches from the given repository.- Parameters:
pluginFolder- the destination folder for plugins and their dependenciesrepositoryUrl- base URL of the Maven repository to download from
-
-
Method Details
-
resolvePlugin
public PluginResolver.ResolutionResult resolvePlugin(String groupId, String artifactId, String version) throws IOException Downloads a plugin and all of its runtime dependencies into the plugin folder.This is the bootstrap sequence: the plugin JAR is fetched first, then its embedded manifest is read as a ZIP entry (no classloading, no code execution), then each listed dependency is fetched and verified. The plugin is not usable until this method returns without error, and a restart is required before the plugin can be loaded.
- Parameters:
groupId- the Maven groupId of the pluginartifactId- the Maven artifactId of the pluginversion- the plugin version- Returns:
- a result describing what was downloaded and what was already present
- Throws:
IOException- if the plugin cannot be fetched, its manifest is missing or unreadable, or any artifact fails checksum verification
-