Package org.saidone.service
Class LockService
java.lang.Object
org.saidone.component.BaseComponent
org.saidone.service.LockService
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
Ensures that only one instance of the application runs at a time.
The service acquires an exclusive lock on the anp.lock file during startup
and releases it during bean destruction.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTries to acquire the process lock file as soon as the bean is initialized.voidReleases any acquired lock resources before bean destruction.Methods inherited from class org.saidone.component.BaseComponent
setApplicationContext, shutDown, start, stop
-
Constructor Details
-
LockService
public LockService()
-
-
Method Details
-
acquireLock
@PostConstruct public void acquireLock()Tries to acquire the process lock file as soon as the bean is initialized.If another process already owns the lock (or an unexpected error happens), the application is terminated through
BaseComponent.shutDown(int). -
releaseLock
@PreDestroy public void releaseLock()Releases any acquired lock resources before bean destruction.Any exception during cleanup is ignored because the application is already in shutdown flow.
-