Subversion Repositories SmartDukaan

Rev

View as "text/plain" | Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.price;

import java.time.LocalDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.spice.profitmandi.service.pricing.PriceDropService;
import com.spice.profitmandi.web.config.AppConfig;

@Transactional
@Component
public class PriceDropScheduler {//implements Runnable{
        
        private static final Logger LOGGER = LoggerFactory.getLogger(PriceDropScheduler.class);
        
        @Autowired
        private PriceDropService priceDropService;
        
        @Scheduled(fixedDelay = 3000)
        public void checkAndAddPriceDropAmountToWallet() {
                priceDropService.addPriceDropAmountToWallet();
                LOGGER.info("Check and add price drop Amount to wallet at {}", LocalDateTime.now());
        }
        
        public static void main(String[] args) { 
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        String scheduledAnnotationProcessor = "org.springframework.context.annotation.internalScheduledAnnotationProcessor";
        System.out.println("Contains " + scheduledAnnotationProcessor + ": "+ context.containsBean(scheduledAnnotationProcessor));
        try {
            Thread.sleep(8000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            //context.close();
        }
    }
}