Skip to content

Commit

Permalink
Upgrading to the latest BQModuleProvider format
Browse files Browse the repository at this point in the history
  • Loading branch information
andrus committed Nov 24, 2023
1 parent 7aea608 commit 6d0065d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
package io.bootique.job.consul;

import io.bootique.BQModuleProvider;
import io.bootique.di.BQModule;

import io.bootique.bootstrap.BuiltModule;

public class ConsulJobModuleProvider implements BQModuleProvider {

@Override
public BQModule module() {
return new ConsulJobModule();
public BuiltModule buildModule() {
return BuiltModule.of(new ConsulJobModule())
.provider(this)
.description("Integrates Consul-based Bootique job locks")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@
package io.bootique.job.instrumented;

import io.bootique.BQModuleProvider;
import io.bootique.di.BQModule;
import io.bootique.bootstrap.BuiltModule;
import io.bootique.job.JobModule;
import io.bootique.job.JobModuleProvider;
import io.bootique.metrics.MetricsModuleProvider;

import java.util.Collection;
import java.util.Collections;

import static java.util.Arrays.asList;

public class JobInstrumentedModuleProvider implements BQModuleProvider {

@Override
public BQModule module() {
return new JobInstrumentedModule();
}

@Override
public Collection<Class<? extends BQModule>> overrides() {
return Collections.singleton(JobModule.class);
public BuiltModule buildModule() {
return BuiltModule.of(new JobInstrumentedModule())
.provider(this)
.description("Integrates metrics and extra logging in Bootique job engine")
.overrides(JobModule.class)
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package io.bootique.job.zookeeper;

import io.bootique.BQModuleProvider;
import io.bootique.di.BQModule;
import io.bootique.bootstrap.BuiltModule;

public class ZkJobModuleProvider implements BQModuleProvider {

@Override
public BQModule module() {
return new ZkJobModule();
public BuiltModule buildModule() {
return BuiltModule.of(new ZkJobModule())
.provider(this)
.description("Integrates Zookeeper-based Bootique job locks")
.build();
}
}
22 changes: 8 additions & 14 deletions bootique-job/src/main/java/io/bootique/job/JobModuleProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,24 @@
package io.bootique.job;

import io.bootique.BQModuleProvider;
import io.bootique.di.BQModule;
import io.bootique.bootstrap.BuiltModule;
import io.bootique.job.graph.JobGraphNodeFactory;
import io.bootique.job.scheduler.SchedulerFactory;
import io.bootique.type.TypeRef;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class JobModuleProvider implements BQModuleProvider {

@Override
public BQModule module() {
return new JobModule();
}

@Override
public Map<String, Type> configs() {

public BuiltModule buildModule() {
TypeRef<Map<String, JobGraphNodeFactory>> jobs = new TypeRef<>() {};

Map<String, Type> configs = new HashMap<>();
configs.put("scheduler", SchedulerFactory.class);
configs.put("jobs", jobs.getType());
return configs;
return BuiltModule.of(new JobModule())
.provider(this)
.description("Provides Bootique's own job execution engine")
.config("scheduler", SchedulerFactory.class)
.config("jobs", jobs.getType())
.build();
}
}

0 comments on commit 6d0065d

Please sign in to comment.