Provides coordinated execution of major ROO operations.
A {@link ProcessManager} delivers:
- A well-defined state publication model via {@link ProcessManagerStatusProvider}
- Startup-time registration of the initial monitoring requests (after the {@link #completeStartup()} method has been called)
- Specific polling of {@link FileMonitorService} at well-defined times
- The ability to execute {@link CommandCallback}s for user-requested operations
- An assurance the above is conducted within a "transaction-like" model
Once constructed, all methods in {@link ProcessManager} operate in a"transaction-like" manner. This is achieved by use of a {@link FileManager}that shares the same {@link UndoManager}.
Once available, a {@link ProcessManager} will ordinarily wait for either{@link #backgroundPoll()} or {@link #execute(CommandCallback)}. It will block until the state of the {@link ProcessManager} returns to{@link ProcessManagerStatus#AVAILABLE}.
{@link ProcessManager} guarantees:
- The status will remain {@link ProcessManagerStatus#STARTING} until{@link #completeStartup()} has been called. This is intended to allow objectsdepending on {@link ProcessManager} or other {@link MetadataService}s to be constructed and register for events. The initial monitoring requests will only be registered during {@link #completeStartup()}, which therefore simplifies the design of dependent objects as they generally (i) don't need to retrieve metadata produced before they were listening and (ii) can freely modify the file system pursuant to {@link FileManager} with assurance ofcorrect "transaction" behaviour.
- At the end of a successful startup, background poll or command execution, {@link UndoManager#reset()} method will be called.
- An uncaught exception will cause {@link UndoManager#undo()} to be called(before re-throwing the exception).
- A {@link FileMonitorService#scanAll()} will be called after a command isexecuted, and will continue to be called until such time as it does not return any further changes. Such calls will occur within the scope of the same "transaction" as used for the command.
{@link ProcessManager} implementations also guarantee to update{@link ActiveProcessManager} whenever running an operation, and clear it whenan operation completes.
@author Ben Alex
@since 1.0