synchronized (jobExecutor) {
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
log.debug("querying for acquirable job...");
String lockOwner = getName();
JobSession jobSession = jbpmContext.getJobSession();
Job job = jobSession.getFirstAcquirableJob(lockOwner);
if (job != null) {
if (job.isExclusive()) {
ProcessInstance processInstance = job.getProcessInstance();
log.debug("loaded exclusive " + job + ", finding exclusive jobs for " + processInstance);
acquiredJobs = jobSession.findExclusiveJobs(lockOwner, processInstance);
log.debug("trying to obtain locks on " + acquiredJobs + " for " + processInstance);
}
else {
acquiredJobs = Collections.singletonList(job);
log.debug("trying to obtain lock on " + job);