// Path: graceland-platform/src/main/java/io/graceland/application/Application.java
// public interface Application {
// 
//     /**
//      * Adds the plugin to the list of plugins that will be loaded.
//      *
//      * @param plugin The plugin to load.
//      */
//     void loadPlugin(Plugin plugin);
// 
//     /**
//      * Provides a list of loaded plugins for this application. Once requested, the list of plugins should not change.
//      * <p/>
//      * At least one plugin must be loaded.
//      *
//      * @return A list of plugins.
//      */
//     ImmutableList<Plugin> getPlugins();
// }
// 
// Path: graceland-platform/src/main/java/io/graceland/plugin/Plugin.java
// public interface Plugin extends Module {
// }


import java.util.ServiceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import io.graceland.application.Application;
import io.graceland.plugin.Plugin;
package io.graceland.plugin.loaders;




/**
 * Uses the java {@link java.util.ServiceLoader} to discover plugins and loads them into the
 * {@link io.graceland.application.Application}.
 */
public class NativePluginLoader implements PluginLoader {

    private static final Logger LOGGER = LoggerFactory.getLogger(NativePluginLoader.class);

    NativePluginLoader() {
        // do nothing
    }

    public static NativePluginLoader newLoader() {
        return new NativePluginLoader();
    }

    @Override
    public void loadInto(Application application) {
        Preconditions.checkNotNull(application, "Application cannot be null.");

        LOGGER.info("Loading plugins using the native ServiceLoader.");

// Path: graceland-platform/src/main/java/io/graceland/application/Application.java
// public interface Application {
// 
//     /**
//      * Adds the plugin to the list of plugins that will be loaded.
//      *
//      * @param plugin The plugin to load.
//      */
//     void loadPlugin(Plugin plugin);
// 
//     /**
//      * Provides a list of loaded plugins for this application. Once requested, the list of plugins should not change.
//      * <p/>
//      * At least one plugin must be loaded.
//      *
//      * @return A list of plugins.
//      */
//     ImmutableList<Plugin> getPlugins();
// }
// 
// Path: graceland-platform/src/main/java/io/graceland/plugin/Plugin.java
// public interface Plugin extends Module {
// }


// Path: graceland-platform/src/main/java/io/graceland/plugin/loaders/NativePluginLoader.java
import java.util.ServiceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import io.graceland.application.Application;
import io.graceland.plugin.Plugin;

package io.graceland.plugin.loaders;




/**
 * Uses the java {@link java.util.ServiceLoader} to discover plugins and loads them into the
 * {@link io.graceland.application.Application}.
 */
public class NativePluginLoader implements PluginLoader {

    private static final Logger LOGGER = LoggerFactory.getLogger(NativePluginLoader.class);

    NativePluginLoader() {
        // do nothing
    }

    public static NativePluginLoader newLoader() {
        return new NativePluginLoader();
    }

    @Override
    public void loadInto(Application application) {
        Preconditions.checkNotNull(application, "Application cannot be null.");

        LOGGER.info("Loading plugins using the native ServiceLoader.");

        for (Plugin plugin : ServiceLoader.load(Plugin.class)) {