Package org.jbpm.env.session

Examples of org.jbpm.env.session.Job


    return result;
  }

  public ObjectReference<Activity> getScheduledActivity(long id) {
    ObjectReference<Activity> result = null;
    Job job =
      Environment.getCurrent().get(JobSession.class).get(id);
    Timer timer = null;
    if (job instanceof Timer) {
      timer = (Timer) job;
    }
View Full Code Here


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

  public Object execute(Environment environment) throws Exception {
  Job job = environment.get(JobSession.class).get(jobDbid);

    try {
      log.fine("executing job "+job+"...");
      job.execute(environment);

      // if this job is locked too long, it could be unlocked by the lockmonitor and
      // executed by another thread.
      Date lockExpirationDate = job.getLockExpirationTime();
      //can be null if it was rescheduled
      if (lockExpirationDate != null) {
        long lockExpiration = lockExpirationDate.getTime();
        long currentTime = System.currentTimeMillis();
        if (currentTime>lockExpiration) {
View Full Code Here

    Collection<Job> acquiredJobs = new ArrayList<Job>();
   
    JobSession jobService = environment.get(JobSession.class);
    log.fine("start querying first acquirable job...");
    Job job = jobService.getFirstAcquirableJob();
    if (job!=null) {
      if (job.isExclusive()) {
        log.finest("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
        List<Job> otherExclusiveJobs = jobService.findExclusiveJobs(job.getProcessInstance());
        acquiredJobs.addAll(otherExclusiveJobs);
      } else {
        acquiredJobs.add(job);
      }
View Full Code Here

  public Object execute(Environment environment) throws Exception {
    Date nextDueDate = null;
    log.fine("getting next due date...");
    JobSession jobSession = environment.get(JobSession.class);
    Job job = jobSession.getFirstDueJob();
    if (job!=null) {
      nextDueDate = job.getDueDate();
    }
    log.fine("next due date is "+nextDueDate);
    return nextDueDate;
  }
View Full Code Here

    Collections.sort(result, dueDateJobComparatorDesc);
    return result;
  }

  public Job get(long jobId) {
    Job result = null;
    for (Job job : jobs) {
      if (job.getDbid() == jobId) {
        result = job;
        break;
      }
View Full Code Here

    }
    return result;
  }

  public Job getFirstAcquirableJob() {
    Job result = null;
    long firstAcquirableDate = Long.MAX_VALUE;
    long currentTime = System.currentTimeMillis();
    for (Job job : jobs) {
      if ( (job.getLockExpirationTime() == null ||
          job.getLockExpirationTime().getTime() < currentTime) &&
View Full Code Here

    }
    return result;
  }

  public Job getFirstDueJob() {
    Job result = null;
    long firstDueDate = Long.MAX_VALUE;
    long currentTime = System.currentTimeMillis();
    for (Job job : jobs) {
      if (job.getLockOwner() == null &&
        (job.getEligibleDate() == null ||
View Full Code Here

    commandService.execute(this);
  }

  public Object execute(Environment environment) throws Exception {
    // load the job from the db
    Job job = environment.get(JobSession.class).get(jobDbid);
    // serialize the stack trace
    StringWriter sw = new StringWriter();
    exception.printStackTrace(new PrintWriter(sw));
    job.setException(sw.toString());
    // decrement the number of retries
    job.setRetries(job.getRetries()-1);
    return null;
  }
View Full Code Here

TOP

Related Classes of org.jbpm.env.session.Job

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.