use of org.pentaho.platform.api.engine.IContentGeneratorInfo in project pentaho-platform by pentaho.
the class PentahoSystemPluginManager method registerContentGenerators.
private void registerContentGenerators(IPlatformPlugin plugin, ClassLoader loader, final GenericApplicationContext beanFactory) throws PlatformPluginRegistrationException {
// register the content generators
for (final IContentGeneratorInfo cgInfo : plugin.getContentGenerators()) {
// define the bean in the factory
BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition(cgInfo.getClassname()).setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
// register bean with alias of content generator id (old way)
beanFactory.registerBeanDefinition(cgInfo.getId(), beanDef);
// register bean with alias of type (with default perspective) as well (new way)
beanFactory.registerAlias(cgInfo.getId(), cgInfo.getType());
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.USER_CONTENT_GENERATOR_REGISTERED", cgInfo.getId(), plugin.getId()));
final HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(PLUGIN_ID, plugin.getId());
attributes.put(CONTENT_TYPE, cgInfo.getType());
final IPentahoObjectRegistration referenceHandle = PentahoSystem.registerReference(new PrototypePentahoObjectReference.Builder<IContentGenerator>(IContentGenerator.class).creator(new IObjectCreator<IContentGenerator>() {
@Override
public IContentGenerator create(IPentahoSession session) {
return (IContentGenerator) beanFactory.getBean(cgInfo.getId());
}
}).attributes(attributes).build(), IContentGenerator.class);
registerReference(plugin.getId(), referenceHandle);
}
// The remaining operations require a beanFactory
if (beanFactory == null) {
return;
}
String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory.getBeanFactory(), IContentGenerator.class);
ArrayList<String> ids = new ArrayList<String>();
for (String beanName : names) {
ids.add(beanName);
Collections.addAll(ids, beanFactory.getAliases(beanName));
}
for (final String beanName : ids) {
final HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(PLUGIN_ID, plugin.getId());
attributes.put(CONTENT_TYPE, beanName);
final IPentahoObjectRegistration referenceHandle = PentahoSystem.registerReference(new PrototypePentahoObjectReference.Builder<IContentGenerator>(IContentGenerator.class).creator(new IObjectCreator<IContentGenerator>() {
@Override
public IContentGenerator create(IPentahoSession session) {
return (IContentGenerator) beanFactory.getBean(beanName);
}
}).attributes(attributes).build(), IContentGenerator.class);
registerReference(plugin.getId(), referenceHandle);
}
}
use of org.pentaho.platform.api.engine.IContentGeneratorInfo in project pentaho-platform by pentaho.
the class DefaultPluginManager method registerContentGenerators.
private void registerContentGenerators(IPlatformPlugin plugin, ClassLoader loader) throws PlatformPluginRegistrationException {
// register the content generators
for (IContentGeneratorInfo cgInfo : plugin.getContentGenerators()) {
// define the bean in the factory
BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition(cgInfo.getClassname()).setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
GenericApplicationContext factory = beanFactoryMap.get(plugin.getId());
// register bean with alias of content generator id (old way)
factory.registerBeanDefinition(cgInfo.getId(), beanDef);
// register bean with alias of type (with default perspective) as well (new way)
factory.registerAlias(cgInfo.getId(), cgInfo.getType());
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.USER_CONTENT_GENERATOR_REGISTERED", cgInfo.getId(), // $NON-NLS-1$
plugin.getId()));
}
}
use of org.pentaho.platform.api.engine.IContentGeneratorInfo in project pentaho-platform by pentaho.
the class SystemPathXmlPluginProvider method processContentGenerators.
protected void processContentGenerators(PlatformPlugin plugin, Document doc, IPentahoSession session, String folder, boolean hasLib) {
// look for content generators
// $NON-NLS-1$
List<?> nodes = doc.selectNodes("//content-generator");
for (Object obj : nodes) {
Element node = (Element) obj;
// $NON-NLS-1$
String className = getProperty(node, "class");
if (className == null) {
// $NON-NLS-1$
className = XmlDom4JHelper.getNodeText("classname", node, null);
}
// $NON-NLS-1$
String id = node.attributeValue("id");
// $NON-NLS-1$
String type = node.attributeValue("type");
// $NON-NLS-1$
String url = node.attributeValue("url");
// $NON-NLS-1$
String title = getProperty(node, "title");
// $NON-NLS-1$
String description = getProperty(node, "description");
try {
if (id != null && type != null && className != null && title != null) {
try {
IContentGeneratorInfo info = createContentGenerator(plugin, id, title, description, type, url, className, session, folder);
plugin.addContentGenerator(info);
} catch (Exception e) {
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.USER_CONTENT_GENERATOR_NOT_REGISTERED", id, // $NON-NLS-1$
folder));
}
} else {
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.USER_CONTENT_GENERATOR_NOT_REGISTERED", id, // $NON-NLS-1$
folder));
}
} catch (Exception e) {
PluginMessageLogger.add(Messages.getInstance().getString("PluginManager.USER_CONTENT_GENERATOR_NOT_REGISTERED", id, // $NON-NLS-1$
folder));
Logger.error(getClass().toString(), Messages.getInstance().getErrorString("PluginManager.ERROR_0006_CANNOT_CREATE_CONTENT_GENERATOR_FACTORY", folder), // $NON-NLS-1$
e);
}
}
}
use of org.pentaho.platform.api.engine.IContentGeneratorInfo in project pentaho-platform by pentaho.
the class SystemPathXmlPluginProvider method createContentGenerator.
private static IContentGeneratorInfo createContentGenerator(PlatformPlugin plugin, String id, String title, String description, String type, String url, String className, IPentahoSession session, String location) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
ContentGeneratorInfo info = new ContentGeneratorInfo();
info.setId(id);
info.setTitle(title);
info.setDescription(description);
// $NON-NLS-1$
info.setUrl((url != null) ? url : "");
info.setType(type);
info.setClassname(className);
return info;
}
Aggregations