use of org.pentaho.platform.api.engine.PluginServiceDefinition in project pentaho-platform by pentaho.
the class SystemPathXmlPluginProvider method processWebservices.
protected void processWebservices(PlatformPlugin plugin, Document doc) {
// $NON-NLS-1$
List<?> nodes = doc.selectNodes("//webservice");
for (Object obj : nodes) {
Element node = (Element) obj;
PluginServiceDefinition pws = new PluginServiceDefinition();
// $NON-NLS-1$
pws.setId(getProperty(node, "id"));
// $NON-NLS-1$
String type = getProperty(node, "type");
if (!StringUtils.isEmpty(type)) {
// $NON-NLS-1$
pws.setTypes(type.split(","));
}
// $NON-NLS-1$
pws.setTitle(getProperty(node, "title"));
// $NON-NLS-1$
pws.setDescription(getProperty(node, "description"));
// TODO: add support for inline service class definition
// $NON-NLS-1$
pws.setServiceBeanId(getProperty(node, "ref"));
// $NON-NLS-1$
pws.setServiceClass(getProperty(node, "class"));
Collection<String> extraClasses = new ArrayList<String>();
// $NON-NLS-1$
List<?> extraNodes = node.selectNodes("extra");
for (Object extra : extraNodes) {
Element extraElement = (Element) extra;
// $NON-NLS-1$
String extraClass = getProperty(extraElement, "class");
if (extraClasses != null) {
extraClasses.add(extraClass);
}
}
pws.setExtraClasses(extraClasses);
if (pws.getServiceBeanId() == null && pws.getServiceClass() == null) {
// $NON-NLS-1$
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.NO_SERVICE_CLASS_FOUND"));
} else {
plugin.addWebservice(pws);
}
}
}
use of org.pentaho.platform.api.engine.PluginServiceDefinition 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