Class NodeExecutorRegistry

java.lang.Object
ai.nervemind.app.service.NodeExecutorRegistry

@Component public class NodeExecutorRegistry extends Object
Central registry for all available NodeExecutor implementations.

Acts as a lookup service used by the ExecutionService to find the correct execution logic for any given node type. Supports both built-in executors (auto-wired by Spring) and dynamic executors provided by plugins.

Responsibilities

  • Auto-Discovery: Collects all Spring beans implementing NodeExecutor on startup.
  • Lookup: efficient O(1) retrieval of executors by type string.
  • Dynamic Registration: Allows runtime addition/removal of executors (e.g., from plugins).
  • Constructor Details

    • NodeExecutorRegistry

      public NodeExecutorRegistry(List<NodeExecutor> executorList)
      Creates a new NodeExecutorRegistry with the provided list of executors.
      Parameters:
      executorList - the list of node executors to register
  • Method Details

    • getExecutor

      public NodeExecutor getExecutor(String nodeType)
      Retrieves the executor for the specified node type.
      Parameters:
      nodeType - the type of node to get the executor for
      Returns:
      the executor for the node type
      Throws:
      IllegalArgumentException - if no executor is found for the node type
    • hasExecutor

      public boolean hasExecutor(String nodeType)
      Checks if an executor exists for the specified node type.
      Parameters:
      nodeType - the type of node to check
      Returns:
      true if an executor exists for the node type, false otherwise
    • registerExecutor

      public void registerExecutor(NodeExecutor executor)
      Dynamically register a node executor. Used by plugin system to add custom node types at runtime.
      Parameters:
      executor - The executor to register
      Throws:
      IllegalArgumentException - if an executor for this type already exists
    • unregisterExecutor

      public boolean unregisterExecutor(String nodeType)
      Unregister a node executor. Used by plugin system when unloading plugins.
      Parameters:
      nodeType - The node type to unregister
      Returns:
      true if executor was removed, false if it didn't exist
    • getRegisteredNodeTypes

      public Set<String> getRegisteredNodeTypes()
      Get all registered node types.
      Returns:
      Set of registered node type identifiers