Element rootElement = document.getRootElement();
List jobElements = XPath.newInstance("/jobs/job").selectNodes(rootElement);
List startupJobs = new ArrayList();
for ( Iterator i = jobElements.iterator(); i.hasNext(); ) {
Element jobElement = (Element)i.next();
Step job = new Step();
job.configure(jobElement);
String trigger = jobElement.getAttributeValue("trigger");
if ( trigger == null || trigger.equals(STARTUP) ) {
if ( !installedJobNames.contains(STARTUP_IDENTIFIER+job.getName()) ) {
startupJobs.add(job);
installedJobNames.add(job.getName());
}
} else if ( trigger.equals(REQUEST) ) {
requestJobs.add(job);
} else if ( trigger.equals(SESSION) ) {
sessionJobs.add(job);
}
}
// Note: starting jobs after reading all, to avoid writing to configuration files while reading...
for ( Iterator i = startupJobs.iterator(); i.hasNext(); ) {
Step job = (Step)i.next();
if ( job.getName().startsWith(STARTUP_IDENTIFIER) ) {
context.setStep(job.getName());
} else {
context.setStep(STARTUP_IDENTIFIER+job.getName());
}
launchJob(job, context);
if ( !restoreRunningJobs ) {
Projector.getRepository().subscribe("Update", jobsUri, 0,
new Subscriber() {