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

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

import javax.ejb.DependsOn;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ivu.elect.background.scheduler.AbstractSchedulerBackgroundService;
import de.ivu.elect.background.scheduler.AbstractSchedulerServiceAsync;
import de.ivu.elect.background.scheduler.AbstractSchedulerServiceTransaction;
import de.ivu.elect.business.wahl.entity.WahlPK;

@Startup
@Singleton
@DependsOn("DbInit")
//https://issues.jboss.org/browse/EJBTHREE-2070 (keine Transaktion)
@TransactionManagement(TransactionManagementType.BEAN)
public class PraesentationAsynchronBereitstellenBackgroundService extends AbstractSchedulerBackgroundService<WahlPK> {

  private static final Logger LOG = LoggerFactory.getLogger(PraesentationAsynchronBereitstellenBackgroundService.class);

  public static final AtomicLong RUNNING = createRunning();

  public static final AtomicBoolean DISABLED = createDisabled();

  @Inject
  private transient PraesentationAsynchronBereitstellenAsync async;

  @Inject
  private transient PraesentationAsynchronBereitstellenTransaction transaction;

  @Override
  protected AtomicBoolean getDisabledInternal() {
    return DISABLED;
  }

  @Override
  public AtomicLong getRunning() {
    return RUNNING;
  }

  @Override
  protected AbstractSchedulerServiceAsync<WahlPK> getServiceAsync() {
    return async;
  }

  @Override
  protected AbstractSchedulerServiceTransaction<WahlPK> getServiceTransaction() {
    return transaction;
  }

  @Override
  protected Logger getLogInternal() {
    return LOG;
  }
}
