Package org.jbpm.pvm.internal.env

Examples of org.jbpm.pvm.internal.env.EnvironmentImpl


    return false;
  }
 
  public void handle(ExecutionImpl execution, Exception exception) {
    if (isTransactional) {
      EnvironmentImpl environment = EnvironmentImpl.getCurrent();
      Transaction transaction = (environment!=null ? environment.get(Transaction.class) : null);
      if (transaction!=null) {
        log.trace("registering exception handler to "+transaction);
        CommandService commandService = environment.get(CommandService.class);
        if (commandService==null) {
          throw new JbpmException("environment doesn't have a command service for registering transactional exception handler", exception);
        }
        ExceptionHandlerSynchronization exceptionHandlerSynchronization = new ExceptionHandlerSynchronization(
                this, execution,
View Full Code Here


            + " to recipients of type "
            + recipientType, e);
      }
    }

    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    IdentitySession identitySession = environment.get(IdentitySession.class);
    AddressResolver addressResolver = environment.get(AddressResolver.class);

    // resolve and tokenize users
    String userList = addressTemplate.getUsers();
    if (userList != null) {
      String[] userIds = tokenizeActors(userList, execution);
View Full Code Here

  public static void fire(HistoryEvent historyEvent) {
    fire(historyEvent, null);
  }
 
  public static void fire(HistoryEvent historyEvent, ExecutionImpl execution) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment!=null) {
     
      HistorySession historySession = environment.get(HistorySession.class);
      if (historySession!=null) {
        historyEvent.setExecution(execution);
        historySession.process(historyEvent);       
      }
    }
View Full Code Here

  public ExecuteJobCmd(Long jobDbid) {
    this.jobDbid = jobDbid;
  }

  public Job execute(Environment environmentInterface) throws Exception {
    EnvironmentImpl environment = (EnvironmentImpl) environmentInterface;
    DbSession dbSession = environment.get(DbSession.class);
    if (dbSession==null) {
      throw new JbpmException("no db-session configured");
    }
    JobImpl<?> job = (JobImpl<?>) dbSession.get(JobImpl.class, jobDbid);

    // in case of decision jobs, the job might have been deleted
    // before we execute it (they are in a list)
    if (job != null) {
        JobContext jobContext = new JobContext(job);
        environment.setContext(jobContext);
      try {
        log.debug("executing job "+job+"...");
        job.execute(environment);
        log.debug("executed job "+job);

        // 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) {
            throw new JbpmException("job took too long: lock expired "+(currentTime-lockExpiration)+"ms ago");
          }
        }
      } catch (Exception exception) {
        log.error("exception while executing '"+job+"'", exception);
        handleJobExecutionException(environment, job, exception);
      } finally {
        environment.removeContext(jobContext);
      }

    } else {
      log.debug("job " + jobDbid + " no longer exists");
    }
View Full Code Here

public class StandardTransactionInterceptor extends Interceptor {
 
  private static final Log log = Log.getLog(StandardTransactionInterceptor.class.getName());
 
  public <T> T execute(Command<T> command) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment==null) {
      throw new JbpmException("no environment for managing hibernate transaction");
    }

    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
    if (standardTransaction==null) {
      throw new JbpmException("no standard-transaction in environment");
    }
   
    standardTransaction.begin();
View Full Code Here

      return create(objectName, isDelayable);
    }
   
    // then check if we can find it in the environment (if one is available)
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment!=null) {
      log.trace("delivering "+objectName+" from environment");
      return environment.get(objectName);
    }
   
    log.trace("delivering null for undefined object "+objectName);
    return null;
  }
View Full Code Here

    String transitionName = null;

    ExecutionContext originalExecutionContext = null;
    ExecutionContext subProcessExecutionContext = null;
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment!=null) {
      originalExecutionContext = (ExecutionContext) environment.removeContext(Context.CONTEXTNAME_EXECUTION);
      subProcessExecutionContext = new ExecutionContext((ExecutionImpl) subProcessInstance);
      environment.setContext(subProcessExecutionContext);
    }

    try {
      subProcessInstance.setSuperProcessExecution(null);
      executionImpl.setSubProcessInstance(null);
     

      for (SubProcessOutParameterImpl outParameter: outParameters) {
        outParameter.consume(executionImpl, subProcessInstance);
      }
     
      Activity activity = execution.getActivity();
      String subProcessActivityName = subProcessInstance.getActivityName();
     
      if (outcomeExpression!=null) {
        ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
        Object value = scriptManager.evaluateExpression(outcomeExpression, null);
        // if the value is a String and matches the name of an outgoing transition
        if ( (value instanceof String)
             && (activity.hasOutgoingTransition(((String) value)))
           ) {
          // then take that one
          transitionName = (String) value;
        } else {
          // else see if there is a value mapping
          transitionName = outcomeVariableMappings.get(value);
        }

      } else if (activity.hasOutgoingTransition(subProcessActivityName)) {
        transitionName = subProcessActivityName;
      }

    } finally {
      if (subProcessExecutionContext!=null) {
        environment.removeContext(subProcessExecutionContext);
      }
      if (originalExecutionContext!=null) {
        environment.setContext(originalExecutionContext);
      }
    }
   
    executionImpl.historyActivityEnd();
View Full Code Here

  private static final long serialVersionUID = 1L;

  public void notify(EventListenerExecution execution) throws Exception {
    // find current task
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    DbSession dbSession = environment.get(DbSession.class);
    TaskImpl task = dbSession.findTaskByExecution(execution);

    // make task available to mail templates through task context
    TaskContext taskContext = new TaskContext(task);
    environment.setContext(taskContext);
    try {
      Collection<Message> messages = mailProducer.produce(execution);
      environment.get(MailSession.class).send(messages);
    } finally {
      environment.removeContext(taskContext);
    }
  }
View Full Code Here

  protected ListDescriptor parametersDescriptor;
  protected String resultVariableName;
  protected boolean isResultUnique;

  public void perform(OpenExecution execution) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment==null) {
      throw new JbpmException("no environment for jpdl activity "+HqlBinding.TAG);
    }
    Session session = environment.get(Session.class);
   
    Query q = createQuery(session);
   
    if (parametersDescriptor!=null) {
      for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.env.EnvironmentImpl

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.