Package net.xeoh.plugins.base

Examples of net.xeoh.plugins.base.PluginManager


        final JSPFProperties props = new JSPFProperties();

        props.setProperty(PluginManager.class, "cache.enabled", "true");
        props.setProperty(PluginManager.class, "cache.file", "myjspf.cache");

        final PluginManager pm = PluginManagerFactory.createPluginManager(props);

        DiscoveryMangerFileImpl dmp = new DiscoveryMangerFileImpl();
        dmp.anouncePlugin(pm, PublishMethod.JAVASCRIPT, new URI("http://xxx.com"));

        Thread.sleep(2000);
View Full Code Here


        /*
         * The is the only time you have to access a class directly. Just returns the
         * Plugin manager.
         */
        final PluginManager pmf = PluginManagerFactory.createPluginManager();

        /*
         * Add plugins from somewhere. Be sure to put *the right path* in here. This
         * method may be called multiple times. If you plan to deliver your application
         * replace bin/ with for example myplugins.jar
         */
        pmf.addPluginsFrom(new File("target/test-classes/").toURI());

        /*
         * Obtain multiple plugins
         */
        PluginManagerUtil pmu = new PluginManagerUtil(pmf);
View Full Code Here

        /*
         * The is the only time you have to access a class directly. Just returns the
         * Plugin manager.
         */
        final PluginManager pmf = PluginManagerFactory.createPluginManager();

        /*
         * Add plugins from somewhere. Be sure to put *the right path* in here. This
         * method may be called multiple times. If you plan to deliver your application
         * replace bin/ with for example myplugins.jar
         */
        pmf.addPluginsFrom(new File("bin/").toURI());

        /*
         * Thats it. Technically all plugins have now been loaded and are running. If you
         * would like to retrieve one, do it like this:
         */
        final OutputService plugin = pmf.getPlugin(OutputService.class);
        plugin.doSomething();
    }
View Full Code Here

    @Test
    public void testMany() {
        for(int i=0; i<10000; i++) {
            System.out.println();
            System.out.println("Run " + i);
            PluginManager manager = PluginManagerFactory.createPluginManager();
            manager.addPluginsFrom(ClassURI.CLASSPATH);
            manager.shutdown();
        }
    }
View Full Code Here

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (final Exception e) {}

        // We only need the default plugins and a few of our owns
        final PluginManager pluginManager = PluginManagerFactory.createPluginManager();
        final PluginManagerUtil pluginManagerUtil = new PluginManagerUtil(pluginManager);

        pluginManager.addPluginsFrom(ClassURI.PLUGIN(PlainConverterImpl.class));
        pluginManager.addPluginsFrom(ClassURI.PLUGIN(CSVConverterImpl.class));
        pluginManager.addPluginsFrom(ClassURI.PLUGIN(XMLConverterImpl.class));
        pluginManager.addPluginsFrom(new File("plugins/").toURI());

        final MainWindow mainWindow = new MainWindow(pluginManager);
        mainWindow.setVisible(true);

        final Collection<Converter> converters = pluginManagerUtil.getPlugins(Converter.class);
View Full Code Here

    /**
     * @throws MalformedURLException
     */
    @Test
    public void testAddPluginsFrom() throws MalformedURLException {
        final PluginManager pm2 = PluginManagerFactory.createPluginManager();

        Assert.assertNull(pm2.getPlugin(TestAnnotations.class));
    }
View Full Code Here

    /**
     * @throws MalformedURLException
     */
    @Test
    public void testAddPluginsFrom() throws MalformedURLException {
        final PluginManager pm2 = PluginManagerFactory.createPluginManager();


        Assert.assertNull(pm2.getPlugin(TestAnnotations.class));
        //pm2.addPluginsFrom(new File("tests/plugins/test.coredefinition.jar").toURI());
        //pm2.addPluginsFrom(new File("tests/plugins/test.annotation.jar").toURI());
        //Assert.assertNotNull(pm2.getPlugin(TestAnnotations.class));
    }
View Full Code Here

        props.setProperty(PluginManager.class, "cache.enabled", "true");
        props.setProperty(PluginManager.class, "cache.mode", "weak");
        props.setProperty(PluginManager.class, "cache.file", "jspf.cache");

        PluginManager pm = PluginManagerFactory.createPluginManager(props);
        pm.addPluginsFrom(new URI("classpath://*"));

        TestAnnotations plugin = pm.getPlugin(TestAnnotations.class);
        RemoteAPI remote = pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {

            public boolean selectPlugin(final RemoteAPI p) {
                if (p.getPublishMethod().equals(PublishMethod.JSON)) return true;
                return false;
            }

        }));

        ExportResult exportPlugin = remote.exportPlugin(plugin);
        Collection<URI> exportURIs = exportPlugin.getExportURIs();
        for (URI uri : exportURIs) {
            System.out.println(uri);
        }
       
        Thread.sleep(6000000);

        pm.shutdown();
    }
View Full Code Here

        props.setProperty(PluginManager.class, "cache.mode", "weak");
        props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
        props.setProperty(PluginManager.class, "logging.level", "INFO");
        props.setProperty(PluginManager.class, "classpath.filter.default.pattern", "");

        PluginManager pm = PluginManagerFactory.createPluginManager(props);
        pm.addPluginsFrom(URI.create("classpath://*"));
       
        final PluginInformation pi = pm.getPlugin(PluginInformation.class);
        final InformationAuthors information = pi.getInformation(pi, InformationAuthors.class);
    }
View Full Code Here

        final JSPFProperties props = new JSPFProperties();

        props.setProperty(PluginManager.class, "cache.enabled", "true");
        props.setProperty(PluginManager.class, "cache.file", "myjspf.cache");

        PluginManager pm = PluginManagerFactory.createPluginManager(props);

        System.out.println("X");
        pm.addPluginsFrom(new URI("classpath://*"));
        pm.addPluginsFrom(new File("coolplugin.jar").toURI());
        System.out.println("Y");

        final PluginInformation pi = pm.getPlugin(PluginInformation.class);
        final PluginManagerUtil pmu = new PluginManagerUtil(pm);
        Collection<Plugin> plugins = pmu.getPlugins(Plugin.class);
        for (Plugin p : plugins) {
            Collection<String> information = pi.getInformation(Information.CLASSPATH_ORIGIN, p);
            for (String string : information) {
                System.out.println(p + ": " + string);
            }
        }

        Thread.sleep(5000);
        pm.shutdown();
    }
View Full Code Here

TOP

Related Classes of net.xeoh.plugins.base.PluginManager

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.