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

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;

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

import de.ivu.document.generator.template.monitor.DocumentProgress;
import de.ivu.document.generator.template.monitor.DocumentProgressMonitor;
import de.ivu.document.generator.template.openoffice.OOConnection;

@ApplicationScoped
public class OpenOfficeApplication implements Serializable {

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

  private static final long serialVersionUID = 1L;

  @PostConstruct
  public void startUp(){
    LOG.info("StartUp");
  }

  public void foo(){
    // nichts zu tun
  }

  @PreDestroy
  public void shutdown(){
    LOG.info("Shutdown");
    OOConnection.INSTANCE.shutdown(new DocumentProgressMonitor() {
      @Override
      public void progress(DocumentProgress documentProgress) {
        LOG.info("Progress: " + documentProgress);
      }

      @Override
      public void progress(DocumentProgress documentProgress, int i, int i1) {
        LOG.info("Progress: " + documentProgress);
      }

      @Override
      public boolean isCanceled() {
        return false;
      }
    });
  }

}
