use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.
the class SystemPathXmlPluginProvider method getPlugins.
/**
* Gets the list of plugins that this provider class has discovered.
*
* @return an read-only list of plugins
* @see IPluginProvider#getPlugins()
* @throws PlatformPluginRegistrationException
* if there is a problem preventing the impl from looking for plugins
*/
public List<IPlatformPlugin> getPlugins(IPentahoSession session) throws PlatformPluginRegistrationException {
List<IPlatformPlugin> plugins = new ArrayList<IPlatformPlugin>();
// look in each of the system setting folders looking for plugin.xml files
// $NON-NLS-1$
String systemPath = PentahoSystem.getApplicationContext().getSolutionPath("system");
File systemDir = new File(systemPath);
if (!systemDir.exists() || !systemDir.isDirectory()) {
throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"PluginManager.ERROR_0004_CANNOT_FIND_SYSTEM_FOLDER"));
}
File[] kids = systemDir.listFiles();
// look at each child to see if it is a folder
for (File kid : kids) {
if (kid.isDirectory()) {
try {
processDirectory(plugins, kid, session);
} catch (Throwable t) {
// don't throw an exception. we need to continue to process any remaining good plugins
String msg = Messages.getInstance().getErrorString("SystemPathXmlPluginProvider.ERROR_0001_FAILED_TO_PROCESS_PLUGIN", // $NON-NLS-1$
kid.getAbsolutePath());
Logger.error(getClass().toString(), msg, t);
PluginMessageLogger.add(msg);
}
}
}
return Collections.unmodifiableList(plugins);
}
use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.
the class DefaultPluginManagerIT method test17_getPluginIdForType.
@Test
public void test17_getPluginIdForType() throws PlatformInitializationException, PluginBeanException {
IPluginProvider provider = new IPluginProvider() {
public List<IPlatformPlugin> getPlugins(IPentahoSession session) throws PlatformPluginRegistrationException {
PlatformPlugin p = new PlatformPlugin(new DefaultListableBeanFactory());
p.setId("testPlugin");
ContentGeneratorInfo cg1 = new ContentGeneratorInfo();
cg1.setDescription("test 9 plugin description");
cg1.setId("oldworldCGid");
cg1.setType("oldworldCGtype");
cg1.setTitle("test");
cg1.setClassname("org.pentaho.test.platform.plugin.pluginmgr.ContentGenerator1");
// cg1.setFileInfoGeneratorClassname("org.pentaho.test.platform.plugin.pluginmgr.FileInfoGenerator");
p.addContentGenerator(cg1);
BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition("org.pentaho.test.platform.plugin.pluginmgr.ContentGenerator1").setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
p.getBeanFactory().registerBeanDefinition("springDefinedCGid", beanDef);
p.getBeanFactory().registerAlias("springDefinedCGid", "springDefinedCGtype");
return Arrays.asList((IPlatformPlugin) p);
}
};
microPlatform.defineInstance(IPluginProvider.class, provider).start();
pluginManager.reload();
assertEquals("testPlugin", pluginManager.getPluginIdForType("oldworldCGtype"));
assertEquals("testPlugin", pluginManager.getPluginIdForType("springDefinedCGtype"));
}
use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.
the class SystemPathPluginProviderIT method tesLoadtLifecycleListener.
@SuppressWarnings("deprecation")
@Test
public void tesLoadtLifecycleListener() throws PlatformPluginRegistrationException {
microPlatform.init();
PluginMessageLogger.clear();
List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
// first make sure Plugin 1 was loaded, otherwise our check for lifcycle class will never happen
assertTrue("plugin1 was not found", CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1")));
for (IPlatformPlugin plugin : plugins) {
if (plugin.getId().equals("Plugin 1")) {
assertEquals("org.pentaho.test.platform.plugin.pluginmgr.FooInitializer", plugin.getLifecycleListenerClassname());
}
if (plugin.getId().equals("Plugin 2")) {
// no listener defined to for Plugin 2
assertNull(plugin.getLifecycleListenerClassname());
}
}
}
use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.
the class SystemPathPluginProviderIT method testLoadLifeCycleListener.
@SuppressWarnings("deprecation")
@Test
public void testLoadLifeCycleListener() 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);
assertEquals("org.pentaho.test.platform.plugin.pluginmgr.FooInitializer", plugin.getLifecycleListenerClassname());
}
use of org.pentaho.platform.api.engine.IPlatformPlugin in project pentaho-platform by pentaho.
the class SystemPathPluginProviderIT method testLoadWebservices.
@SuppressWarnings("deprecation")
@Test
public void testLoadWebservices() throws PlatformPluginRegistrationException {
microPlatform.init();
List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());
System.out.println(PluginMessageLogger.getAll());
IPlatformPlugin plugin = (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
assertNotNull("Plugin 1 should have been found", plugin);
Collection<PluginServiceDefinition> webservices = plugin.getServices();
Object wsobj = CollectionUtils.find(webservices, new Predicate() {
public boolean evaluate(Object object) {
PluginServiceDefinition ws = (PluginServiceDefinition) object;
boolean ret = ws.getTitle().equals("%TestWS1.TITLE%");
return ret;
}
});
assertNotNull("Webservice \"%TestWS1.TITLE%\" should have been loaded", wsobj);
PluginServiceDefinition wsDfn = (PluginServiceDefinition) wsobj;
assertEquals("org.pentaho.test.platform.engine.core.EchoServiceBean", wsDfn.getServiceClass());
assertEquals("xml", wsDfn.getTypes()[0]);
assertEquals("gwt", wsDfn.getTypes()[1]);
assertEquals("A test webservice", wsDfn.getDescription());
assertEquals(1, wsDfn.getExtraClasses().size());
assertEquals("java.lang.String", wsDfn.getExtraClasses().iterator().next());
}
Aggregations