New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier to co-host zip and jar plugins in same system #143
Comments
I think that it could be a solution but I have doubt that someone wish to use multiple plugin packaging systems ( |
If it turns out to be useful for us, I'll contribute a solution later. For now I'll keep it custom and get some experience with it. |
See https://github.com/cominvent/lucene-solr/blob/pf4j/solr/core/src/java/org/apache/solr/util/plugin/bundle/SolrPf4jPluginManager.java#L146 for how I solved it. Simply implementing a |
The solution is good for now but it's a little bit static for the future. The idea is to use a Compound(PluginLoader/DescriptorFinder/PluginRepository) and to pass the entries (a list with PluginLoader for example) in constructor. In public CompoundPluginLoader implements PluginLoader {
private List<PluginLoader> items;
public CompoundPluginLoader(List<PluginLoader> items) {
this.items = items;
}
@Override
public boolean isApplicable(Path pluginPath) {
for (PluginLoader item : items) {
if (item.isApplicable(pluginPath)) {
return true;
}
}
return false;
}
@Override
public ClassLoader loadPlugin(Path pluginPath, PluginDescriptor pluginDescriptor) {
for (PluginLoader item : items) {
if (item.isApplicable(pluginPath)) {
return item.loadPlugin(pluginPath, pluginDescriptor);
}
}
throw new PluginRuntimeException("Something is very bad"); // no happening
}
} It's only an idea. |
The concept described by me in the previous comment is taken from Pippo, see explanations for public CompoundPluginLoader implements PluginLoader {
private List<PluginLoader> items;
public CompoundPluginLoader(List<PluginLoader> items) {
this.items = items;
}
@Override
public ClassLoader loadPlugin(Path pluginPath, PluginDescriptor pluginDescriptor) {
ClassLoader classLoader = null;
for (PluginLoader item : items) {
try {
classLoader = item.loadPlugin(pluginPath, pluginDescriptor);
} catch (Throwable t) {
// ignore or log
}
if (classLoader != null) {
return classLoader;
}
}
throw new PluginRuntimeException("Something is very bad"); // no happening
}
} I see the same pattern applicable for |
The |
I finished the implementation. |
A host system may want to let developers choose between zip plugins or jar plugins. Or perhaps in the future Jigsaw module plugins. This is hard today since the distinction is on a PluginManager level (JarPluginManager).
Provide an out of the box
SmartPluginLoader
that can will decide based onpath
whether this is a jar plugin or an unpacked zip plugin and load using correct loader.Also a
SmartPluginDescriptorFinder
that based onpath
will decide whether to useJarPluginDescriptorFinder
, and in case of folder, will first try Manifest, then if exception fall back to properties.I have done just that in my own code, but it would be better to have framework support?
The text was updated successfully, but these errors were encountered: