}
JobDetail jobDetail = new JobDetail(taskInstance.getTaskInstanceId().toString(), null, ScheduledTaskTransitionJob.class); jobDetail.getJobDataMap().put(TASK_INSTANCE_ID_KEY, taskInstance.getTaskInstanceId());  ZebraTaskDefinition taskDef = (ZebraTaskDefinition) taskInstance.getTaskDefinition(); String wait = taskDef.getGeneralProperties().getString("Wait"); log.info("Wait is : " + wait); log.info("Delay is :" + new Long(delay(wait)).toString());   SimpleTrigger trigger = new SimpleTrigger(); trigger.setStartTime(new Date(new Date().getTime() + delay(wait))); trigger.setName("delay"); scheduler.scheduleJob(jobDetail, trigger);     taskInstance.setState(ITaskInstance.STATE_RUNNING); ITransaction t = zebra.getStateFactory().beginTransaction(); zebra.getStateFactory().saveObject(taskInstance); t.commit(); log.info("Save task in state:" + taskInstance.getState());  } catch (SchedulerException se) { throw new RunTaskException(se); } catch (StateFailureException e) { throw new RunTaskException(e); } } else {  taskInstance.setState(ITaskInstance.STATE_AWAITINGCOMPLETE); }  }
	public void runTask(ITaskInstance taskInstance) throws RunTaskException {		try {			/*			 * Create your Scheduled job			 */			JobDetail jobDetail = new JobDetail(taskInstance					.getTaskInstanceId().toString(), null,					ScheduledTaskTransitionJob.class);			jobDetail.getJobDataMap().put(TASK_INSTANCE_ID_KEY,					taskInstance.getTaskInstanceId());			/*			 * get the poll interval from taskInstace.getTaskDefinition			 * (downcast to ZebraTaskDefinition) get property.			 */			ZebraTaskDefinition taskDef = (ZebraTaskDefinition) taskInstance					.getTaskDefinition();			String wait = taskDef.getGeneralProperties().getString(					"Wait");			log.info("Wait is : " + wait);			log.info("Delay is :" + new Long(delay(wait)).toString());			/*			 * Wait supports delay times in : - 			 * 	S	Seconds ( Default )			 *  M	Minutes			 *  H	Hours			 *  D	Days			 *   			 */						SimpleTrigger trigger = new SimpleTrigger();			trigger.setStartTime(new Date(new Date().getTime() + delay(wait)));			trigger.setName("delay");			scheduler.scheduleJob(jobDetail, trigger);			/*			 * Don't set the state unlike every other task action as the state			 * will be set when the trigger fires.			 */		} catch (DefinitionNotFoundException dnfe) {			throw new RunTaskException(dnfe);		} catch (SchedulerException se) {			throw new RunTaskException(se);		}	}