Search in sources :

Example 36 with IExtensionRegistry

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);
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 37 with IExtensionRegistry

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);
        }
    }
}
Also used : Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) EXECUTING(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTING) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeView(org.knime.core.node.NodeView) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) Node(org.knime.core.node.Node) Vector(java.util.Vector) Matcher(java.util.regex.Matcher) WorkflowFileStoreHandlerRepository(org.knime.core.data.filestore.internal.WorkflowFileStoreHandlerRepository) Map(java.util.Map) FileStoreHandlerRepository(org.knime.core.data.filestore.internal.FileStoreHandlerRepository) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) EXECUTINGREMOTELY(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTINGREMOTELY) Set(java.util.Set) ResolverUtil(org.knime.core.util.pathresolve.ResolverUtil) Executors(java.util.concurrent.Executors) POSTEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.POSTEXECUTE) InputNode(org.knime.core.node.dialog.InputNode) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Stream(java.util.stream.Stream) CONFIGURED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) CollapseIntoMetaNodeResult(org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) VirtualParallelizedChunkPortObjectInNodeModel(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeModel) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) VMFileLocker(org.knime.core.util.VMFileLocker) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) EXECUTED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_QUEUED) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) NotConfigurableException(org.knime.core.node.NotConfigurableException) UpdateStatus(org.knime.core.node.workflow.MetaNodeTemplateInformation.UpdateStatus) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) LinkedHashSet(java.util.LinkedHashSet) VirtualParallelizedChunkNodeInput(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkNodeInput) KNIMEConstants(org.knime.core.node.KNIMEConstants) LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Executor(java.util.concurrent.Executor) PREEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.PREEXECUTE) InteractiveView(org.knime.core.node.interactive.InteractiveView) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) UNCONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC) OutputNode(org.knime.core.node.dialog.OutputNode) Platform(org.eclipse.core.runtime.Platform) LoopStatus(org.knime.core.node.workflow.NativeNodeContainer.LoopStatus) FileUtil(org.knime.core.util.FileUtil) CONFIGURED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_QUEUED) NodeType(org.knime.core.node.NodeFactory.NodeType) ExpandSubnodeResult(org.knime.core.node.workflow.action.ExpandSubnodeResult) ListIterator(java.util.ListIterator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) ReexecutionCallback(org.knime.core.node.interactive.ReexecutionCallback) MetaNodeLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.MetaNodeLinkUpdateResult) FileFilterUtils(org.apache.commons.io.filefilter.FileFilterUtils) NodeDialogPane(org.knime.core.node.NodeDialogPane) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) AbstractNodeView(org.knime.core.node.AbstractNodeView) ConvenienceMethods(org.knime.core.node.util.ConvenienceMethods) URI(java.net.URI) ThreadFactory(java.util.concurrent.ThreadFactory) ContainerTable(org.knime.core.data.container.ContainerTable) MetaNodeToSubNodeResult(org.knime.core.node.workflow.action.MetaNodeToSubNodeResult) PortType(org.knime.core.node.port.PortType) NodeAndInports(org.knime.core.node.workflow.Workflow.NodeAndInports) CONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC) Collection(java.util.Collection) CredentialsNode(org.knime.core.node.workflow.CredentialsStore.CredentialsNode) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) LoadResultEntryType(org.knime.core.node.workflow.WorkflowPersistor.LoadResultEntry.LoadResultEntryType) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Entry(java.util.Map.Entry) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) CheckUtils.checkState(org.knime.core.node.util.CheckUtils.checkState) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) IntStream(java.util.stream.IntStream) IOCase(org.apache.commons.io.IOCase) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) EXECUTED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_MARKEDFOREXEC) HashMap(java.util.HashMap) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) IDLE(org.knime.core.node.workflow.InternalNodeContainerState.IDLE) ExternalNodeData(org.knime.core.node.dialog.ExternalNodeData) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) NodeLogger(org.knime.core.node.NodeLogger) NodeCreationContext(org.knime.core.node.NodeCreationContext) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) LinkedList(java.util.LinkedList) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) SubNodeToMetaNodeResult(org.knime.core.node.workflow.action.SubNodeToMetaNodeResult) OutputStream(java.io.OutputStream) NodeFactory(org.knime.core.node.NodeFactory) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) VirtualParallelizedChunkPortObjectOutNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectOutNodeFactory) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) ParallelizedChunkContent(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContent) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Condition(java.util.concurrent.locks.Condition) IEarlyStartup(org.knime.core.util.IEarlyStartup) ParallelizedChunkContentMaster(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContentMaster) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) Collections(java.util.Collections) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IEarlyStartup(org.knime.core.util.IEarlyStartup) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) CoreException(org.eclipse.core.runtime.CoreException) LockFailedException(org.knime.core.util.LockFailedException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NotConfigurableException(org.knime.core.node.NotConfigurableException) IOException(java.io.IOException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URISyntaxException(java.net.URISyntaxException) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 38 with IExtensionRegistry

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);
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 39 with IExtensionRegistry

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();
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SerializerMethodLoader(org.knime.core.internal.SerializerMethodLoader) HashMap(java.util.HashMap) CoreException(org.eclipse.core.runtime.CoreException) PortObjectSpecSerializer(org.knime.core.node.port.PortObjectSpec.PortObjectSpecSerializer) BufferedDataTable(org.knime.core.node.BufferedDataTable) Stream(java.util.stream.Stream) PortObjectSerializer(org.knime.core.node.port.PortObject.PortObjectSerializer) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) NodeLogger(org.knime.core.node.NodeLogger) Map(java.util.Map) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Optional(java.util.Optional) Platform(org.eclipse.core.runtime.Platform) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) GlobalClassCreator(org.knime.core.eclipseUtil.GlobalClassCreator) DataCell(org.knime.core.data.DataCell) DataType(org.knime.core.data.DataType) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 40 with IExtensionRegistry

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;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SerializerMethodLoader(org.knime.core.internal.SerializerMethodLoader) HashMap(java.util.HashMap) CoreException(org.eclipse.core.runtime.CoreException) PortObjectSpecSerializer(org.knime.core.node.port.PortObjectSpec.PortObjectSpecSerializer) BufferedDataTable(org.knime.core.node.BufferedDataTable) Stream(java.util.stream.Stream) PortObjectSerializer(org.knime.core.node.port.PortObject.PortObjectSerializer) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) NodeLogger(org.knime.core.node.NodeLogger) Map(java.util.Map) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Optional(java.util.Optional) Platform(org.eclipse.core.runtime.Platform) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) GlobalClassCreator(org.knime.core.eclipseUtil.GlobalClassCreator) DataCell(org.knime.core.data.DataCell) DataType(org.knime.core.data.DataType) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)55 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)50 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)33 CoreException (org.eclipse.core.runtime.CoreException)25 IExtension (org.eclipse.core.runtime.IExtension)20 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)11 Platform (org.eclipse.core.runtime.Platform)9 Map (java.util.Map)8 Optional (java.util.Optional)8 Stream (java.util.stream.Stream)8 NodeLogger (org.knime.core.node.NodeLogger)8 Collection (java.util.Collection)7 List (java.util.List)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 DataTableSpec (org.knime.core.data.DataTableSpec)5 GlobalClassCreator (org.knime.core.eclipseUtil.GlobalClassCreator)5 SerializerMethodLoader (org.knime.core.internal.SerializerMethodLoader)5 File (java.io.File)4 Collections (java.util.Collections)4