All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.caelum.vraptor.quartzjob.QuartzController Maven / Gradle / Ivy

There is a newer version: 4.0.8
Show newest version
package br.com.caelum.vraptor.quartzjob;

import java.util.List;

import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;

import org.quartz.SchedulerException;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Result;

import com.google.common.collect.Lists;

@Controller
public class QuartzController {

	private List tasks;
	private QuartzConfiguration cfg;
	private QuartzScheduler scheduler;
	private Result result;

	@Deprecated // CDI eyes only
	public QuartzController() {}

	@Inject
	public QuartzController(@Any Instance tasks,
			QuartzConfiguration cfg, QuartzScheduler
			scheduler, Result result) {
		this.tasks = Lists.newArrayList(tasks);
		this.cfg = cfg;
		this.scheduler = scheduler;
		this.result = result;
	}

	@Get("/jobs/configure")
	public void config() throws SchedulerException {
		if (!scheduler.isInitialized()) 
			cfg.configure(tasks);
		result.nothing();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy