Package org.jbpm.db

Examples of org.jbpm.db.JobSession


  public ExecuteJobCommand(long jobId) {
    this.jobId = jobId;
  }

  public Object execute(JbpmContext jbpmContext) throws Exception {
    JobSession jobSession = jbpmContext.getJobSession();
    log.debug("loading job "+jobId);
    Job job = jobSession.loadJob(jobId);
    log.debug("executing job "+jobId);
    if (!job.execute(jbpmContext)) {
      log.warn("job "+jobId+" was not supposed to be deleted");
    }
    jobSession.deleteJob(job);
    return null;
  }
View Full Code Here


    Collection jobsToLock = new ArrayList();
    log.debug("acquiring jobs for execution...");

    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
        {
View Full Code Here

    return acquiredJobs;
  }

  protected void executeJob(Job job)
  {
    JobSession jobSession = jbpmContext.getJobSession();
    job = jobSession.loadJob(job.getId());

    try
    {
      log.debug("executing job " + job);
      if (job.execute(jbpmContext))
      {
        jobSession.deleteJob(job);
      }

    }
    catch (Exception e)
    {
View Full Code Here

  }

  protected Date getNextDueDate()
  {
    Date nextDueDate = null;
    JobSession jobSession = jbpmContext.getJobSession();
    Job job = jobSession.getFirstDueJob(getName(), new ArrayList());
    if (job != null)
    {
      nextDueDate = job.getDueDate();
    }
    return nextDueDate;
View Full Code Here

  protected void unlockOverdueJobs() {
    List<Job> overdueJobs = null;
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      Date threshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
      JobSession jobSession = jbpmContext.getJobSession();
      overdueJobs = jobSession.findJobsWithOverdueLockTime(threshold);
      for (Job job : overdueJobs) {
        log.debug("unlocking " + job + " owned by thread " + job.getLockOwner());
        job.setLockOwner(null);
        job.setLockTime(null);
      }
View Full Code Here

    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);
View Full Code Here

  }

  protected void executeJob(Job job) {
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      JobSession jobSession = jbpmContext.getJobSession();
      job = jobSession.loadJob(job.getId());

      log.debug("executing " + job);
      try {
        if (job.execute(jbpmContext)) {
          jobSession.deleteJob(job);
        }
      }
      catch (Exception e) {
        log.debug("exception while executing " + job, e);
        if (!DbPersistenceService.isPersistenceException(e)) {
View Full Code Here

  protected Date getNextDueDate() {
    Date nextDueDate = null;
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      JobSession jobSession = jbpmContext.getJobSession();
      Collection<Long> jobIdsToIgnore = jobExecutor.getMonitoredJobIds();
      Job job = jobSession.getFirstDueJob(getName(), jobIdsToIgnore);
      if (job != null) {
        nextDueDate = job.getDueDate();
        jobExecutor.addMonitoredJobId(getName(), job.getId());
      }
    }
View Full Code Here

  public JobSession getJobSession() {
    if (jobSession == null) {
      Session session = getSession();
      if (session != null) {
        jobSession = new JobSession(session);
      }
    }
    return jobSession;
  }
View Full Code Here

  }

  void suspendJobs()
  {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    JobSession jobSession = (jbpmContext != null ? jbpmContext.getJobSession() : null);
    if (jobSession != null)
    {
      jobSession.suspendJobs(this);
    }
  }
View Full Code Here

TOP

Related Classes of org.jbpm.db.JobSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.