当前位置: 首页>>代码示例>>Java>>正文


Java RuntimeService.signalEventReceived方法代码示例

本文整理汇总了Java中org.activiti.engine.RuntimeService.signalEventReceived方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeService.signalEventReceived方法的具体用法?Java RuntimeService.signalEventReceived怎么用?Java RuntimeService.signalEventReceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.RuntimeService的用法示例。


在下文中一共展示了RuntimeService.signalEventReceived方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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());

    }
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:28,代码来源:ProvisionrSupport.java

示例2: 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/SignalCatchingEvent.bpmn").deploy();
	// 启动流程
	runtimeService.startProcessInstanceByKey("scProcess");
	Task firstTask = taskService.createTaskQuery().singleResult();
	taskService.complete(firstTask.getId());
	// 此时会出现并行的两个流程分支,查找用户任务并完成
	Task payTask = taskService.createTaskQuery().singleResult();
	// 完成任务
	taskService.complete(payTask.getId());
	// 发送信号完成支付
	runtimeService.signalEventReceived("finishPay");
	Task finishTask = taskService.createTaskQuery().singleResult();
	System.out.println("当前流程任务:" + finishTask.getName());
}
 
开发者ID:yudar1024,项目名称:spring4-springmvc4-mybatis3-activiti,代码行数:25,代码来源:SignalCatchingEvent.java

示例3: executeExecutionAction

import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@PUT
@Path("/")
public Response executeExecutionAction(ExecutionActionRequest actionRequest) {
    if (!ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
        throw new ActivitiIllegalArgumentException("Illegal action: '" + actionRequest.getAction() +"'.");
    }

    if (actionRequest.getSignalName() == null) {
        throw new ActivitiIllegalArgumentException("Signal name is required.");
    }
    RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();

    if (actionRequest.getVariables() != null) {
        runtimeService.signalEventReceived(actionRequest.getSignalName(), getVariablesToSet(actionRequest));
    } else {
        runtimeService.signalEventReceived(actionRequest.getSignalName());
    }
    return Response.ok().status(Response.Status.NO_CONTENT).build();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:ExecutionService.java

示例4: main

import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
/**
 * @param args
 */
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/SignalBoundaryEvent.bpmn").deploy();
	// 启动2个流程实例
	ProcessInstance pi1 = runtimeService
			.startProcessInstanceByKey("sbProcess");
	ProcessInstance pi2 = runtimeService
			.startProcessInstanceByKey("sbProcess");
	// 查找第一个流程实例中签订合同的任务
	Task pi1Task = taskService.createTaskQuery()
			.processInstanceId(pi1.getId()).singleResult();
	taskService.complete(pi1Task.getId());
	// 查找第二个流程实例中签订合同的任务
	Task pi2Task = taskService.createTaskQuery()
			.processInstanceId(pi2.getId()).singleResult();
	taskService.complete(pi2Task.getId());
	// 此时执行流到达确认合同任务,发送一次信号
	runtimeService.signalEventReceived("contactChangeSignal");
	// 查询全部的任务
	List<Task> tasks = taskService.createTaskQuery().list();
	// 输出结果
	for (Task task : tasks) {
		System.out.println(task.getProcessInstanceId() + "---"
				+ task.getName());
	}
}
 
开发者ID:yudar1024,项目名称:spring4-springmvc4-mybatis3-activiti,代码行数:39,代码来源:SignalBoundaryEvent.java

示例5: performExecutionAction

import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
/**
 * Execute an action on an execution
 * @param executionId
 * @param actionRequest
 * @return Response
 */
@PUT
@Path("/{executionId}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response performExecutionAction(@PathParam("executionId") String executionId, ExecutionActionRequest
        actionRequest) {

    Execution execution = getExecutionFromRequest(executionId);
    RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();

    if (ExecutionActionRequest.ACTION_SIGNAL.equals(actionRequest.getAction())) {
        if (actionRequest.getVariables() != null) {
            runtimeService.signal(execution.getId(), getVariablesToSet(actionRequest));
        } else {
            runtimeService.signal(execution.getId());
        }
    } else if (ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
        if (actionRequest.getSignalName() == null) {
            throw new ActivitiIllegalArgumentException("Signal name is required");
        }
        if (actionRequest.getVariables() != null) {
            runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId(),
                    getVariablesToSet(actionRequest));
        } else {
            runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId());
        }
    } else if (ExecutionActionRequest.ACTION_MESSAGE_EVENT_RECEIVED.equals(actionRequest.getAction())) {
        if (actionRequest.getMessageName() == null) {
            throw new ActivitiIllegalArgumentException("Message name is required");
        }
        if (actionRequest.getVariables() != null) {
            runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId(),
                    getVariablesToSet(actionRequest));
        } else {
            runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId());
        }
    } else {
        throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
    }

    Response.ResponseBuilder response = Response.ok();
    // Re-fetch the execution, could have changed due to action or even completed
    execution = runtimeService.createExecutionQuery().executionId(execution.getId()).singleResult();
    if (execution == null) {
        // Execution is finished, return empty body to inform user
        response.status(Response.Status.NO_CONTENT);
    } else {
        response.entity(new RestResponseFactory()
                .createExecutionResponse(execution, uriInfo.getBaseUri().toString())).build();
    }

    return response.build();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:60,代码来源:ExecutionService.java

示例6: signalEventReceived

import org.activiti.engine.RuntimeService; //导入方法依赖的package包/类
@POST
@Path("/")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response signalEventReceived(SignalEventReceivedRequest signalRequest) {
    RestResponseFactory restResponseFactory = new RestResponseFactory();
    RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();

    if (signalRequest.getSignalName() == null) {
        throw new ActivitiIllegalArgumentException("signalName is required");
    }

    Map<String, Object> signalVariables = null;
    if (signalRequest.getVariables() != null) {
        signalVariables = new HashMap<String, Object>();
        for (RestVariable variable : signalRequest.getVariables()) {
            if (variable.getName() == null) {
                throw new ActivitiIllegalArgumentException("Variable name is required.");
            }
            signalVariables.put(variable.getName(), restResponseFactory.getVariableValue(variable));
        }
    }

    if (signalRequest.isAsync()) {
        if (signalVariables != null) {
            throw new ActivitiIllegalArgumentException("Async signals cannot take variables as payload");
        }
        if (signalRequest.isCustomTenantSet()) {
            runtimeService.signalEventReceivedAsyncWithTenantId(signalRequest.getSignalName(),
                                                                signalRequest.getTenantId());
        } else {
            runtimeService.signalEventReceivedAsync(signalRequest.getSignalName());
        }
        return Response.ok().status(Response.Status.ACCEPTED).build();
    } else {
        if (signalRequest.isCustomTenantSet()) {
            runtimeService.signalEventReceivedWithTenantId(signalRequest.getSignalName(), signalVariables,
                                                           signalRequest.getTenantId());
        } else {
            runtimeService.signalEventReceived(signalRequest.getSignalName(), signalVariables);
        }
        return Response.ok().status(Response.Status.NO_CONTENT).build();
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:45,代码来源:SignalService.java


注:本文中的org.activiti.engine.RuntimeService.signalEventReceived方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。