Search in sources :

Example 1 with NodeFactoryClassMapper

use of org.knime.core.node.NodeFactoryClassMapper in project knime-core by knime.

the class FileNativeNodeContainerPersistor method loadNodeFactory.

/**
 * Creates the node factory instance for the given fully-qualified factory class name.
 * Otherwise a respective exception will be thrown.
 *
 * @since 3.5
 */
@SuppressWarnings("unchecked")
public static final NodeFactory<NodeModel> loadNodeFactory(final String factoryClassName) throws InvalidSettingsException, InstantiationException, IllegalAccessException, InvalidNodeFactoryExtensionException {
    Optional<NodeFactory<? extends NodeModel>> facOptional = NodeFactoryExtensionManager.getInstance().createNodeFactory(factoryClassName);
    if (facOptional.isPresent()) {
        return (NodeFactory<NodeModel>) facOptional.get();
    }
    List<NodeFactoryClassMapper> classMapperList = NodeFactoryClassMapper.getRegisteredMappers();
    for (NodeFactoryClassMapper mapper : classMapperList) {
        @SuppressWarnings("rawtypes") NodeFactory factory = mapper.mapFactoryClassName(factoryClassName);
        if (factory != null) {
            LOGGER.debug(String.format("Replacing stored factory class name \"%s\" by actual factory " + "class \"%s\" (defined by class mapper \"%s\")", factoryClassName, factory.getClass().getName(), mapper.getClass().getName()));
            return factory;
        }
    }
    throw new InvalidSettingsException(String.format("Unknown factory class \"%s\" -- not registered via extension point", factoryClassName));
}
Also used : NodeModel(org.knime.core.node.NodeModel) ConfigurableNodeFactory(org.knime.core.node.ConfigurableNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) MissingNodeFactory(org.knime.core.node.missing.MissingNodeFactory) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeFactoryClassMapper(org.knime.core.node.NodeFactoryClassMapper)

Aggregations

ConfigurableNodeFactory (org.knime.core.node.ConfigurableNodeFactory)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeFactory (org.knime.core.node.NodeFactory)1 NodeFactoryClassMapper (org.knime.core.node.NodeFactoryClassMapper)1 NodeModel (org.knime.core.node.NodeModel)1 MissingNodeFactory (org.knime.core.node.missing.MissingNodeFactory)1