use of org.nutz.integration.quartz.QuartzIocLoader in project nutzboot by nutzam.
the class QuartzStarter method getIocLoader.
public IocLoader getIocLoader() {
if (!conf.has("cron.pkgs")) {
conf.put("cron.pkgs", appContext.getPackage());
}
QuartzIocLoader loader = new QuartzIocLoader();
if (appContext.getClassLoader().getResource("quartz.properties") != null) {
log.debug("found quartz.properties, use it");
return loader;
}
// 通过nutzboot的配置信息来初始化
Properties properties = new Properties();
for (String key : conf.keySet()) {
if (key.startsWith("quartz.")) {
properties.put("org." + key, conf.get(key));
}
}
// 设置一下默认值
/*
org.quartz.scheduler.instanceName = NutzbookScheduler
org.quartz.threadPool.threadCount = 3
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.scheduler.skipUpdateCheck=true
*/
properties.putIfAbsent("org.quartz.scheduler.instanceName", "NutzbootScheduler");
properties.putIfAbsent("org.quartz.threadPool.threadCount", "8");
properties.putIfAbsent("org.quartz.scheduler.skipUpdateCheck", "true");
startupDelay = conf.getInt("quartz.startupDelay", 0);
try {
StdSchedulerFactory factory = new StdSchedulerFactory(properties);
scheduler = factory.getScheduler();
scheduler.setJobFactory(new NutQuartzJobFactory(appContext.getIoc()));
((Ioc2) appContext.getIoc()).getIocContext().save("app", "scheduler", new ObjectProxy(scheduler));
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
return loader;
}
Aggregations