use of org.pentaho.platform.api.engine.IServiceManager in project pentaho-platform by pentaho.
the class DefaultPluginManager method reload.
@Override
public final boolean reload() {
IPentahoSession session = PentahoSessionHolder.getSession();
boolean anyErrors = false;
IPluginProvider pluginProvider = PentahoSystem.get(IPluginProvider.class, "IPluginProvider", session);
List<IPlatformPlugin> providedPlugins = null;
try {
synchronized (registeredPlugins) {
this.unloadPlugins();
}
// the plugin may fail to load during getPlugins without an exception thrown if the provider
// is capable of discovering the plugin fine but there are structural problems with the plugin
// itself. In this case a warning should be logged by the provider, but, again, no exception
// is expected.
providedPlugins = pluginProvider.getPlugins(session);
} catch (PlatformPluginRegistrationException e1) {
String msg = // $NON-NLS-1$
Messages.getInstance().getErrorString("PluginManager.ERROR_0012_PLUGIN_DISCOVERY_FAILED");
Logger.error(getClass().toString(), msg, e1);
PluginMessageLogger.add(msg);
anyErrors = true;
}
synchronized (providedPlugins) {
for (IPlatformPlugin plugin : providedPlugins) {
try {
registeredPlugins.put(plugin.getId(), plugin);
ClassLoader loader = setPluginClassLoader(plugin);
initializeBeanFactory(plugin, loader);
} catch (Throwable t) {
// this has been logged already
anyErrors = true;
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0011_FAILED_TO_REGISTER_PLUGIN", // $NON-NLS-1$
plugin.getId());
Logger.error(getClass().toString(), msg, t);
PluginMessageLogger.add(msg);
}
}
registeredPlugins.clear();
for (IPlatformPlugin plugin : providedPlugins) {
try {
GenericApplicationContext beanFactory = beanFactoryMap.get(plugin.getId());
if (beanFactory != null) {
beanFactory.refresh();
}
registerPlugin(plugin);
registeredPlugins.put(plugin.getId(), plugin);
} catch (Throwable t) {
// this has been logged already
anyErrors = true;
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0011_FAILED_TO_REGISTER_PLUGIN", // $NON-NLS-1$
plugin.getId());
Logger.error(getClass().toString(), msg, t);
PluginMessageLogger.add(msg);
}
}
}
IServiceManager svcManager = PentahoSystem.get(IServiceManager.class, null);
if (svcManager != null) {
try {
svcManager.initServices();
} catch (ServiceInitializationException e) {
String msg = Messages.getInstance().getErrorString(// $NON-NLS-1$
"PluginManager.ERROR_0022_SERVICE_INITIALIZATION_FAILED");
Logger.error(getClass().toString(), msg, e);
PluginMessageLogger.add(msg);
}
}
return !anyErrors;
}
use of org.pentaho.platform.api.engine.IServiceManager in project pentaho-platform by pentaho.
the class PentahoSystemPluginManager method reload.
@Override
public boolean reload(IPentahoSession session) {
boolean anyErrors = false;
IPluginProvider pluginProvider = PentahoSystem.get(IPluginProvider.class, "IPluginProvider", session);
List<IPlatformPlugin> providedPlugins = Collections.emptyList();
try {
this.unloadPlugins();
// the plugin may fail to load during getPlugins without an exception thrown if the provider
// is capable of discovering the plugin fine but there are structural problems with the plugin
// itself. In this case a warning should be logged by the provider, but, again, no exception
// is expected.
providedPlugins = pluginProvider.getPlugins(session);
} catch (PlatformPluginRegistrationException e1) {
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0012_PLUGIN_DISCOVERY_FAILED");
org.pentaho.platform.util.logging.Logger.error(getClass().toString(), msg, e1);
PluginMessageLogger.add(msg);
anyErrors = true;
}
for (IPlatformPlugin plugin : providedPlugins) {
try {
IPlatformPlugin existingPlugin = PentahoSystem.get(IPlatformPlugin.class, null, Collections.singletonMap(PLUGIN_ID, plugin.getId()));
if (existingPlugin != null) {
throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0024_PLUGIN_ALREADY_LOADED_BY_SAME_NAME", plugin.getId()));
}
final ClassLoader classloader = createClassloader(plugin);
// Register the classloader, Spring App Context and Object Factory with PentahoSystem
IPentahoObjectRegistration handle = PentahoSystem.registerReference(new SingletonPentahoObjectReference.Builder<IPlatformPlugin>(IPlatformPlugin.class).object(plugin).attributes(Collections.<String, Object>singletonMap(PLUGIN_ID, plugin.getId())).build(), IPlatformPlugin.class);
registerReference(plugin.getId(), handle);
handle = PentahoSystem.registerReference(new SingletonPentahoObjectReference.Builder<ClassLoader>(ClassLoader.class).object(classloader).attributes(Collections.<String, Object>singletonMap(PLUGIN_ID, plugin.getId())).build(), ClassLoader.class);
registerReference(plugin.getId(), handle);
final GenericApplicationContext beanFactory = createBeanFactory(plugin, classloader);
final StandaloneSpringPentahoObjectFactory pentahoFactory = new StandaloneSpringPentahoObjectFactory("Plugin Factory ( " + plugin.getId() + " )");
pentahoFactory.init(null, beanFactory);
beanFactory.refresh();
handle = PentahoSystem.registerReference(new SingletonPentahoObjectReference.Builder<GenericApplicationContext>(GenericApplicationContext.class).object(beanFactory).attributes(Collections.<String, Object>singletonMap(PLUGIN_ID, plugin.getId())).build(), IPentahoRegistrableObjectFactory.Types.ALL);
registerReference(plugin.getId(), handle);
handle = PentahoSystem.registerReference(new SingletonPentahoObjectReference.Builder<IPentahoObjectFactory>(IPentahoObjectFactory.class).object(pentahoFactory).attributes(Collections.<String, Object>singletonMap(PLUGIN_ID, plugin.getId())).build(), IPentahoObjectFactory.class);
registerReference(plugin.getId(), handle);
} catch (Throwable t) {
// this has been logged already
anyErrors = true;
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0011_FAILED_TO_REGISTER_PLUGIN", plugin.getId());
org.pentaho.platform.util.logging.Logger.error(getClass().toString(), msg, t);
PluginMessageLogger.add(msg);
}
}
for (IPlatformPlugin plugin : providedPlugins) {
try {
registerPlugin(plugin);
} catch (Throwable t) {
// this has been logged already
anyErrors = true;
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0011_FAILED_TO_REGISTER_PLUGIN", plugin.getId());
org.pentaho.platform.util.logging.Logger.error(getClass().toString(), msg, t);
PluginMessageLogger.add(msg);
}
}
IServiceManager svcManager = PentahoSystem.get(IServiceManager.class, null);
if (svcManager != null) {
try {
svcManager.initServices();
} catch (ServiceInitializationException e) {
String msg = Messages.getInstance().getErrorString("PluginManager.ERROR_0022_SERVICE_INITIALIZATION_FAILED");
org.pentaho.platform.util.logging.Logger.error(getClass().toString(), msg, e);
PluginMessageLogger.add(msg);
}
}
for (IPluginManagerListener listener : listeners) {
listener.onReload();
}
return !anyErrors;
}
use of org.pentaho.platform.api.engine.IServiceManager in project pentaho-platform by pentaho.
the class GwtRpcPluginProxyServlet method resolveDispatchTarget.
@Override
protected Object resolveDispatchTarget(String servletContextPath) {
IServiceManager serviceManager = PentahoSystem.get(IServiceManager.class, PentahoSessionHolder.getSession());
String key = getDispatchKey();
if (null == serviceManager.getServiceConfig("gwt", key)) {
// $NON-NLS-1$
String errMsg = // $NON-NLS-1$
Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0001_SERVICE_NOT_FOUND", key);
logger.error(errMsg);
throw new GwtRpcProxyException(errMsg);
}
Object targetBean = null;
try {
// $NON-NLS-1$
targetBean = serviceManager.getServiceBean("gwt", key);
} catch (ServiceException e) {
throw new GwtRpcProxyException(Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0002_FAILED_TO_GET_BEAN_REFERENCE", key), // $NON-NLS-1$
e);
}
return targetBean;
}
Aggregations