package qzui;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
import restx.factory.AutoStartable;
import restx.factory.Module;
import restx.factory.Provides;

@Module
public class QuartzModule {
    @Provides
    public Scheduler scheduler() {
        try {
            return StdSchedulerFactory.getDefaultScheduler();
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
    }

    @Provides
    public AutoStartable schedulerStarter(final Scheduler scheduler) {
        return new AutoStartable() {
            @Override
            public void start() {
                try {
                    scheduler.start();
                } catch (SchedulerException e) {
                    throw new RuntimeException(e);
                }
            }
        };
    }

    @Provides
    public AutoCloseable schedulerCloser(final Scheduler scheduler) {
        return new AutoCloseable() {
            @Override
            public void close() throws Exception {
                scheduler.shutdown();
            }
        };
    }
}

@@ -119,16 +119,41 @@
 actory;%0A
+import org.slf4j.Logger;%0A
 import r
@@ -245,43 +245,167 @@
 s;%0A%0A
-@Module%0Apublic class QuartzModule %7B
+import static org.slf4j.LoggerFactory.getLogger;%0A%0A@Module%0Apublic class QuartzModule %7B%0A%0A    private static final Logger logger = getLogger(QuartzModule.class);%0A
 %0A   
@@ -731,112 +731,92 @@
 urn 
-new AutoStartable() %7B%0A            @Override%0A            public void start() %7B%0A                try %7B%0A    
+() -%3E %7B%0A            try %7B%0A                logger.info(%22Starting quartz scheduler%22);%0A
     
@@ -854,28 +854,24 @@
             
-    
 %7D catch (Sch
@@ -899,36 +899,32 @@
                 
- 
-   
 throw new Runtim
@@ -942,26 +942,8 @@
 e);%0A
-                %7D%0A
     
@@ -1073,107 +1073,70 @@
 urn 
-new AutoCloseable() %7B%0A            @Override%0A            public void close() throws Exception %7B%0A    
+() -%3E %7B%0A            logger.info(%22Stopping quartz scheduler%22);%0A
     
@@ -1165,30 +1165,16 @@
 down();%0A
-            %7D%0A
         

add log while quartz scheduler is started or stopped