Class FileWatcherService
java.lang.Object
ai.nervemind.app.service.FileWatcherService
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 Summary
ConstructorsConstructorDescriptionFileWatcherService(WorkflowService workflowService, ExecutionService executionService) Creates a new FileWatcherService with required dependencies. -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of active watchers.voidInitializes the file watcher service after construction.booleanCheck if a workflow is currently being watched.voidregisterWorkflow(ai.nervemind.common.dto.WorkflowDTO workflow) Register a workflow for file watching.voidshutdown()Shuts down the file watcher service and releases resources.voidunregisterWorkflow(Long workflowId) Unregister a workflow from file watching.
-
Constructor Details
-
FileWatcherService
Creates a new FileWatcherService with required dependencies.- Parameters:
workflowService- the workflow service for managing workflowsexecutionService- 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
Unregister a workflow from file watching.- Parameters:
workflowId- The workflow ID to unregister
-
isWatched
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
-