本文整理汇总了Java中org.activiti.engine.RuntimeService类的典型用法代码示例。如果您正苦于以下问题:Java RuntimeService类的具体用法?Java RuntimeService怎么用?Java RuntimeService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeService类属于org.activiti.engine包,在下文中一共展示了RuntimeService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startProcess
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@Test
public void startProcess() throws Exception {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("confirmPublish", "N");
String processId = "Employee360DegreeFeedbackProjectPublishProcess";
RuntimeService runtimeService = (RuntimeService) AppContext.getBean("runtimeService");
ProcessInstance process = runtimeService.startProcessInstanceByKey(processId, paramMap);
System.out.println("DeploymentId: " + process.getDeploymentId() );
System.out.println("ActivityId: " + process.getActivityId() );
System.out.println("Name: " + process.getName() );
System.out.println("ProcessDefinitionId: " + process.getProcessDefinitionId());
System.out.println("ProcessDefinitionKey: " + process.getProcessDefinitionKey());
System.out.println("ProcessDefinitionName: " + process.getProcessDefinitionName());
System.out.println("BusinessKey: " + process.getBusinessKey());
}
示例2: testSend
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@Deployment
public void testSend() {
ProcessEngine processEngine = muleContext.getRegistry().get("processEngine");
TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());
RuntimeService runtimeService = muleContext.getRegistry().get("runtimeService");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
assertEquals(10, result);
}
示例3: triggerSignalEvent
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
/**
* Trigger a signal event on all executions for a specific business key.
*
* @see <a href="http://www.activiti.org/userguide/index.html#bpmnSignalEventDefinition" />
* @see CoreSignals
*/
protected void triggerSignalEvent(ProcessEngine processEngine, String businessKey, String signalName) {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceBusinessKey(businessKey).singleResult();
List<Execution> executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getProcessInstanceId())
.signalEventSubscriptionName(signalName).list();
if (executions.isEmpty()) {
throw new NoSuchElementException(String.format("No executions found waiting " +
"for signal '%s' on process %s", signalName, businessKey));
}
for (Execution execution : executions) {
LOG.info("Sending '{}' signal to execution {} for process {}",
new Object[]{signalName, execution.getId(), businessKey});
runtimeService.signalEventReceived(signalName, execution.getId());
}
}
示例4: getEngineServices
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@Override
public EngineServices getEngineServices() {
if (this.engineServicesMock != null) {
return this.engineServicesMock;
}
this.engineServicesMock = mock(EngineServices.class);
when(engineServicesMock.getFormService()).thenReturn(mock(FormService.class));
when(engineServicesMock.getHistoryService()).thenReturn(mock(HistoryService.class));
when(engineServicesMock.getIdentityService()).thenReturn(mock(IdentityService.class));
when(engineServicesMock.getManagementService()).thenReturn(mock(ManagementService.class));
when(engineServicesMock.getRepositoryService()).thenReturn(mock(RepositoryService.class));
when(engineServicesMock.getRuntimeService()).thenReturn(mock(RuntimeService.class));
when(engineServicesMock.getTaskService()).thenReturn(mock(TaskService.class));
return engineServicesMock;
}
示例5: setUp
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@BeforeTest
public void setUp(){
RuntimeService rts = mock(RuntimeService.class);
List<ProcessInstance> processList = new ArrayList<ProcessInstance>();
ExecutionEntity executionEntity = new ExecutionEntity();
executionEntity.setActive(false);
processList.add(executionEntity);
ProcessInstanceQuery pQuery = mock(ProcessInstanceQuery.class);
when(pQuery.active()).thenReturn(pQuery);
when(pQuery.list()).thenReturn(processList);
when(rts.createProcessInstanceQuery()).thenReturn(pQuery);
this.servlet.setRuntimeService(rts);
this.servlet.setWoDispatcher(mock(WoDispatcher.class));
this.servlet.init();
}
示例6: stopProcessInstance
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public void stopProcessInstance(String instanceId, String username, OperationResult parentResult) {
OperationResult result = parentResult.createSubresult(OPERATION_STOP_PROCESS_INSTANCE);
result.addParam("instanceId", instanceId);
RuntimeService rs = activitiEngine.getRuntimeService();
try {
LOGGER.trace("Stopping process instance {} on the request of {}", instanceId, username);
String deletionMessage = "Process instance stopped on the request of " + username;
rs.setVariable(instanceId, CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_IS_STOPPING, Boolean.TRUE);
rs.deleteProcessInstance(instanceId, deletionMessage);
} catch (RuntimeException e) {
result.recordFatalError("Process instance couldn't be stopped: " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例7: execute
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public void execute(DelegateExecution execution) {
if (LOGGER.isTraceEnabled()) {
RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
Set<String> variablesSeen = new HashSet<>();
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId());
// LOGGER.trace("All variables for execution id={}, parent id={}", execution.getId(), execution.getParentId());
// execution.getVariableInstances().forEach((n, v) -> LOGGER.trace(" - {} = {} (in {})", n, v.getValue(), v.getExecutionId()));
LOGGER.trace("Execution hierarchy for id={}", execution.getId());
LOGGER.trace("------------------------------------");
dumpExecutionVariables(execution.getId(), execution, null, variablesSeen, runtimeService);
Collection<String> disjunction = CollectionUtils.disjunction(variablesSeen, execution.getVariableNames());
if (!disjunction.isEmpty()) {
LOGGER.trace("*** Variables not found in execution tree or 'execution.getVariableNames()': {}", disjunction);
}
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId() + " END ------------");
}
}
示例8: testStartProcess
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@Test
public void testStartProcess() throws Exception {
// 创建流程引擎,使用内存数据库
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.buildProcessEngine();
// 部署流程定义文件
RepositoryService repositoryService = processEngine.getRepositoryService();
String processFileName = "me/kafeitu/activiti/helloworld/sayhelloleave.bpmn";
repositoryService.createDeployment().addClasspathResource(processFileName)
.deploy();
// 验证已部署流程定义
ProcessDefinition processDefinition = repositoryService
.createProcessDefinitionQuery().singleResult();
assertEquals("leavesayhello", processDefinition.getKey());
// 启动流程并返回流程实例
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService
.startProcessInstanceByKey("leavesayhello");
assertNotNull(processInstance);
System.out.println("pid=" + processInstance.getId() + ", pdid="
+ processInstance.getProcessDefinitionId());
}
示例9: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx =
new AnnotationConfigApplicationContext();
ctx.register(SpringAnnotationConfiguration.class);
ctx.refresh();
assertNotNull(ctx.getBean(ProcessEngine.class));
assertNotNull(ctx.getBean(RuntimeService.class));
TaskService bean = ctx.getBean(TaskService.class);
assertNotNull(bean);
assertNotNull(ctx.getBean(HistoryService.class));
assertNotNull(ctx.getBean(RepositoryService.class));
assertNotNull(ctx.getBean(ManagementService.class));
assertNotNull(ctx.getBean(FormService.class));
Task task = bean.newTask();
task.setName("哈哈");
bean.saveTask(task);
}
示例10: testSpringMaster
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
@Test
public void testSpringMaster() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("mule/spring-master/spring-master.xml");
MuleContext mc = (MuleContext) ctx.getBean("_muleContext");
mc.start();
RepositoryService repositoryService = (RepositoryService) ctx.getBean("repositoryService");
repositoryService.createDeployment().addClasspathResource("mule/leaveWithMule.bpmn").deploy();
RuntimeService runtimeService = (RuntimeService) ctx.getBean("runtimeService");
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("days", 5);
runtimeService.startProcessInstanceByKey("leaveWithMule", variableMap);
TaskService taskService = (TaskService) ctx.getBean("taskService");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("部门经理审批", task.getName());
mc.stop();
}
示例11: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines
.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("com/roger/activiti/workflow/CompensationBoundaryEvent.bpmn").deploy();
// 初始化参数
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("result", false);
runtimeService.startProcessInstanceByKey("cbProcess", vars);
}
开发者ID:yudar1024,项目名称:spring4-springmvc4-mybatis3-activiti,代码行数:17,代码来源:CompensationBoundaryEvent.java
示例12: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
// 得到任务服务组件
TaskService taskService = engine.getTaskService();
// 得到管理服务组件
ManagementService managementService = engine.getManagementService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/SignalThrowingEvent.bpmn").deploy();
// 启动流程
runtimeService.startProcessInstanceByKey("stProcess");
// 完成选择商品任务
Task firstTask = taskService.createTaskQuery().singleResult();
taskService.complete(firstTask.getId());
// 完成用户支付任务
Task payTask = taskService.createTaskQuery().singleResult();
taskService.complete(payTask.getId());
// 由于使用了异步的中间Throwing事件,因此会产生2条工作数据
List<Job> jobs = managementService.createJobQuery().list();
System.out.println(jobs.size());
}
示例13: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// 创建流程引擎
ProcessEngineImpl engine = (ProcessEngineImpl)ProcessEngines
.getDefaultProcessEngine();
// 启动JobExecutor
engine.getProcessEngineConfiguration().getJobExecutor().start();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/TimerCatchingEvent.bpmn").deploy();
// 启动流程
runtimeService.startProcessInstanceByKey("tcProcess");
// 查询当前任务
Task currentTask = taskService.createTaskQuery().singleResult();
taskService.complete(currentTask.getId());
Thread.sleep(1000 * 61);
// 重新查询当前任务
currentTask = taskService.createTaskQuery().singleResult();
System.out.println("定时器中间事件的触发后任务:" + currentTask.getName());
//关闭JobExecutor
engine.getProcessEngineConfiguration().getJobExecutor().shutdown();
}
示例14: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/MessageCatchingEvent.bpmn").deploy();
// 启动流程
ProcessInstance pi = runtimeService.startProcessInstanceByKey("mcProcess");
Execution exe = runtimeService.createExecutionQuery().activityId("messageintermediatecatchevent1").singleResult();
runtimeService.messageEventReceived("myMsg", exe.getId());
// 输出当前的任务
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
System.out.println(task.getName());
}
}
示例15: main
import org.activiti.engine.RuntimeService; //导入依赖的package包/类
public static void main(String[] args) {
// 创建流程引擎
ProcessEngine engine = ProcessEngines
.getDefaultProcessEngine();
// 得到流程存储服务组件
RepositoryService repositoryService = engine.getRepositoryService();
// 得到运行时服务组件
RuntimeService runtimeService = engine.getRuntimeService();
// 获取流程任务组件
TaskService taskService = engine.getTaskService();
// 部署流程文件
repositoryService.createDeployment()
.addClasspathResource("bpmn/ErrorBoundaryEvent.bpmn").deploy();
// 启动流程
runtimeService.startProcessInstanceByKey("ebProcess");
// 进行任务查询
Task task = taskService.createTaskQuery().singleResult();
System.out.println(task.getName());
}