Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of volatile configuration fields for Scheduler
Browse files Browse the repository at this point in the history
geoand committed May 2, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c974e59 commit c91407f
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
import java.util.List;
import java.util.Optional;

import javax.inject.Singleton;

import org.quartz.core.QuartzSchedulerThread;
import org.quartz.core.SchedulerSignalerImpl;
import org.quartz.impl.StdSchedulerFactory;
@@ -25,7 +27,7 @@
import io.quarkus.agroal.deployment.JdbcDataSourceBuildItem;
import io.quarkus.agroal.deployment.JdbcDataSourceSchemaReadyBuildItem;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanContainerBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.datasource.common.runtime.DatabaseKind;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.annotations.BuildProducer;
@@ -40,7 +42,6 @@
import io.quarkus.quartz.runtime.QuarkusQuartzConnectionPoolProvider;
import io.quarkus.quartz.runtime.QuartzBuildTimeConfig;
import io.quarkus.quartz.runtime.QuartzRecorder;
import io.quarkus.quartz.runtime.QuartzRuntimeConfig;
import io.quarkus.quartz.runtime.QuartzScheduler;
import io.quarkus.quartz.runtime.QuartzSupport;

@@ -55,7 +56,7 @@ CapabilityBuildItem capability() {

@BuildStep
AdditionalBeanBuildItem beans() {
return new AdditionalBeanBuildItem(QuartzScheduler.class, QuartzSupport.class);
return new AdditionalBeanBuildItem(QuartzScheduler.class);
}

@BuildStep
@@ -169,11 +170,16 @@ public List<LogCleanupFilterBuildItem> logCleanup(QuartzBuildTimeConfig config)

@BuildStep
@Record(RUNTIME_INIT)
public void build(QuartzRuntimeConfig runtimeConfig, QuartzBuildTimeConfig buildTimeConfig, QuartzRecorder recorder,
BeanContainerBuildItem beanContainer,
public void build(QuartzRecorder recorder,
BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer,
BuildProducer<ServiceStartBuildItem> serviceStart, QuartzJDBCDriverDialectBuildItem driverDialect,
List<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) {
recorder.initialize(runtimeConfig, buildTimeConfig, beanContainer.getValue(), driverDialect.getDriver());

syntheticBeanBuildItemBuildProducer.produce(SyntheticBeanBuildItem.configure(QuartzSupport.class)
.scope(Singleton.class)
.setRuntimeInit()
.supplier(recorder.quartzSupportSupplier(driverDialect.getDriver())).done());

// Make sure that StartupEvent is fired after the init
serviceStart.produce(new ServiceStartBuildItem("quartz"));
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package io.quarkus.quartz.runtime;

import java.util.Optional;
import java.util.function.Supplier;

import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.runtime.annotations.Recorder;

@Recorder
public class QuartzRecorder {

public void initialize(QuartzRuntimeConfig runTimeConfig, QuartzBuildTimeConfig buildTimeConfig, BeanContainer container,
Optional<String> driverDialect) {
QuartzSupport support = container.instance(QuartzSupport.class);
support.initialize(runTimeConfig, buildTimeConfig, driverDialect);
public Supplier<QuartzSupport> quartzSupportSupplier(Optional<String> driverDialect) {
return new Supplier<QuartzSupport>() {
@Override
public QuartzSupport get() {
return new QuartzSupport(driverDialect);
}
};
}

}
Original file line number Diff line number Diff line change
@@ -2,18 +2,19 @@

import java.util.Optional;

import javax.inject.Singleton;
import javax.inject.Inject;

@Singleton
public class QuartzSupport {

private volatile QuartzRuntimeConfig runtimeConfig;
private volatile QuartzBuildTimeConfig buildTimeConfig;
private volatile Optional<String> driverDialect;
@Inject
QuartzRuntimeConfig runtimeConfig;

void initialize(QuartzRuntimeConfig runTimeConfig, QuartzBuildTimeConfig buildTimeConfig, Optional<String> driverDialect) {
this.runtimeConfig = runTimeConfig;
this.buildTimeConfig = buildTimeConfig;
@Inject
QuartzBuildTimeConfig buildTimeConfig;

private final Optional<String> driverDialect;

public QuartzSupport(Optional<String> driverDialect) {
this.driverDialect = driverDialect;
}

0 comments on commit c91407f

Please sign in to comment.