public class MainSetup implements Setup {
@Inject("refer:mainConfig")
private MainConfig mainConfig;
@Inject("refer:cryptBean")
private CryptBean cryptBean;
private static final Log log = Logs.get();
public void init(NutConfig conf) {
Ioc ioc = conf.getIoc();
log.debug("clean Non-Active User , start");
ioc.get(MyNutQuartzCronJobFactory.class);
}
public void destroy(NutConfig conf) {
}
}
public class MyNutQuartzCronJobFactory extends NutQuartzCronJobFactory {
private static final Log log = Logs.get();
@Inject
protected SqlKeyBiz sqlKeyBiz;
@SuppressWarnings("unchecked")
@Override
public void init() throws Exception {
InputApi inputApi = new InputApi();
List<Record> rds = sqlKeyBiz.list(inputApi, "#quartzJobQuery");
String prefix = "cron.";
for(Record r :rds) {
String key=r.getString("TIMING_KEY");
if (key.length() >= prefix.length() + 1 && key.startsWith(prefix)) {
String name = key.substring(prefix.length());
if ("pkgs".equals(name)) {
log.debug((new StringBuilder()).append("found cron job packages = ")
.append(r.getString("TIMING_TIME")).toString());
String as[] = Strings.splitIgnoreBlank(key, ",");
int i = as.length;
int j = 0;
while (j < i) {
String pkg = as[j];
addPackage(pkg);
j++;
}
}else{
log.debugf("job define name=%s cron=%s", new Object[] {name, key});
Class klass = null;
if (name.contains("."))
klass = Lang.loadClass(name);
else
klass = Lang.loadClass((new StringBuilder())
.append(getClass().getPackage().getName())
.append(".job.").append(name).toString());
cron(key, klass);
}
}
}
}
}