Package org.socialmusicdiscovery.server.api.plugin

Examples of org.socialmusicdiscovery.server.api.plugin.Plugin


            // /META-INF/services/org.socialmusicdiscovery.server.api.plugin.Plugin
            Map<String, Plugin> plugins = new HashMap<String, Plugin>();
            ServiceLoader<Plugin> pluginLoader = ServiceLoader.load(Plugin.class);
            Iterator<Plugin> pluginIterator = pluginLoader.iterator();
            while (pluginIterator.hasNext()) {
                Plugin plugin = pluginIterator.next();
                plugins.put(plugin.getId(), plugin);
            }

            pluginManager = new PluginManager(plugins);
        }
        return pluginManager;
View Full Code Here


    public void startAll() {
        List<String> pluginIdentities = new ArrayList<String>(plugins.keySet());
        Collections.sort(pluginIdentities, new Comparator<String>() {
            @Override
            public int compare(String p1, String p2) {
                Plugin plugin1 = plugins.get(p1);
                Plugin plugin2 = plugins.get(p2);
                return new CompareToBuilder().append(plugin1.getStartPriority(), plugin2.getStartPriority()).toComparison();
            }
        });

        for (String pluginId : pluginIdentities) {
            if (!runningPlugins.containsKey(pluginId)) {
View Full Code Here

     * @param pluginId The plugin identity, this is the value from {@link org.socialmusicdiscovery.server.api.plugin.Plugin#getId()}
     * @throws PluginException If the plugin or one of its dependent plugins fails to start
     */
    public void startPlugin(String pluginId) throws PluginException {
        if (!runningPlugins.containsKey(pluginId)) {
            Plugin plugin = plugins.get(pluginId);
            if (plugin != null) {
                List<String> dependencies = plugin.getDependencies();
                for (String dependency : dependencies) {
                    if (!runningPlugins.containsKey(dependency)) {
                        startPlugin(dependency);
                    }
                }
                System.out.println("Starting " + pluginId + ": " + plugin.getClass().getName());
                System.out.flush();
                if (plugin.start()) {
                    runningPlugins.put(pluginId, plugin);
                }
                System.out.println("Started " + pluginId + ": OK");
            }
        }
View Full Code Here

     * Stop the plugin with the specified identity
     * @param pluginId The plugin identity, this is the value from {@link org.socialmusicdiscovery.server.api.plugin.Plugin#getId()}
     * @throws PluginException If the plugin fails to be stopped
     */
    public void stopPlugin(String pluginId) throws PluginException {
        Plugin plugin = runningPlugins.get(pluginId);
        if (plugin != null) {
            System.out.println("Stopping " + pluginId + ": " + plugin.getClass().getName());
            plugin.stop();
            runningPlugins.remove(pluginId);
            System.out.println("Stopped " + pluginId + ": OK");
        }
    }
View Full Code Here

TOP

Related Classes of org.socialmusicdiscovery.server.api.plugin.Plugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.