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;
}
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;
}
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");
}
}));
}
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");
}
}));
}
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);
}
}
Aggregations