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

import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;
import javax.inject.Inject;

import de.ivu.elect.business.konfiguration.entity.ElectKonfigurationWerte;
import de.ivu.elect.business.konfiguration.entity.KonfigurationWertGeaendertEvent;
import de.ivu.elect.jee.memory.MemoryGcCronTimer;

public class MemoryGcKonfigurationWertGeaendertTimerEventListener {

  @Inject
  private transient MemoryGcCronTimer cronTimer;

  public MemoryGcKonfigurationWertGeaendertTimerEventListener() {
    super();
  }

  public void listen(@Observes(during = TransactionPhase.AFTER_COMPLETION, notifyObserver = Reception.ALWAYS) KonfigurationWertGeaendertEvent konfigurationWertGeaendertEvent) {
    if (ElectKonfigurationWerte.MEMORY_GC_CRONTAB.equals(konfigurationWertGeaendertEvent.getKey())) {
      cronTimer.createTimer(konfigurationWertGeaendertEvent.getNeuerWert());
    }
  }
}
