Package org.jbpm

Examples of org.jbpm.JbpmContext


    // if this parsing is done in the context of a process deployment, there is
    // a database connection to look up the subprocess.
    // when there is no jbpmSession, the definition will be left null... the
    // testcase can set it as appropriate.
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext != null) {
     
      // now, we must be able to find the sub-process
      if (subProcessName != null) {
       
        // if the name and the version are specified
        if (subProcessVersion != null) {
         
          try {
            int version = Integer.parseInt(subProcessVersion);
            // select that exact process definition as the subprocess definition
            subProcessDefinition = jbpmContext.getGraphSession().findProcessDefinition(subProcessName, version);

          } catch (NumberFormatException e) {
            throw new JpdlException("version in process-state was not a number: " + subProcessElement.asXML());
          }
         
        } else { // if only the name is specified
          // select the latest version of that process as the subprocess
          // definition
          subProcessDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition(subProcessName);
        }
      } else {
        throw new JpdlException("no sub-process name specfied in process-state: " + subProcessElement.asXML());
      }
    }
View Full Code Here


    result[1] = Integer.valueOf(root.attribute("height").getValue()).intValue();
    return result;
  }

  private void initialize() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (this.taskInstanceId > 0) {
      TaskInstance taskInstance = jbpmContext.getTaskMgmtSession().loadTaskInstance(taskInstanceId);
      currentToken = taskInstance.getToken();
    }
    else
    {
      if (this.tokenInstanceId > 0)
        currentToken = jbpmContext.getGraphSession().loadToken(this.tokenInstanceId);
    }
    processDefinition = currentToken.getProcessInstance().getProcessDefinition();
  }
View Full Code Here

   */
  public long executeTimers() {
    long millisTillNextTimerIsDue = -1;
    boolean isDueDateInPast = true;
   
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(jbpmContextName);
    try {

      SchedulerSession schedulerSession = jbpmContext.getSchedulerSession();
     
      log.debug("checking for timers");
      Iterator iter = schedulerSession.findTimersByDueDate();
      while( (iter.hasNext())
             && (isDueDateInPast)
           ) {
        Timer timer = (Timer) iter.next();
        log.debug("found timer "+timer);
       
        // if this timer is due
        if (timer.isDue()) {
          log.debug("executing timer '"+timer+"'");
           
          // execute
          timer.execute();
         
          // save the process instance
          jbpmContext.save(timer.getProcessInstance());
           
          // notify the listeners (e.g. the scheduler servlet)
          notifyListeners(timer);
           
          // if there was an exception, just save the timer
          if (timer.getException()!=null) {
            schedulerSession.saveTimer(timer);
           
          // if repeat is specified
          } else if (timer.getRepeat()!=null) {
            // update timer by adding the repeat duration
            Date dueDate = timer.getDueDate();
           
            // suppose that it took the timer runner thread a
            // very long time to execute the timers.
            // then the repeat action dueDate could already have passed.
            while (dueDate.getTime()<=System.currentTimeMillis()) {
              dueDate = businessCalendar
                    .add(dueDate,
                      new Duration(timer.getRepeat()));
            }
            timer.setDueDate( dueDate );
            // save the updated timer in the database
            log.debug("saving updated timer for repetition '"+timer+"' in '"+(dueDate.getTime()-System.currentTimeMillis())+"' millis");
            schedulerSession.saveTimer(timer);
           
          } else {
            // delete this timer
            log.debug("deleting timer '"+timer+"'");
            schedulerSession.deleteTimer(timer);
          }

        } else { // this is the first timer that is not yet due
          isDueDateInPast = false;
          millisTillNextTimerIsDue = timer.getDueDate().getTime() - System.currentTimeMillis();
        }
      }
     
    } finally {
      jbpmContext.close();
    }
   
    return millisTillNextTimerIsDue;
  }
View Full Code Here

  MessagingSession messagingSession = null;
  Collection destinations = null;
 
  public DbMessageService() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext==null) {
      throw new JbpmException("instantiation of the DbMessageService requires a current JbpmContext");
    }
    this.messagingSession = jbpmContext.getMessagingSession();
  }
View Full Code Here

 
  public List getProcessDefinitions() {
   
    ArrayList processDefinitionsList = new ArrayList();

    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    List processDefinitions = jbpmContext.getGraphSession().findAllProcessDefinitions();

    if (processDefinitions.isEmpty() == false) {
      ListIterator listProcessDefinitions = processDefinitions.listIterator();
      while (listProcessDefinitions.hasNext() ) {
        ProcessDefinition processDefinition = (ProcessDefinition)listProcessDefinitions.next();

        int instancesCount = 0;
        try {
          Connection connection = jbpmContext.getConnection();
          Statement statement = connection.createStatement();
         
          String request = "SELECT COUNT(*) AS instancesCount "
            + "FROM jbpm_processinstance "
            + "WHERE processdefinition_='"
View Full Code Here

 
  public String searchInstances() {

    long count = 0;
   
        JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();

    try {
      Connection connection = jbpmContext.getConnection();
      Statement statement = connection.createStatement();
      statement.setMaxRows(100);
     
      String request = "SELECT DISTINCT processinstance_, name_, stringvalue_  FROM jbpm_variableinstance "
            + "WHERE name_ "
View Full Code Here

      throw new JbpmException("couldn't continue execution for '"+token+"', token moved");
    }
    ExecutionContext executionContext = new ExecutionContext(token);
    node.execute(executionContext);
   
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext!=null) {
      jbpmContext.save(token);
    }
  }
View Full Code Here

  private static final long serialVersionUID = 1L;

  public boolean matches(Class valueClass) {
    boolean matches = false;
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext!=null) {
      SessionFactory sessionFactory = jbpmContext.getSessionFactory();
      ClassMetadata classMetadata = sessionFactory.getClassMetadata(valueClass);
      matches = ( (classMetadata!=null)
                  && (classMetadata.getIdentifierType().getClass()==StringType.class)
                 );
    } else {
View Full Code Here

  private static final long serialVersionUID = 1L;

  public boolean matches(Class valueClass) {
    boolean matches = false;
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext!=null) {
      SessionFactory sessionFactory = jbpmContext.getSessionFactory();
      ClassMetadata classMetadata = sessionFactory.getClassMetadata(valueClass);
      matches =  ( (classMetadata!=null)
                   && (classMetadata.getIdentifierType().getClass()==LongType.class)
                 );
    } else {
View Full Code Here

    }

    Services services = new Services(serviceFactories, serviceNames, saveOperations);
   
    if (log.isDebugEnabled()) log.debug("creating jbpm context with service factories '"+serviceFactories.keySet()+"'");
    return new JbpmContext(services, objectFactory);
  }
View Full Code Here

TOP

Related Classes of org.jbpm.JbpmContext

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.