本文整理匯總了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());
}
}
示例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());
}
示例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();
}
示例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());
}
}
示例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();
}
示例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();
}
}