Class FileWatcherService

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

@Service public class FileWatcherService extends Object
Service for watching file system events and triggering workflows. Enables workflows to be triggered when files are created, modified, or deleted in specified directories.
  • Constructor Details

    • FileWatcherService

      public FileWatcherService(WorkflowService workflowService, ExecutionService executionService)
      Creates a new FileWatcherService with required dependencies.
      Parameters:
      workflowService - the workflow service for managing workflows
      executionService - the execution service for triggering workflows
  • Method Details

    • initialize

      @PostConstruct public void initialize()
      Initializes the file watcher service after construction. Sets up the watch service and registers active file-triggered workflows.
    • shutdown

      @PreDestroy public void shutdown()
      Shuts down the file watcher service and releases resources. Stops the watcher thread and closes the watch service.
    • registerWorkflow

      public void registerWorkflow(ai.nervemind.common.dto.WorkflowDTO workflow)
      Register a workflow for file watching.
      Parameters:
      workflow - The workflow to register
    • unregisterWorkflow

      public void unregisterWorkflow(Long workflowId)
      Unregister a workflow from file watching.
      Parameters:
      workflowId - The workflow ID to unregister
    • isWatched

      public boolean isWatched(Long workflowId)
      Check if a workflow is currently being watched.
      Parameters:
      workflowId - The workflow ID
      Returns:
      true if watched
    • getActiveWatcherCount

      public int getActiveWatcherCount()
      Get the number of active watchers.
      Returns:
      active watcher count