Search in sources :

Example 1 with ServiceConfig

use of org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig in project pentaho-platform by pentaho.

the class StubServiceSetup method setEnabled.

@Override
public boolean setEnabled(String name, boolean enabled) {
    ServiceConfig wrapper = (ServiceConfig) getWebServiceDefinition(name);
    wrapper.setEnabled(enabled);
    // axisService.setActive( enabled );
    return true;
}
Also used : IServiceConfig(org.pentaho.platform.api.engine.IServiceConfig) ServiceConfig(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig)

Example 2 with ServiceConfig

use of org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig in project pentaho-platform by pentaho.

the class DefaultServiceManagerTest method testServiceRegistration.

@Test
public void testServiceRegistration() throws ServiceException {
    ServiceConfig config = new ServiceConfig();
    config.setId("testId");
    config.setServiceClass(EchoServiceBean.class);
    config.setServiceType("gwt");
    serviceManager.registerService(config);
    assertNotNull(serviceManager.getServiceConfig("gwt", "testId"));
}
Also used : IServiceConfig(org.pentaho.platform.api.engine.IServiceConfig) ServiceConfig(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig) Test(org.junit.Test)

Example 3 with ServiceConfig

use of org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig in project pentaho-platform by pentaho.

the class DefaultServiceManagerTest method testRegisterInvalidService.

@Test(expected = IllegalStateException.class)
public void testRegisterInvalidService() throws ServiceException {
    ServiceConfig config = new ServiceConfig();
    serviceManager.registerService(config);
}
Also used : IServiceConfig(org.pentaho.platform.api.engine.IServiceConfig) ServiceConfig(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig) Test(org.junit.Test)

Example 4 with ServiceConfig

use of org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig in project pentaho-platform by pentaho.

the class DefaultPluginManager method createServiceConfigs.

/*
   * A utility method to convert plugin version of webservice definition to the official engine version consumable by an
   * IServiceManager
   */
private Collection<ServiceConfig> createServiceConfigs(PluginServiceDefinition pws, IPlatformPlugin plugin, ClassLoader loader) throws PlatformPluginRegistrationException {
    Collection<ServiceConfig> services = new ArrayList<ServiceConfig>();
    // 
    if (pws.getTypes() == null || pws.getTypes().length < 1) {
        throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0023_SERVICE_TYPE_UNSPECIFIED", // $NON-NLS-1$
        pws.getId()));
    }
    for (String type : pws.getTypes()) {
        ServiceConfig ws = new ServiceConfig();
        ws.setServiceType(type);
        ws.setTitle(pws.getTitle());
        ws.setDescription(pws.getDescription());
        String serviceClassName = (StringUtils.isEmpty(pws.getServiceClass())) ? pws.getServiceBeanId() : pws.getServiceClass();
        String serviceId;
        if (!StringUtils.isEmpty(pws.getId())) {
            serviceId = pws.getId();
        } else {
            serviceId = serviceClassName;
            if (serviceClassName.indexOf('.') > 0) {
                serviceId = serviceClassName.substring(serviceClassName.lastIndexOf('.') + 1);
            }
        }
        ws.setId(serviceId);
        // Register the service class
        // 
        final String serviceClassKey = // $NON-NLS-1$ //$NON-NLS-2$
        ws.getServiceType() + "-" + ws.getId() + "/" + serviceClassName;
        assertUnique(plugin.getId(), serviceClassKey);
        // defining plugin beans the old way through the plugin provider ifc supports only prototype scope
        BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition(serviceClassName).setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
        beanFactoryMap.get(plugin.getId()).registerBeanDefinition(serviceClassKey, beanDef);
        if (!this.isBeanRegistered(serviceClassKey)) {
            throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0020_NO_SERVICE_CLASS_REGISTERED", // $NON-NLS-1$
            serviceClassKey));
        }
        // 
        try {
            ws.setServiceClass(loadClass(serviceClassKey));
            ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
            if (pws.getExtraClasses() != null) {
                for (String extraClass : pws.getExtraClasses()) {
                    classes.add(loadClass(extraClass));
                }
            }
            ws.setExtraClasses(classes);
        } catch (PluginBeanException e) {
            throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0021_SERVICE_CLASS_LOAD_FAILED", serviceClassKey), // $NON-NLS-1$
            e);
        }
        services.add(ws);
    }
    return services;
}
Also used : PluginBeanException(org.pentaho.platform.api.engine.PluginBeanException) ServiceConfig(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig) ArrayList(java.util.ArrayList) PluginBeanDefinition(org.pentaho.platform.api.engine.PluginBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) PlatformPluginRegistrationException(org.pentaho.platform.api.engine.PlatformPluginRegistrationException)

Example 5 with ServiceConfig

use of org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig in project pentaho-platform by pentaho.

the class PentahoSystemPluginManager method createServiceConfigs.

/*
 * A utility method to convert plugin version of webservice definition to the official engine version consumable by an
 * IServiceManager
 */
private Collection<ServiceConfig> createServiceConfigs(PluginServiceDefinition pws, IPlatformPlugin plugin, ClassLoader loader, GenericApplicationContext beanFactory) throws PlatformPluginRegistrationException {
    Collection<ServiceConfig> services = new ArrayList<ServiceConfig>();
    // 
    if (pws.getTypes() == null || pws.getTypes().length < 1) {
        throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0023_SERVICE_TYPE_UNSPECIFIED", pws.getId()));
    }
    for (String type : pws.getTypes()) {
        ServiceConfig ws = new ServiceConfig();
        ws.setServiceType(type);
        ws.setTitle(pws.getTitle());
        ws.setDescription(pws.getDescription());
        String serviceClassName = (StringUtils.isEmpty(pws.getServiceClass())) ? pws.getServiceBeanId() : pws.getServiceClass();
        String serviceId;
        if (!StringUtils.isEmpty(pws.getId())) {
            serviceId = pws.getId();
        } else {
            serviceId = serviceClassName;
            if (serviceClassName.indexOf('.') > 0) {
                serviceId = serviceClassName.substring(serviceClassName.lastIndexOf('.') + 1);
            }
        }
        ws.setId(serviceId);
        // Register the service class
        // 
        final String serviceClassKey = ws.getServiceType() + "-" + ws.getId() + "/" + serviceClassName;
        assertUnique(beanFactory, plugin.getId(), serviceClassKey);
        // defining plugin beans the old way through the plugin provider ifc supports only prototype scope
        BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition(serviceClassName).setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
        beanFactory.registerBeanDefinition(serviceClassKey, beanDef);
        if (!this.isBeanRegistered(serviceClassKey)) {
            throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0020_NO_SERVICE_CLASS_REGISTERED", serviceClassKey));
        }
        // 
        try {
            ws.setServiceClass(loadClass(serviceClassKey));
            ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
            if (pws.getExtraClasses() != null) {
                for (String extraClass : pws.getExtraClasses()) {
                    classes.add(loadClass(extraClass));
                }
            }
            ws.setExtraClasses(classes);
        } catch (PluginBeanException e) {
            throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0021_SERVICE_CLASS_LOAD_FAILED", serviceClassKey), e);
        }
        services.add(ws);
    }
    return services;
}
Also used : PluginBeanException(org.pentaho.platform.api.engine.PluginBeanException) ServiceConfig(org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig) ArrayList(java.util.ArrayList) PluginBeanDefinition(org.pentaho.platform.api.engine.PluginBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) PlatformPluginRegistrationException(org.pentaho.platform.api.engine.PlatformPluginRegistrationException)

Aggregations

ServiceConfig (org.pentaho.platform.plugin.services.pluginmgr.servicemgr.ServiceConfig)5 IServiceConfig (org.pentaho.platform.api.engine.IServiceConfig)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 PlatformPluginRegistrationException (org.pentaho.platform.api.engine.PlatformPluginRegistrationException)2 PluginBeanDefinition (org.pentaho.platform.api.engine.PluginBeanDefinition)2 PluginBeanException (org.pentaho.platform.api.engine.PluginBeanException)2 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)2