use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class AggregationMethods method registerExtensionPoints.
/**
* Registers all extension point implementations.
*/
private void registerExtensionPoints() {
try {
final IExtensionRegistry registry = Platform.getExtensionRegistry();
final IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
LOGGER.error("Invalid extension point: " + EXT_POINT_ID);
throw new IllegalStateException("ACTIVATION ERROR: --> Invalid extension point: " + EXT_POINT_ID);
}
for (final IConfigurationElement elem : point.getConfigurationElements()) {
final String operator = elem.getAttribute(EXT_POINT_ATTR_DF);
final String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (operator == null || operator.isEmpty()) {
LOGGER.error("The extension '" + decl + "' doesn't provide the required attribute '" + EXT_POINT_ATTR_DF + "'");
LOGGER.error("Extension " + decl + " ignored.");
continue;
}
boolean isDeprecated = Boolean.parseBoolean(elem.getAttribute("deprecated"));
try {
final AggregationOperator aggrOperator = (AggregationOperator) elem.createExecutableExtension(EXT_POINT_ATTR_DF);
if (isDeprecated) {
addDeprecatedOperator(aggrOperator);
} else {
addOperator(aggrOperator);
}
} catch (final Throwable t) {
LOGGER.error("Problems during initialization of aggregation operator (with id '" + operator + "'.)", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.", t);
}
}
}
} catch (final Exception e) {
LOGGER.error("Exception while registering aggregation operator extensions", e);
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class WorkflowManager method executeEarlyStartup.
private static void executeEarlyStartup() {
String extPointId = "org.knime.core.EarlyStartup";
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(extPointId);
assert point != null : "Invalid extension point id: " + extPointId;
Iterator<IConfigurationElement> it = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).iterator();
while (it.hasNext()) {
IConfigurationElement e = it.next();
try {
((IEarlyStartup) e.createExecutableExtension("class")).run();
} catch (CoreException ex) {
LOGGER.error("Could not create early startup object od class '" + e.getAttribute("class") + "' " + "from plug-in '" + e.getContributor().getName() + "': " + ex.getMessage(), ex);
} catch (Exception ex) {
LOGGER.error("Early startup in '" + e.getAttribute("class") + " from plug-in '" + e.getContributor().getName() + "' has thrown an uncaught exception: " + ex.getMessage(), ex);
}
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class WorkflowSaveHook method collectWorkflowSaveHooks.
private static List<WorkflowSaveHook> collectWorkflowSaveHooks() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
if (point == null) {
LOGGER.error("Invalid extension point: " + EXT_POINT_ID);
return Collections.emptyList();
}
List<WorkflowSaveHook> resultList = new ArrayList<WorkflowSaveHook>();
for (IConfigurationElement elem : point.getConfigurationElements()) {
String workflowSaveHookClassName = elem.getAttribute(EXT_POINT_ATTR_CLASS_NAME);
String decl = elem.getDeclaringExtension().getUniqueIdentifier();
if (StringUtils.isEmpty(workflowSaveHookClassName)) {
LOGGER.errorWithFormat("The extension '%s' doesn't provide the required attribute '%s' - ignoring it", decl, EXT_POINT_ATTR_CLASS_NAME);
continue;
}
WorkflowSaveHook instance = null;
try {
instance = (WorkflowSaveHook) elem.createExecutableExtension(EXT_POINT_ATTR_CLASS_NAME);
} catch (Throwable t) {
LOGGER.error("Problems during initialization of workflow save hook (class '" + workflowSaveHookClassName + "'.)", t);
if (decl != null) {
LOGGER.error("Extension " + decl + " ignored.");
}
}
resultList.add(instance);
}
return Collections.unmodifiableList(resultList);
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class PortTypeRegistry method scanExtensionPointForSpecSerializer.
private <T extends PortObjectSpec> Optional<PortObjectSpecSerializer<T>> scanExtensionPointForSpecSerializer(final String specClassName) {
// not found => scan extension point
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
Optional<IConfigurationElement> o = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(cfe -> cfe.getAttribute("specClass").equals(specClassName)).findFirst();
if (o.isPresent()) {
IConfigurationElement configElement = o.get();
return createSpecSerializer(configElement);
} else {
return Optional.empty();
}
}
use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class PortTypeRegistry method getPortType.
/**
* Returns the port type for the given port object class.
*
* @param portClass any port object class, must not be <code>null</code>
* @param isOptional <code>true</code> for an optional port, <code>false</code> for a required port
* @return a port type, never <code>null</code>
*/
public synchronized PortType getPortType(final Class<? extends PortObject> portClass, final boolean isOptional) {
Map<Class<? extends PortObject>, PortType> map = isOptional ? m_allOptionalPortTypes : m_allPortTypes;
PortType pt = map.get(portClass);
if (pt == null) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXT_POINT_ID);
Optional<IConfigurationElement> configElement = Stream.of(point.getExtensions()).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(e -> portClass.getName().equals(e.getAttribute("objectClass"))).findFirst();
if (configElement.isPresent()) {
createPortTypes(configElement.get());
pt = map.get(portClass);
} else {
if (!portClass.isInterface()) {
NodeLogger.getLogger(getClass()).coding("Port object class '" + portClass.getName() + "' is not " + "registered at the extension point org.knime.core.PortType.");
}
pt = new PortType(portClass, isOptional, null, PortType.DEFAULT_COLOR, true);
map.put(portClass, pt);
}
}
return pt;
}
Aggregations