package de.ivu.elect.business.system.control.files;

import javax.ejb.EJB;
import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;

/**
 *  on 09.07.2015.
 */
public class FileCleanupEventListener {

  // wichtig, da mit @Inject die asynchrone Ausführung nicht funktioniert
  @EJB
  FileCleanupBackgroundService backgroundService;

  public void listen(
      @Observes(during = TransactionPhase.AFTER_SUCCESS, notifyObserver = Reception.ALWAYS) FileCleanupEvent event) {
    FileCleanupBackgroundService.startIfNotRunning(backgroundService, FileCleanupBackgroundService.RUNNING);
  }
}
