use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class RpcTransportRegistry method collectRpcMessageTransportFactory.
/**
* @return the factory provided by org.knime.core.ui (delegating message transport to NodeContainerUI#doRpc)
*/
private static RpcTransportFactory collectRpcMessageTransportFactory() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
// find all extensions implementing the RpcTransportFactory extension point
List<RpcTransportFactory> factoryList = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).map(RpcTransportRegistry::readFactory).filter(Objects::nonNull).collect(Collectors.toList());
if (factoryList.isEmpty() || factoryList.size() > 1) {
throw new IllegalStateException(String.format("%s factories registered via RpcTransportFactory extension point, should be exactly 1.\n" + "Factory list: %s", factoryList.size(), factoryList));
}
return factoryList.get(0);
}
use of org.eclipse.core.runtime.IExtensionPoint in project knime-core by knime.
the class TestrunJanitor method getJanitors.
/**
* Returns a list with all registered testrun janitors. Each call will create new instances.
*
* @return a (possibly empty) collection with testrun janitors
*/
public static Collection<TestrunJanitor> getJanitors() {
List<TestrunJanitor> janitors = new ArrayList<>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("org.knime.testing.TestrunJanitor");
for (IExtension ext : point.getExtensions()) {
IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement janitorElement : elements) {
try {
janitors.add((TestrunJanitor) janitorElement.createExecutableExtension("class"));
} catch (CoreException ex) {
NodeLogger.getLogger(TestrunJanitor.class).error("Could not create testrun janitor " + janitorElement.getAttribute("class") + " from plug-in " + janitorElement.getNamespaceIdentifier() + ": " + ex.getMessage(), ex);
}
}
}
return janitors;
}
use of org.eclipse.core.runtime.IExtensionPoint 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.IExtensionPoint in project knime-core by knime.
the class AbstractWizardNodeView method getAllWizardNodeViews.
/**
* Queries extension point for additional {@link AbstractWizardNodeView} implementations.
*
* @return A list with all registered view implementations.
*/
@SuppressWarnings("unchecked")
public static List<WizardNodeViewExtension> getAllWizardNodeViews() {
List<WizardNodeViewExtension> viewExtensionList = new ArrayList<WizardNodeViewExtension>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
assert point != null : "Invalid extension point id: " + EXT_POINT_ID;
for (IExtension ext : point.getExtensions()) {
IConfigurationElement[] elements = ext.getConfigurationElements();
for (IConfigurationElement viewElement : elements) {
String viewClassName = viewElement.getAttribute("viewClass");
String viewName = viewElement.getAttribute("name");
String viewDesc = viewElement.getAttribute("description");
Class<AbstractWizardNodeView<?, ?, ?>> viewClass;
try {
viewClass = (Class<AbstractWizardNodeView<?, ?, ?>>) Platform.getBundle(viewElement.getDeclaringExtension().getContributor().getName()).loadClass(viewClassName);
viewExtensionList.add(new WizardNodeViewExtension(viewClass, viewName, viewDesc));
} catch (ClassNotFoundException ex) {
NodeLogger.getLogger(AbstractWizardNodeView.class).error("Could not find implementation for " + viewClassName, ex);
}
}
}
return viewExtensionList;
}
use of org.eclipse.core.runtime.IExtensionPoint 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 + "'");
}
}
}
}
Aggregations