From d672f9188ed11d75d5f48493a3fe083884889c11 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 22 Apr 2021 09:31:44 +0200 Subject: [PATCH] Quartz - remove the deprecated quarkus.quartz.force-start property --- ...precatedForceStartQuartzSchedulerTest.java | 68 ------------------- .../io/quarkus/quartz/test/InjectJobTest.java | 2 +- .../quartz/runtime/QuartzRuntimeConfig.java | 13 ---- .../quartz/runtime/QuartzScheduler.java | 15 +--- 4 files changed, 2 insertions(+), 96 deletions(-) delete mode 100644 extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectDeprecatedForceStartQuartzSchedulerTest.java diff --git a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectDeprecatedForceStartQuartzSchedulerTest.java b/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectDeprecatedForceStartQuartzSchedulerTest.java deleted file mode 100644 index 1b53c04fc6333..0000000000000 --- a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectDeprecatedForceStartQuartzSchedulerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.quarkus.quartz.test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.enterprise.event.Observes; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.StringAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.quartz.Job; -import org.quartz.JobBuilder; -import org.quartz.JobDetail; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.SimpleScheduleBuilder; -import org.quartz.Trigger; -import org.quartz.TriggerBuilder; - -import io.quarkus.runtime.StartupEvent; -import io.quarkus.test.QuarkusUnitTest; - -public class InjectDeprecatedForceStartQuartzSchedulerTest { - - @RegisterExtension - static final QuarkusUnitTest test = new QuarkusUnitTest() - .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addClasses(Starter.class) - .addAsResource(new StringAsset("quarkus.quartz.force-start=true"), - "application.properties")); - - @Test - public void testSimpleScheduledJobs() throws InterruptedException { - assertTrue(Starter.LATCH.await(5, TimeUnit.SECONDS), "Latch count: " + Starter.LATCH.getCount()); - } - - public static class Starter implements Job { - - static final CountDownLatch LATCH = new CountDownLatch(2); - - void onStart(@Observes StartupEvent event, Scheduler quartz) throws SchedulerException { - JobDetail job = JobBuilder.newJob(Starter.class) - .withIdentity("myJob", "myGroup") - .build(); - Trigger trigger = TriggerBuilder.newTrigger() - .withIdentity("myTrigger", "myGroup") - .startNow() - .withSchedule(SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(1) - .repeatForever()) - .build(); - quartz.scheduleJob(job, trigger); - } - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - LATCH.countDown(); - } - - } - -} diff --git a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectJobTest.java b/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectJobTest.java index 25cdf5d4dad2d..d292fa6df9817 100644 --- a/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectJobTest.java +++ b/extensions/quartz/deployment/src/test/java/io/quarkus/quartz/test/InjectJobTest.java @@ -37,7 +37,7 @@ public class InjectJobTest { static final QuarkusUnitTest test = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) .addClasses(Starter.class, Service.class, CountDownLatchProducer.class) - .addAsResource(new StringAsset("quarkus.quartz.force-start=true"), + .addAsResource(new StringAsset("quarkus.quartz.start-mode=forced"), "application.properties")); @Test diff --git a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzRuntimeConfig.java b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzRuntimeConfig.java index 68be1a59d2210..dfd8535f8a76c 100644 --- a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzRuntimeConfig.java +++ b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzRuntimeConfig.java @@ -1,7 +1,5 @@ package io.quarkus.quartz.runtime; -import java.util.Optional; - import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; @@ -27,17 +25,6 @@ public class QuartzRuntimeConfig { @ConfigItem(defaultValue = "5") public int threadPriority; - /** - * By default, the scheduler is not started unless a {@link io.quarkus.scheduler.Scheduled} business method is found. - * If set to true the scheduler will be started even if no scheduled business methods are found. This is necessary for - * "pure" programmatic scheduling. - * - * @deprecated use quarkus.quartz.start-mode=forced instead. - */ - @Deprecated - @ConfigItem - public Optional forceStart; - /** * Scheduler can be started in different modes: normal, forced or halted. * By default, the scheduler is not started unless a {@link io.quarkus.scheduler.Scheduled} business method diff --git a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java index 7c78c6fa341e5..5d222ae14e8f0 100644 --- a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java +++ b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java @@ -72,7 +72,6 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Sc Event skippedExecutionEvent, Instance jobs, Instance userTransaction) { enabled = schedulerRuntimeConfig.enabled; final QuartzRuntimeConfig runtimeConfig = quartzSupport.getRuntimeConfig(); - warnDeprecated(runtimeConfig); boolean forceStart; if (runtimeConfig.startMode != QuartzStartMode.NORMAL) { @@ -80,7 +79,7 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Sc forceStart = startHalted || (runtimeConfig.startMode == QuartzStartMode.FORCED); } else { startHalted = false; - forceStart = runtimeConfig.forceStart.orElse(false); + forceStart = false; } if (!enabled) { @@ -206,18 +205,6 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Sc } } - /** - * Warn if there's any deprecated configuration - * - * @param runtimeConfig {@link QuartzRuntimeConfig} quartz scheduler configurations - */ - private static void warnDeprecated(QuartzRuntimeConfig runtimeConfig) { - if (runtimeConfig.forceStart.isPresent()) { - LOGGER.warn("`quarkus.quartz.force-start` is deprecated and will be removed in a future version - it is " - + "recommended to switch to `quarkus.quartz.start-mode`"); - } - } - @Produces @Singleton org.quartz.Scheduler produceQuartzScheduler() {