use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.
the class RepositoryManager method readNodeSets.
/**
* @param isInExpertMode
*/
private void readNodeSets(final IProgressMonitor monitor) {
//
// Process the contributed node sets
//
Iterator<IConfigurationElement> it = Stream.of(RepositoryManager.getExtensions(ID_NODE_SET)).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(elem -> !"true".equalsIgnoreCase(elem.getAttribute("deprecated"))).iterator();
while (it.hasNext()) {
IConfigurationElement elem = it.next();
try {
Collection<DynamicNodeTemplate> dynamicNodeTemplates = RepositoryFactory.createNodeSet(m_root, elem);
for (DynamicNodeTemplate node : dynamicNodeTemplates) {
if (monitor.isCanceled()) {
return;
}
for (Listener l : m_loadListeners) {
l.newNode(m_root, node);
}
m_nodesById.put(node.getID(), node);
String nodeName = node.getID();
nodeName = nodeName.substring(nodeName.lastIndexOf('.') + 1);
// Ask the root to lookup the category-container located
// at
// the given path
IContainerObject parentContainer = m_root.findContainer(node.getCategoryPath());
// the node to the repository root.
if (parentContainer == null) {
LOGGER.warn("Invalid category-path for node " + "contribution: '" + node.getCategoryPath() + "' - adding to root instead");
m_root.addChild(node);
} else {
// everything is fine, add the node to its parent
// category
parentContainer.addChild(node);
}
}
} catch (Throwable t) {
String message = "Node " + elem.getAttribute("factory-class") + "' from plugin '" + elem.getNamespaceIdentifier() + "' could not be created.";
Bundle bundle = Platform.getBundle(elem.getNamespaceIdentifier());
if ((bundle == null) || (bundle.getState() != Bundle.ACTIVE)) {
// if the plugin is null, the plugin could not
// be activated maybe due to a not
// activateable plugin (plugin class cannot be found)
message += " The corresponding plugin " + "bundle could not be activated!";
}
LOGGER.error(message, t);
}
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.
the class OpenInteractiveWebViewAction method getViewClassByReflection.
private static Class<?> getViewClassByReflection(final String className, final IConfigurationElement[] confElements) {
Class<?> viewClass = null;
try {
for (IConfigurationElement element : confElements) {
if (className.equals(element.getAttribute("viewClass"))) {
viewClass = Platform.getBundle(element.getDeclaringExtension().getContributor().getName()).loadClass(element.getAttribute("viewClass"));
}
}
} catch (Exception e) {
/* do nothing */
}
if (viewClass != null) {
try {
Method isEnabledM = viewClass.getMethod("isEnabled");
boolean isEnabled = (boolean) isEnabledM.invoke(null);
return isEnabled ? viewClass : null;
} catch (Exception e) {
return viewClass;
}
}
return null;
}
use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.
the class DatabaseDriverLoader method loadDriversFromExtensionPoint.
/**
* Loads all JDBC driver registered via the extension point.
*/
private static void loadDriversFromExtensionPoint() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
throw new IllegalStateException("Invalid extension point id: " + EXT_POINT_ID);
}
for (IExtension ext : point.getExtensions()) {
IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement e : elements) {
String path = e.getAttribute("jarFile");
String bundleId = e.getDeclaringExtension().getNamespaceIdentifier();
Bundle bundle = Platform.getBundle(bundleId);
URL jdbcUrl = FileLocator.find(bundle, new Path(path), null);
if (jdbcUrl != null) {
ClassLoader bundleClassLoader = bundle.adapt(BundleWiring.class).getClassLoader();
try {
loadDriver(new File(FileLocator.toFileURL(jdbcUrl).getPath()), bundleClassLoader, false);
} catch (IOException ex) {
LOGGER.error("Could not load JDBC driver '" + path + "': " + ex.getMessage(), ex);
}
} else {
LOGGER.error("Could not find JDBC driver file '" + path + "' from plug-in '" + bundleId + "'");
}
}
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.
the class NodeExecutionJobManagerPool method collectJobManagerFactories.
private static void collectJobManagerFactories() {
managerFactories = new LinkedHashMap<String, NodeExecutionJobManagerFactory>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
// let's throw in the default manager - otherwise things fail badly
managerFactories.put(getDefaultJobManagerFactory().getID(), getDefaultJobManagerFactory());
LOGGER.error("Invalid extension point: " + EXT_POINT_ID);
throw new IllegalStateException("ACTIVATION ERROR: " + " --> Invalid extension point: " + EXT_POINT_ID);
}
for (IConfigurationElement elem : point.getConfigurationElements()) {
String jobMgr = elem.getAttribute(EXT_POINT_ATTR_JOBMGR);
String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (jobMgr == null || jobMgr.isEmpty()) {
LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + EXT_POINT_ATTR_JOBMGR + "'");
LOGGER.error("Extension " + decl + " ignored.");
continue;
}
// try instantiating the job manager.
NodeExecutionJobManagerFactory instance = null;
try {
// TODO: THE THREADED MANAGER NEEDS TO BE RE-WRITTEN!
if (jobMgr.equals(getDefaultJobManagerFactory().getID())) {
instance = getDefaultJobManagerFactory();
} else {
instance = (NodeExecutionJobManagerFactory) elem.createExecutableExtension(EXT_POINT_ATTR_JOBMGR);
}
} catch (UnsatisfiedLinkError ule) {
// in case an implementation tries to load an external lib
// when the factory class gets loaded
LOGGER.error("Unable to load a library required for '" + jobMgr + "'");
LOGGER.error("Either specify it in the -Djava.library.path " + "option at the program's command line, or");
LOGGER.error("include it in the LD_LIBRARY_PATH variable.");
LOGGER.error("Extension " + jobMgr + " ('" + decl + "') ignored.", ule);
} catch (CoreException ex) {
Throwable cause = ex.getStatus().getException();
if (cause != null) {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "'): " + cause.getMessage(), ex);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
} else {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "')", ex);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
} catch (Throwable t) {
LOGGER.error("Problems during initialization of job manager (with id '" + jobMgr + "')", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
if (instance != null) {
/*
* make sure the ThreadedJobManagerFactory is always the first
* in the list
*/
if ((instance instanceof ThreadPool) && managerFactories.size() > 0) {
Map<String, NodeExecutionJobManagerFactory> old = managerFactories;
managerFactories = new LinkedHashMap<String, NodeExecutionJobManagerFactory>();
managerFactories.put(instance.getID(), instance);
for (Map.Entry<String, NodeExecutionJobManagerFactory> e : old.entrySet()) {
managerFactories.put(e.getKey(), e.getValue());
}
} else {
managerFactories.put(instance.getID(), instance);
}
}
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project knime-core by knime.
the class DataTypeRegistry method availableDataTypes.
/**
* Returns a collection with all known data types (that are registered at the extension point
* <tt>org.knime.core.DataType</tt>).
*
* @return a (possibly empty) collection with data types
*/
public synchronized Collection<DataType> availableDataTypes() {
// perform lazy initialization
if (m_allDataTypes != null) {
return m_allDataTypes;
}
List<DataType> types = new ArrayList<>();
for (IConfigurationElement configElement : m_factories.values()) {
try {
DataCellFactory fac = (DataCellFactory) configElement.createExecutableExtension("factoryClass");
types.add(fac.getDataType());
} catch (CoreException e) {
NodeLogger.getLogger(getClass()).error("Could not create data cell factory '" + configElement.getAttribute("factoryClass") + "' for '" + configElement.getAttribute("cellClass") + "' from plug-in '" + configElement.getNamespaceIdentifier() + "': " + e.getMessage(), e);
}
}
m_allDataTypes = Collections.unmodifiableCollection(types);
return types;
}
Aggregations