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