Search in sources :

Example 16 with IPlatformPlugin

use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method getStaticResource.

@Override
public InputStream getStaticResource(String path) {
    for (IPlatformPlugin plugin : PentahoSystem.getAll(IPlatformPlugin.class)) {
        Map<String, String> resourceMap = plugin.getStaticResourceMap();
        for (String url : resourceMap.keySet()) {
            if (isRequested(url, path)) {
                IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
                ClassLoader classLoader = PentahoSystem.get(ClassLoader.class, null, Collections.singletonMap(PLUGIN_ID, plugin.getId()));
                String resourcePath = path.replace(url, resourceMap.get(url));
                return resLoader.getResourceAsStream(classLoader, resourcePath);
            }
        }
    }
    return null;
}
Also used : IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin)

Example 17 with IPlatformPlugin

use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method getRegisteredPlugins.

@Override
public List<String> getRegisteredPlugins() {
    List<String> retList = new ArrayList<String>();
    final List<IPlatformPlugin> plugins = PentahoSystem.getAll(IPlatformPlugin.class);
    for (IPlatformPlugin plugin : plugins) {
        retList.add(plugin.getId());
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin)

Example 18 with IPlatformPlugin

use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoadBeanDefinition.

@SuppressWarnings("deprecation")
@Test
public void testLoadBeanDefinition() throws PlatformPluginRegistrationException {
    microPlatform.init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);
    Collection<PluginBeanDefinition> beans = plugin.getBeans();
    assertEquals("FooComponent was not loaded", 1, CollectionUtils.countMatches(beans, new Predicate() {

        public boolean evaluate(Object object) {
            PluginBeanDefinition bean = (PluginBeanDefinition) object;
            return bean.getBeanId().equals("FooComponent") && bean.getClassname().equals("org.pentaho.test.platform.plugin.pluginmgr.FooComponent");
        }
    }));
    assertEquals("genericBean was not loaded", 1, CollectionUtils.countMatches(beans, new Predicate() {

        public boolean evaluate(Object object) {
            PluginBeanDefinition bean = (PluginBeanDefinition) object;
            return bean.getBeanId().equals("genericBean") && bean.getClassname().equals("java.lang.Object");
        }
    }));
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) PluginBeanDefinition(org.pentaho.platform.api.engine.PluginBeanDefinition) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Example 19 with IPlatformPlugin

use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoadContentGenerators.

@SuppressWarnings("deprecation")
@Test
public void testLoadContentGenerators() throws PlatformPluginRegistrationException {
    microPlatform.init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("content-generator-plugin"));
    assertNotNull("content-generator-plugin should have been found", plugin);
    List<IContentInfo> contentTypes = plugin.getContentInfos();
    Object contentType = CollectionUtils.find(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getTitle().equals("Good Test Type");
        }
    });
    assertNotNull("\"Good Test Type\" should have been loaded", contentType);
    assertNotNull("\"Good Test Type\" extension definition is incorrect", ((IContentInfo) contentType).getExtension().equals("good-content-type"));
    IContentInfo contentInfo = (IContentInfo) contentType;
    IPluginOperation operation = contentInfo.getOperations().listIterator().next();
    assertEquals("Missing perspective", "custom-perspective", operation.getPerspective());
    assertEquals("\"Test Type Missing type\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getTitle().equals("Test Type Missing type");
        }
    }));
    assertEquals("\"test-type-missing-title\" should not have been loaded", 0, CollectionUtils.countMatches(contentTypes, new Predicate() {

        public boolean evaluate(Object object) {
            IContentInfo type = (IContentInfo) object;
            return type.getExtension().equals("test-type-missing-title");
        }
    }));
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPluginOperation(org.pentaho.platform.api.engine.IPluginOperation) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Example 20 with IPlatformPlugin

use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.

the class SystemPathPluginProviderIT method testLoad_Good.

@SuppressWarnings("deprecation")
@Test
public void testLoad_Good() throws PlatformPluginRegistrationException {
    microPlatform.init();
    PluginMessageLogger.clear();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
    // should successfully load good-plugin1 and good-plugin2 and not load bad-plugin. The fact
    // that bad-plugin does not load should not prevent the good ones from being loaded
    assertTrue("plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1")));
    assertTrue("plugin2 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 2")));
    // make sure that the bad plugin caused an error message to be logged
    assertEquals("bad plugin did not log an error message", 1, PluginMessageLogger.count("SystemPathXmlPluginProvider.ERROR_0001"));
    for (String msg : PluginMessageLogger.getAll()) {
        System.err.println(msg);
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Test(org.junit.Test)

Aggregations

IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)21 Test (org.junit.Test)9 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)7 PlatformPluginRegistrationException (org.pentaho.platform.api.engine.PlatformPluginRegistrationException)6 IPluginProvider (org.pentaho.platform.api.engine.IPluginProvider)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 ArrayList (java.util.ArrayList)3 Predicate (org.apache.commons.collections.Predicate)3 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)3 File (java.io.File)2 IPentahoObjectRegistration (org.pentaho.platform.api.engine.IPentahoObjectRegistration)2 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)2 IServiceManager (org.pentaho.platform.api.engine.IServiceManager)2 PluginBeanDefinition (org.pentaho.platform.api.engine.PluginBeanDefinition)2 ServiceInitializationException (org.pentaho.platform.api.engine.ServiceInitializationException)2 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1