package de.ivu.elect.jee.performance;

import java.io.Serializable;

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

public class PerformanceLogEventListener implements Serializable {

  private static final long serialVersionUID = 1L;

  public void listen(
      @Observes(during = TransactionPhase.AFTER_COMPLETION, notifyObserver = Reception.ALWAYS) PerformanceLogEvent event) {
    PerformanceStore.addDuration(event.getTarget(), System.currentTimeMillis() - event.getStart());
  }

}

