Search in sources :

Example 1 with PluginServiceDefinition

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);
        }
    }
}
Also used : PluginServiceDefinition(org.pentaho.platform.api.engine.PluginServiceDefinition) Element(org.dom4j.Element) ArrayList(java.util.ArrayList)

Example 2 with PluginServiceDefinition

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());
}
Also used : PluginServiceDefinition(org.pentaho.platform.api.engine.PluginServiceDefinition) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPlatformPlugin(org.pentaho.platform.api.engine.IPlatformPlugin) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Aggregations

PluginServiceDefinition (org.pentaho.platform.api.engine.PluginServiceDefinition)2 ArrayList (java.util.ArrayList)1 Predicate (org.apache.commons.collections.Predicate)1 Element (org.dom4j.Element)1 Test (org.junit.Test)1 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)1 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)1