Skip to content

Commit 4919cec

Browse files
committed
✨ add bootstrap
1 parent d8e6eaf commit 4919cec

File tree

3 files changed

+105
-1
lines changed

3 files changed

+105
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package link.elastic.scalabel.core.bootstrap;
2+
3+
import link.elastic.scalabel.core.collector.JobCollector;
4+
import link.elastic.scalabel.core.config.JobConfig;
5+
import link.elastic.scalabel.core.container.JobContainer;
6+
import link.elastic.scalabel.core.scheduler.JobScheduler;
7+
8+
public interface Bootstrap {
9+
Bootstrap collector(JobCollector collector);
10+
11+
Bootstrap config(JobConfig config);
12+
13+
Bootstrap container(JobContainer container);
14+
15+
Bootstrap scheduler(JobScheduler scheduler);
16+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
11
package link.elastic.scalabel.core.bootstrap;
22

3-
public class JobBootstrap {
3+
import link.elastic.scalabel.core.collector.JobCollector;
4+
import link.elastic.scalabel.core.config.JobConfig;
5+
import link.elastic.scalabel.core.container.JobContainer;
6+
import link.elastic.scalabel.core.scheduler.JobScheduler;
7+
8+
public class JobBootstrap implements Bootstrap {
9+
private static final JobBootstrap jobBootstrap = new JobBootstrap();
10+
private static JobCollector collector;
11+
private JobConfig config;
12+
private JobContainer container;
13+
private JobScheduler scheduler;
14+
15+
private JobBootstrap() {
16+
}
17+
18+
public static JobBootstrap getInstance() {
19+
return jobBootstrap;
20+
}
21+
22+
@Override
23+
public JobBootstrap collector(JobCollector collector) {
24+
this.collector = collector;
25+
return this;
26+
}
27+
@Override
28+
public JobBootstrap config(JobConfig config) {
29+
this.config = config;
30+
return this;
31+
}
32+
@Override
33+
public JobBootstrap container(JobContainer container) {
34+
this.container = container;
35+
return this;
36+
}
37+
@Override
38+
public JobBootstrap scheduler(JobScheduler scheduler){
39+
this.scheduler = scheduler;
40+
return this;
41+
}
42+
43+
44+
445
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package link.elastic.scalabel.core.bootstrap;
2+
3+
import link.elastic.scalabel.core.collector.H2JobCollector;
4+
import link.elastic.scalabel.core.config.QuartzJobConfig;
5+
import link.elastic.scalabel.core.container.DefaultJobContainer;
6+
import link.elastic.scalabel.core.scheduler.QuartzJobScheduler;
7+
import org.junit.jupiter.api.Test;
8+
import org.quartz.SchedulerException;
9+
10+
import static org.junit.jupiter.api.Assertions.*;
11+
12+
class JobBootstrapTest {
13+
14+
@Test
15+
void getInstance() {
16+
Bootstrap bootstrap = JobBootstrap.getInstance();
17+
assertNotNull(bootstrap);
18+
}
19+
20+
@Test
21+
void collector() {
22+
Bootstrap bootstrap = JobBootstrap.getInstance();
23+
bootstrap.collector(new H2JobCollector());
24+
assertNotNull(bootstrap);
25+
}
26+
27+
@Test
28+
void config() {
29+
Bootstrap bootstrap = JobBootstrap.getInstance();
30+
bootstrap.config(new QuartzJobConfig());
31+
assertNotNull(bootstrap);
32+
}
33+
34+
@Test
35+
void container() {
36+
Bootstrap bootstrap = JobBootstrap.getInstance();
37+
bootstrap.container(new DefaultJobContainer());
38+
assertNotNull(bootstrap);
39+
}
40+
41+
@Test
42+
void scheduler() throws SchedulerException {
43+
Bootstrap bootstrap = JobBootstrap.getInstance();
44+
bootstrap.scheduler(new QuartzJobScheduler());
45+
assertNotNull(bootstrap);
46+
}
47+
}

0 commit comments

Comments
 (0)