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

@Component @Order(-2147483648) public class LockService extends BaseComponent
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 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.