String jobClassName = (String) jdm.get(CLASSNAME);
if (jobClassName == null) {
handleException("No " + CLASSNAME + " in JobDetails");
}
Task task = null;
try {
task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
} catch (Exception e) {
handleException("Cannot instantiate task : " + jobClassName, e);
}
Set properties = (Set) jdm.get(PROPERTIES);
Iterator it = properties.iterator();
while (it.hasNext()) {
OMElement prop = (OMElement) it.next();
log.debug("Found Property : " + prop.toString());
PropertyHelper.setStaticProperty(prop, task);
}
SynapseEnvironment se = (SynapseEnvironment) jdm.get("SynapseEnvironment");
if (task instanceof ManagedLifecycle) {
if (se != null) {
((ManagedLifecycle) task).init(se);
}
}
if (se.isInitialized()) {
task.execute();
}
}