JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
try {
JobSession jobSession = jbpmContext.getJobSession();
log.debug("querying for acquirable job...");
Job job = jobSession.getFirstAcquirableJob(getName());
if (job!=null) {
if (job.isExclusive()) {
log.debug("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
List otherExclusiveJobs = jobSession.findExclusiveJobs(getName(), job.getProcessInstance());
jobsToLock.addAll(otherExclusiveJobs);
log.debug("trying to obtain a process-instance exclusive locks for '"+otherExclusiveJobs+"'");
} else {
log.debug("trying to obtain a lock for '"+job+"'");
jobsToLock.add(job);
}
Iterator iter = jobsToLock.iterator();
while (iter.hasNext()) {
job = (Job) iter.next();
job.setLockOwner(getName());
job.setLockTime(new Date());
// jbpmContext.getSession().update(job);
}
// HACKY HACK : this is a workaround for a hibernate problem that is fixed in hibernate 3.2.1
if (job instanceof Timer) {