Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Change the interface of PriamScheduler (#1049)" #1050

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.spi.JobFactory;
import org.quartz.spi.TriggerFiredBundle;

public class GuiceJobFactory implements PriamJobFactory {
public class GuiceJobFactory implements JobFactory {
public final Injector guice;

@Inject
Expand All @@ -35,11 +36,7 @@ public GuiceJobFactory(Injector guice) {
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = bundle.getJobDetail();
return newJob((Class<? extends Task>) jobDetail.getJobClass());
}

@Override
public Job newJob(Class<? extends Task> jobClass) {
Class<?> jobClass = jobDetail.getJobClass();
Job job = (Job) guice.getInstance(jobClass);
guice.injectMembers(job);
return job;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
public class PriamScheduler {
private static final Logger logger = LoggerFactory.getLogger(PriamScheduler.class);
private final Scheduler scheduler;
private final PriamJobFactory jobProvider;
private final GuiceJobFactory jobFactory;
private final Sleeper sleeper;

@Inject
public PriamScheduler(SchedulerFactory factory, PriamJobFactory jobProvider, Sleeper sleeper) {
public PriamScheduler(SchedulerFactory factory, GuiceJobFactory jobFactory, Sleeper sleeper) {
try {
this.scheduler = factory.getScheduler();
this.scheduler.setJobFactory(jobProvider);
this.jobProvider = jobProvider;
this.scheduler.setJobFactory(jobFactory);
this.jobFactory = jobFactory;
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public void addTaskWithDelay(
}

public void runTaskNow(Class<? extends Task> taskclass) throws Exception {
jobProvider.newJob(taskclass).execute(null);
jobFactory.guice.getInstance(taskclass).execute(null);
}

public void deleteTask(String name) throws SchedulerException {
Expand Down