package sklep.dodatki;

import io.quarkus.scheduler.Scheduled;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.ApplicationScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicInteger;

@ApplicationScoped
public class Sched {
    private static final Logger log = LoggerFactory.getLogger(Sched.class);

    private AtomicInteger counter = new AtomicInteger();

    @PostConstruct
    public void start() {
        log.info("Sched @PostConstruct");
    }

    @Scheduled(every="30s")
    void increment() {
        log.info(String.valueOf(counter.incrementAndGet()));
    }

    @PreDestroy
    public void end() {
        log.info("Sched @PreDestroy");

    }
}
