package io.highway.to.urhell;

import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashSet;
import java.util.Set;


public class PluginUtils {
    private static final Logger LOGGER = LoggerFactory.getLogger(PluginUtils.class);

    private PluginUtils() {
    }

    public static <T> Set<T> autodiscoverPlugin(Class<T> pluginClass) {
        Set<T> pluginList = new HashSet<>();
        Reflections reflections = new Reflections("io.highway.to.urhell");
        Set<Class<? extends T>> pluginsAvailable = reflections
                .getSubTypesOf(pluginClass);
        for (Class<? extends T> plugin : pluginsAvailable) {
            try {
                LOGGER.info("registering {} : {}", plugin.getClass().getName(),
                        plugin.getCanonicalName());
                T instance = plugin.newInstance();
                pluginList.add(instance);
            } catch (InstantiationException | IllegalAccessException e) {
                LOGGER.error("An error occured while registering " + plugin.getClass().getName() + " : " + plugin.getCanonicalName(), e);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return pluginList;

    }

}

@@ -748,35 +748,29 @@
  %7B%7D%22, plugin
-.get
 Class
-()
 .getName(),%0A
@@ -1067,19 +1067,13 @@
 ugin
-.get
 Class
-()
 .get

fix logging