public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
Task task = null;
JobDetail jobDetail = jobExecutionContext.getJobDetail();
if (log.isDebugEnabled()) {
log.debug("Executing Function scheduling task : " + jobDetail.getFullName());
}
Map mjdm = jobExecutionContext.getMergedJobDataMap();
String jobClassName = (String) mjdm.get(CLASSNAME);
if (jobClassName == null) {
throw new CarbonException("No " + CLASSNAME + " in JobDetails");
}
try {
task = (Task) getClass().getClassLoader().loadClass(jobClassName).newInstance();
} catch (Exception e) {
throw new CarbonException("Cannot instantiate Function scheduling task : " + jobClassName, e);
}
/*Set properties = (Set) mjdm.get(PROPERTIES);
for (Object property : properties) {
OMElement prop = (OMElement) property;
log.debug("Found Property : " + prop.toString());
PropertyHelper.setStaticProperty(prop, task);
}*/
// 1. Initialize
if (task instanceof FunctionExecutionTaskLifeCycleCallBack) {
// initialize FunctionExecutionTask with JobDataMap
((FunctionExecutionTask) task).init(
jobDetail.getJobDataMap());
}
// 2. Execute
task.execute();
// 3. Destroy
if (task instanceof FunctionExecutionTaskLifeCycleCallBack) {
((FunctionExecutionTaskLifeCycleCallBack) task).destroy();
}