`
学会做人
  • 浏览: 120946 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

JBPM封装类

    博客分类:
  • JBPM
阅读更多

package net.sweet.service.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import net.sweet.dao.JbpmObjectUtilsDAO;
import net.sweet.jbpm.form.item.Item;
import net.sweet.jbpm.variable.VariableKey;
import net.sweet.log.level.Logger;
import net.sweet.service.DataBaseProber;
import net.sweet.service.WorkflowDriver;
import net.sweet.util.Constants;
import net.sweet.util.comparator.TaskInstanceComparator;

import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.context.exe.variableinstance.StringInstance;
import org.jbpm.db.GraphSession;
import org.jbpm.db.TaskMgmtSession;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.def.Task;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
import org.springframework.transaction.annotation.Transactional;
import org.springmodules.workflow.jbpm31.JbpmCallback;
import org.springmodules.workflow.jbpm31.JbpmTemplate;

@SuppressWarnings("unchecked")
public class JbpmWorkflowDriver implements WorkflowDriver {

 private JbpmTemplate jbpmTemplate;

 private DataBaseProber dataBaseProber;

 private JbpmObjectUtilsDAO jbpmObjectUtilsDao;

 public void setJbpmObjectUtilsDao(JbpmObjectUtilsDAO jbpmObjectUtilsDao) {
  this.jbpmObjectUtilsDao = jbpmObjectUtilsDao;
 }

 public void setJbpmTemplate(JbpmTemplate jbpmTemplate) {
  this.jbpmTemplate = jbpmTemplate;
 }

 public void setDataBaseProber(DataBaseProber dataBaseProber) {
  this.dataBaseProber = dataBaseProber;
 }

 /**
  * 返回当前系统所有流程定义
  */
 @Transactional(readOnly = true)
 public List<?> listAllProcessDefinition() {
  return (List<?>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    Logger.debug("go into listAllProcessDefinition");
    return jbpmContext.getGraphSession()
      .findAllProcessDefinitions();
   }
  });
 }

 /**
  * 开始流程实例,并设置流程发起者
  */
 @Transactional
 public Long startProcessInstance(final Long processDefinitionId,
   final String username) {
  return (Long) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    GraphSession graphSession = jbpmContext.getGraphSession();
    ProcessDefinition processDefinition = graphSession
    // .findLatestProcessDefinition("Approve");
      .loadProcessDefinition(processDefinitionId);

    ProcessInstance processInstance = new ProcessInstance(
      processDefinition);
    // 设置流程发起人
    processInstance.getContextInstance().setVariable(
      VariableKey.PROCESS_STARTER.name(), username);

    processInstance.signal();

    TaskInstance taskInstance = (TaskInstance) processInstance
      .getTaskMgmtInstance().getTaskInstances().iterator()
      .next();

    // taskInstance.getComments()
    Logger.debug("Task name is :" + taskInstance.getName());
    taskInstance.setActorId(username);
    taskInstance.setVariable(VariableKey.PROCESS_STARTER.name(),
      username);
    /*
     * taskInstance.setDescription("This is a [" + username + "]
     * '制单' task");
     */

    taskInstance.setDueDate(Constants.TASK_DUE_DATE);
    // taskInstance.end();
    // Save the process instance along with the task instance
    jbpmContext.save(processInstance);
    return processInstance.getId();
   }
  });
 }

 /**
  * 根据流程定义名字开启流程实例
  */
 @Transactional
 public Long startProcessInstance(final String processDefinitionName,
   final String username) {
  return (Long) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    GraphSession graphSession = jbpmContext.getGraphSession();
    ProcessDefinition processDefinition = graphSession
      .findLatestProcessDefinition(processDefinitionName);

    ProcessInstance processInstance = new ProcessInstance(
      processDefinition);
    // 设置流程发起人
    processInstance.getContextInstance().setVariable(
      VariableKey.PROCESS_STARTER.name(), username);

    processInstance.signal();

    /*
     * TaskInstance taskInstance = (TaskInstance) processInstance
     * .getTaskMgmtInstance().getTaskInstances().iterator() .next();
     * taskInstance.setActorId(username);
     */
    // taskInstance.setVariable(VariableKey.PROCESS_STARTER.name(),
    // username);
    // taskInstance.end();
    // Save the process instance along with the task instance
    jbpmContext.save(processInstance);
    return processInstance.getId();
   }
  });
 }

 /**
  * 根据流程实例获得当前流程的当前任务实例
  */
 @Transactional(readOnly = true)
 public TaskInstance getCurrentTaskInstance(final Long processInstanceId) {
  return (TaskInstance) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    ProcessInstance processInstance = jbpmContext
      .loadProcessInstance(processInstanceId);
    return processInstance.getTaskMgmtInstance().getTaskInstances()
      .iterator().next();
   }
  });
 }

 /**
  * 保存流程实例
  */
 @Transactional
 public void saveProcessInstance(final Long processInstanceId) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    ProcessInstance processInstance = jbpmContext
      .loadProcessInstance(processInstanceId);
    jbpmContext.save(processInstance);
    return null;
   }
  });
 }

 /**
  * 根据流程实例获得当前流程的当前任务实例
  */
 @Transactional(readOnly = true)
 public Task getCurrentTask(final Long processInstanceId) {
  return (Task) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    ProcessInstance processInstance = jbpmContext
      .loadProcessInstance(processInstanceId);
    return ((TaskInstance) processInstance.getTaskMgmtInstance()
      .getTaskInstances().iterator().next()).getTask();
   }
  });
 }

 /**
  * 取得当前任务实例所在的实例管理上下文中所有任务实例
  *
  * @param taskInstanceId
  * @return
  */
 @Transactional(readOnly = true)
 public Collection getAllTaskInstances(final Long taskInstanceId) {
  return (Collection) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance task = jbpmContext.getTaskInstance(taskInstanceId);
    List sortList = new ArrayList();
    sortList.addAll(task.getTaskMgmtInstance().getTaskInstances());
    Collections.sort(sortList, new TaskInstanceComparator());
    return sortList;
   }
  });
 }

 /**
  * 完成任务实例,并保存流程实例变量
  */
 @Transactional
 public void endTaskInstance(final Long taskInstanceId,
   final Map formParams, final String opinion, final String transition) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance task = jbpmContext.getTaskInstance(taskInstanceId);
    Set keySet = formParams.keySet();
    for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
     String key = (String) iterator.next();
     if (key.startsWith(Item.ITEM_PREFIX)
       && !key
         .endsWith(Item.FILE_PARAMETER_APPEND_POSTFIX)) {// 判断需要保存在流程实例中的变量
      String value = getValue(((String[]) formParams.get(key)));
      if (!isLargeString(value))// 判断是否为长字符串,如果是,则以byte[]形式保存,否则直接保存字符串
       task.getContextInstance().setVariable(key, value);
      else
       task.getContextInstance().setVariable(key,
         value.getBytes());
     }
    }
    // task.setVariable("opinion", opinion);
    task.setVariableLocally(VariableKey.TASK_OPINION.name(),
      opinion);
    // task.getVariablesLocally()
    // task.addComment(new Comment(opinion));
    task.end(transition);
    // task.getPooledActors();
    jbpmContext.save(task);
    return null;
   }
  });
 }

 /**
  * 完成任务实例
  */
 @Transactional
 public void endTaskInstance(final Long taskInstanceId,
   final String opinion, final String transition,
   final String taskProcessPerson) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance task = jbpmContext.getTaskInstance(taskInstanceId);
    task.setVariableLocally(VariableKey.TASK_OPINION.name(),
      opinion);
    task.setVariableLocally(VariableKey.TASK_PROCESS_PERSON.name(),
      taskProcessPerson);
    task.end(transition);
    jbpmContext.save(task);
    return null;
   }
  });
 }

 /**
  * 判断当前字符串是否属于长字符串,具体参照标准为‘jbpm_variableinstance’表中的‘STRINGVALUE_’字段长度
  *
  * @param str
  * @return
  */
 private boolean isLargeString(String str) {
  if (str.length() >= dataBaseProber.getFieldPrecision(
    "jbpm_variableinstance", "STRINGVALUE_"))
   return true;
  return false;
 }

 /**
  * 将字符数组的空间值循环构成字符串
  *
  * @param values
  * @return
  */
 private String getValue(String[] values) {
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < values.length; i++) {
   sb.append(values[i]);
   if (i != values.length - 1)
    sb.append(Item.MUTIPUL_VALUE_SPLIT);
  }
  return sb.toString();
 }

 /**
  * 完成任务,并结束任务
  */
 /*
  * @Transactional public void doTaskWithTaskEnd(final Long
  * processInstanceId, final String transition) { jbpmTemplate.execute(new
  * JbpmCallback() { public Object doInJbpm(JbpmContext jbpmContext) throws
  * JbpmException { ProcessInstance processInstance = jbpmContext
  * .loadProcessInstance(processInstanceId); TaskInstance task =
  * (TaskInstance) processInstance
  * .getTaskMgmtInstance().getTaskInstances().iterator() .next();
  * task.end(transition); jbpmContext.save(processInstance); return null; }
  * }); }
  */

 /**
  * 根据参与者名称获得当前所有非池任务实例
  */
 @SuppressWarnings("unchecked")
 @Transactional
 public List<Object> getTaskList(final String username) {
  return (List<Object>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    /*
     * ProcessInstance processInstance = jbpmContext
     * .loadProcessInstance(processInstanceId);
     */
    TaskMgmtSession taskMgmtSession = new TaskMgmtSession(
      jbpmContext.getSession());
    // return taskMgmtSession.findPooledTaskInstances(username);
    return taskMgmtSession.findTaskInstances(username);
   }
  });
 }

 /**
  * 根据参与者名称获得当前所有池任务实例
  */
 @SuppressWarnings("unchecked")
 @Transactional
 public List<Object> getPooledTaskList(final String username) {
  return (List<Object>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskMgmtSession taskMgmtSession = new TaskMgmtSession(
      jbpmContext.getSession());
    return taskMgmtSession.findPooledTaskInstances(username);
   }
  });
 }

 /**
  * 结束任务,并跳转到指定节点
  */
 @Transactional
 public void endTask(final Long taskInstanceId, final String transition) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance taskInstance = jbpmContext
      .getTaskInstance(taskInstanceId);
    taskInstance.end(transition);
    return null;
   }
  });
 }

 /**
  * 判断流程实例是否结束
  */
 @Transactional(readOnly = true)
 public Boolean isFinish(final Long processInstanceId) {
  return (Boolean) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    ProcessInstance processInstance = jbpmContext
      .loadProcessInstance(processInstanceId);
    return processInstance.hasEnded();
   }
  });
 }

 /**
  * 获得当前任务节点的所有可能流向
  */
 @Transactional(readOnly = true)
 public List<?> getTransitionByTaskNode(final Long taskInstanceId) {
  return (List<?>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance ti = jbpmContext.getTaskInstance(taskInstanceId);
    Logger.debug(ti.getContextInstance().getVariables());
    List<?> transitions = ti.getTask().getTaskNode()
      .getLeavingTransitionsList();
    return transitions;
   }
  });
 }

 /**
  * 获得当前任务实例对应的任务节点名称
  */
 @Transactional(readOnly = true)
 public String getTaskNodeName(final Long taskInstanceId) {
  return (String) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskInstance ti = jbpmContext.getTaskInstance(taskInstanceId);
    Logger.debug(ti.getContextInstance().getVariables());
    return ti.getTask().getTaskNode().getName();
   }
  });
 }

 /**
  * 获得流程实例信息
  */
 @Transactional(readOnly = true)
 public ProcessInstance getProcessInstance(final Long processInstanceId) {
  return (ProcessInstance) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getProcessInstance(processInstanceId);
   }
  });
 }

 /**
  * 获得流程实例变量集合
  */
 @Transactional(readOnly = true)
 public Map<String, String> getProcessInstanceVariables(
   final Long processInstanceId) {
  return (Map<String, String>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getProcessInstance(processInstanceId)
      .getContextInstance().getVariables();
   }
  });
 }

 /**
  * 获得任务实例信息
  */
 @Transactional(readOnly = true)
 public TaskInstance getTaskInstance(final Long taskInstanceId) {
  return (TaskInstance) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getTaskInstance(taskInstanceId);
   }
  });
 }

 /**
  * 根据流程定义,获得所有流程实例
  */
 @Transactional(readOnly = true)
 public List<?> getProcessInstances(final Long processDefinitionId) {
  return (List<?>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getGraphSession().findProcessInstances(
      processDefinitionId);
   }
  });
 }

 /**
  * 根据流程实例得到当前所有任务实例
  */
 @Transactional(readOnly = true)
 public Collection<?> getTaskInstances(final Long processInstanceId) {
  return (Collection<?>) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    ProcessInstance processInstance = jbpmContext
      .loadProcessInstance(processInstanceId);
    List sortList = new ArrayList();
    sortList.addAll(processInstance.getTaskMgmtInstance()
      .getTaskInstances());
    Collections.sort(sortList, new TaskInstanceComparator());
    return sortList;
   }
  });
 }

 /**
  * 根据流程定义ID获得流程定义名称
  *
  * @param processDefinitionId
  * @return
  */
 @Transactional(readOnly = true)
 public String getProcessDefinitionName(final Long processDefinitionId) {
  return (String) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getGraphSession().getProcessDefinition(
      processDefinitionId).getName();
   }
  });
 }

 /**
  * 根据流程定义获得任务列表
  *
  * @param processDefinitionId
  * @return
  */
 @Transactional(readOnly = true)
 public Map findTaskNode(final Long processDefinitionId) {
  return (Map) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getGraphSession().getProcessDefinition(
      processDefinitionId).getTaskMgmtDefinition().getTasks();
   }
  });
 }

 /**
  * 根据任务实例获得当前流程定义
  *
  * @param processDefinitionId
  * @return
  */
 @Transactional(readOnly = true)
 public ProcessDefinition findProcessDefinition(final Long taskInstanceId) {
  return (ProcessDefinition) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.getTaskInstance(taskInstanceId)
      .getContextInstance().getProcessInstance()
      .getProcessDefinition();
   }
  });
 }

 /**
  * 获得流程实例中的变量值
  *
  * @param processInstanceId
  * @param key
  * @return
  */
 @Transactional(readOnly = true)
 public Object getVariable(final Long processInstanceId, final String key) {
  return jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.loadProcessInstance(processInstanceId)
      .getContextInstance().getVariable(key);
   }
  });
 }

 /**
  * 根据任务实例标识得到流程实例的变量值
  *
  * @param processInsanceId
  * @param key
  *            变量key
  * @param value
  *            变量值
  */
 @Transactional(readOnly = true)
 public Object getVariableByTaskInstance(final Long taskInstanceId,
   final String key) {
  return jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.loadTaskInstance(taskInstanceId)
      .getContextInstance().getVariable(key);
   }
  });
 }

 /**
  * 向流程实例中保存流程变量
  *
  * @param processInsanceId
  * @param key
  *            变量key
  * @param value
  *            变量值
  */
 @Transactional
 public void insertVariable(final Long processInstanceId, final String key,
   final Object value) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    jbpmContext.loadProcessInstance(processInstanceId)
      .getContextInstance().setVariable(key, value);
    return null;
   }
  });
 }

 /**
  * 获得令牌实例对象
  *
  * @param tokenInstanceId
  * @return
  */
 @Transactional(readOnly = true)
 public Token getTokenInstance(final Long tokenInstanceId) {
  return (Token) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    return jbpmContext.loadToken(tokenInstanceId);
   }
  });
 }

 /**
  * 根据流程定义名字开启流程实例并停留在开始节点手动往下流转
  */
 @Transactional
 public Long startProcessInstanceNoSignal(
   final String processDefinitionName, final String username) {
  return (Long) jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    GraphSession graphSession = jbpmContext.getGraphSession();
    ProcessDefinition processDefinition = graphSession
      .findLatestProcessDefinition(processDefinitionName);

    ProcessInstance processInstance = new ProcessInstance(
      processDefinition);
    // 设置流程发起人
    processInstance.getContextInstance().setVariable(
      VariableKey.PROCESS_STARTER.name(), username);

    /*
     * TaskInstance taskInstance = (TaskInstance) processInstance
     * .getTaskMgmtInstance().getTaskInstances().iterator() .next();
     * taskInstance.setActorId(username);
     */
    // taskInstance.setVariable(VariableKey.PROCESS_STARTER.name(),
    // username);
    // taskInstance.end();
    // Save the process instance along with the task instance
    jbpmContext.save(processInstance);
    return processInstance.getId();
   }
  });
 }

 /**
  * 根据流程实例结束掉这个实例中所有未完成的任务
  *
  * @param processInsanceId
  */
 @Transactional
 public void endUnfinishedTasksByProcessInstanceId(
   final Long processInstanceId) {
  jbpmTemplate.execute(new JbpmCallback() {
   public Object doInJbpm(JbpmContext jbpmContext)
     throws JbpmException {
    TaskMgmtInstance tmi = jbpmContext.loadProcessInstance(
      processInstanceId).getTaskMgmtInstance();
    Collection<TaskInstance> taskInstanceCollection = tmi
      .getTaskInstances();
    for (TaskInstance taskInstance : taskInstanceCollection) {
     // 如果任务实例没有结束就结束掉该任务
     if (!taskInstance.hasEnded()) {
      taskInstance.end();
      jbpmContext.save(taskInstance);
     }
    }
    return null;
   }
  });
 }

 /**
  * 得到流程发起者的所有流程实例
  *
  * @param processStarter
  * @return
  */
 @Transactional
 public List getProcessInstances(String processStarter,
   String processDefinitionName, Boolean hasEnded) {
  String hql = "FROM StringInstance WHERE name = ? AND value = ? "
    + "AND processInstance.processDefinition.name = ? ";
  if (hasEnded != null) {
   if (hasEnded)
    hql = hql + "AND processInstance.end IS NOT NULL ";
   else
    hql = hql + "AND processInstance.end IS NULL ";
  }
  List list = jbpmObjectUtilsDao.find(hql, new Object[] {
    VariableKey.PROCESS_STARTER.name(), processStarter,
    processDefinitionName });
  List processInstances = new ArrayList();
  for (Iterator iterator = list.iterator(); iterator.hasNext();) {
   StringInstance si = (StringInstance) iterator.next();
   processInstances.add(this.getProcessInstance(si
     .getProcessInstance().getId()));
  }
  return processInstances;
 }
}

分享到:
评论
3 楼 wocsok 2009-10-09  
您好 楼主 请问  任务实例的begin() 和 end()  与 过程实例的  pi.signal()有什么区别与联系啊
2 楼 学会做人 2009-09-20  
processInstance.getContextInstance().setVariable("key","value")与taskInstance.("key","value")不一样的!
一个是将变量放到上下文实例中;另一个是将变量放到任务实例中!
如果是放到任务实例当中,取 变量也必须先得到该任务实例,再从中去变量!


至于你为什么流转时数据库会无数据:
是和你的事务有关的,如:<property name="transactionAttributes">
<props>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="upd*">PROPAGATION_REQUIRED</prop>
<prop key="modify*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="submit*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
</props>
</property>

这是你spring里的配置事务的,如果你的service里的方法名不是以你配置中的为开
头,就无法的往数据库里插入数据.
如你service里的方法名为:public void submitToWorkflow(String userId, String gongdId, String transitionName),所以你的spring配置文件里必须配置<prop key="submit*">PROPAGATION_REQUIRED</prop>,.
1 楼 dongyeyun 2009-09-17  
我接触jbpm的时间不长,processInstance.getContextInstance().setVariable("key","value")与taskInstance.("key","value")一样吗?都可以通过processInstance.getContextInstance().getVariable("key");的方式获取到吗?在jbpm当中关于JbpmContext对象该怎么管理啊?在节点流转的时候经常报错,通过查看jbpm的数据库发现里边的数据并没有更新,例如:在taskInstance.end("transitionName");后节点并没有流转而是任然停留在上一节点,Token表中绑定的还是上一节点,请你帮我指点一下。谢谢

相关推荐

    jbpm4请假实例代码

    3. **实体和数据模型**:实例代码中会包含员工、请假申请等实体类,这些类通常用来封装业务数据,并与数据库进行交互。数据模型的设计是理解业务逻辑的关键。 4. **服务任务和服务调用**:在请假流程中,可能会有...

    Struts整合jbpm的jar包

    - 创建一个ActionForm,用于封装与工作流相关的参数,如任务ID、流程实例ID等。 - 设计视图,显示工作流的状态、任务列表,以及处理任务的表单。你可以使用Struts的标签库来帮助渲染这些视图。 - 编写业务逻辑,...

    jbpm4流程提交及执行完整代码

    首先,`Service.java`通常是一个核心服务类,它封装了与jbpm4引擎交互的逻辑。在jbpm4中,我们可以通过服务接口来启动流程实例、完成任务、查询流程状态等。这个文件可能包含诸如`startProcessInstanceByKey`(根据...

    jbpm的扩展源代码

    - 其他辅助类和工具,如数据访问对象(DAO)和模型对象,用于与数据库交互和封装业务逻辑。 通过分析这些源代码,我们可以了解开发者如何根据实际需求对jbpm进行了定制,从而更好地理解和应用jbpm框架。对于想要...

    jbpm-jpdl-javadoc(jbpl api下载)

    其中,`org.jbpm.graph.def`包下的类用于定义流程图,`org.jbpm.process.instance`包则包含了运行时流程实例的管理。 在jbpm中,`ProcessDefinition`接口代表了一个流程模型,而`ProcessInstance`接口则表示正在...

    jbpm Demo 可以走通一个简单的流程

    你可以自定义服务任务的行为,将业务逻辑封装在Java服务类中,并通过工作流引擎调用。 9. **异常处理与回退**:jbpm允许定义异常处理和回退策略,当流程执行过程中遇到问题时,可以根据预设规则进行错误恢复或流程...

    jbpm4.3 流程申请(mina通信)

    这个客户端可能包含配置文件(如XML配置)、Mina相关的类(如服务发现、会话管理和编码解码器)以及业务逻辑代码,用于发起流程申请、处理响应和展示结果。 **总结** jbpm4.3结合Mina通信,为业务流程的远程调用和...

    jbpm4整合struts2+spring2[1].5+hibernate3.3

    jbpm4的流程启动、结束等操作可以通过Struts2的Action类进行封装,提供Web界面操作。 - **Action与流程**:jbpm4的流程状态可以通过Struts2的Action传递给视图层,用户可以在页面上查看或操作流程。 4. **整合过程...

    spring2_struts2_jbpm3.2.rar_jbpm struts2_jbpm-demo_jbpm3 spring_

    3. 创建Service Bean:实现对JBPM API的封装,如startProcess、completeTask等方法。 4. 配置Struts2:编写Struts2动作类,注入Service Bean,根据用户请求调用相应的方法。 5. 实现流程交互:在Struts2的Action中...

    JBPM4 web设计器实践--命令模式的使用

    文件可能包含类定义、接口实现、测试用例等,用于演示如何在JBPM4中应用命令模式。 深入讲解: 1. **命令模式的概念**:命令模式是一种行为设计模式,它将命令封装为一个对象,允许接收者和请求者解耦。在JBPM4的...

    SSH整合jbpm

    在SSH整合jbpm中,Struts的动作类可以调用Spring管理的jbpm服务,将流程实例的创建、结束等操作封装为用户友好的接口。 Hibernate作为ORM(对象关系映射)工具,简化了数据库操作。在jbpm中,可能会涉及到对流程...

    jbpm4.3请假的jar包

    这些业务逻辑可能封装在jar包的类文件中,通过调用Jbpm提供的API来与工作流引擎交互。 4. **持久化支持**: Jbpm4.3支持对流程实例的状态进行持久化存储,jar包中可能包含相关的数据库连接池和ORM框架,如Hibernate...

    JBoss jBPM jPDL中文指南

    - **服务** 和 **环境** 是jPDL中用于封装外部系统交互的概念。 - 服务可以是HTTP调用、数据库操作等,而环境则定义了这些服务运行的上下文。 #### 七、注意事项 ##### 7.1 运行时数据隔离 - **数据隔离** 是指在...

    JBPM工作流演示系统使用说明

    - **com.aptech.handler**:封装了JBPM相关的组件,如动作处理器,实现了流程控制的核心逻辑。 - **com.aptech.pojo**:包含了六个POJO类,用于映射数据库实体,简化数据操作。 - **com.aptech.service**:业务逻辑...

    JBPM学习笔记

    策略模式允许算法家族独立于使用它的客户端,通过定义一系列算法,并把它们一个个封装起来,使它们可以相互替换。这使得算法可以独立于使用它的客户端变化。策略模式适用于需要根据上下文动态地选择不同行为的情况。...

    jbpm-bpel.pdf

    2. **数据处理**:在BPEL流程中,数据通常被封装为消息,并且可以在不同的服务之间传递。jBPM支持高级的数据处理功能,如变量映射、数据转换等,确保了数据的一致性和完整性。 3. **与流程的交互**:除了传统的...

Global site tag (gtag.js) - Google Analytics