This commit is contained in:
Fabio Sinibaldi 2022-03-16 12:14:15 +01:00
parent 7851d09cfb
commit f2da26496c
1 changed files with 5 additions and 4 deletions

View File

@ -14,21 +14,22 @@ import java.util.Set;
public class PluginsReflections { public class PluginsReflections {
/** Loads Plugin implementation classes. It should only be accessed once by Plugin Manager /** Loads Plugin implementation classes. It should only be accessed once by Plugin Manager
* Plugins shouldn't access this unless this class for testing purposes. * Plugins shouldn't access this class unless for testing purposes.
* @return * @return
*/ */
public static Map<String,Plugin> load(){ public static Map<String,Plugin> load(){
Map<String,Plugin> toReturn=new HashMap<>(); Map<String,Plugin> toReturn=new HashMap<>();
log.warn("WARNING!! LOADING PLUGIN SET : THIS SHOULD HAPPEN ONLY ONCE"); log.warn("WARNING!! LOADING PLUGIN CLASSES : THIS SHOULD HAPPEN ONLY ONCE");
Reflections reflections = new Reflections( Reflections reflections = new Reflections(
new ConfigurationBuilder() new ConfigurationBuilder()
.forPackage("org.gcube.application.cms") .forPackage("org.gcube.application.cms")
.filterInputsBy(new FilterBuilder().includePackage("org.gcube.application.cms"))); .filterInputsBy(new FilterBuilder().includePackage("org.gcube.application.cms")));
reflections.getSubTypesOf(Plugin.class).iterator().forEachRemaining(pluginClass->{ reflections.getSubTypesOf(Plugin.class).iterator().forEachRemaining(pluginClass->{
log.trace("Evaluating class {}",pluginClass);
if(!pluginClass.isInterface() && !Modifier.isAbstract(pluginClass.getModifiers())){ if(!pluginClass.isInterface() && !Modifier.isAbstract(pluginClass.getModifiers())){
log.trace("Evaluating class ");
try { try {
log.debug("Found implementation {} ",pluginClass);
Plugin plugin = pluginClass.newInstance(); Plugin plugin = pluginClass.newInstance();
log.debug("Loading {} description : {}", plugin, plugin.getDescriptor()); log.debug("Loading {} description : {}", plugin, plugin.getDescriptor());