本文整理匯總了Java中org.kie.api.runtime.KieSession.halt方法的典型用法代碼示例。如果您正苦於以下問題:Java KieSession.halt方法的具體用法?Java KieSession.halt怎麽用?Java KieSession.halt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kie.api.runtime.KieSession
的用法示例。
在下文中一共展示了KieSession.halt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCallService
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void testCallService() throws Exception {
final Holder holder = new Holder();
serviceDomain.registerService(new QName("CallService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
holder.setValue("message handled");
}
});
serviceDomain.registerServiceReference(new QName("CallService"), new InOnlyService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(CALL_SERVICE_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
ksession.startProcess("CallService");
ksession.halt();
ksession.dispose();
Assert.assertEquals("message handled", holder.getValue());
}
示例2: runFaultBoundaryProcess
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
private void runFaultBoundaryProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_BOUNDARY_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultBoundaryProcess");
String output = (String)wpi.getVariable("TestOutput");
Assert.assertEquals(bomb ? "Failure" : "Success", output);
ksession.halt();
ksession.dispose();
}
示例3: runFaultResultProcess
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
private void runFaultResultProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_RESULT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultResultProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultResult");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}
示例4: runFaultEventProcess
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
private void runFaultEventProcess(final boolean bomb) throws Exception {
serviceDomain.registerService(new QName("TestService"), new InOnlyService(), new BaseHandler(){
public void handleMessage(Exchange exchange) throws HandlerException {
if (bomb) {
throw new HandlerException("BOOM!");
}
}
});
serviceDomain.registerServiceReference(new QName("TestService"), new InOutService());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(FAULT_EVENT_PROCESS_BPMN), ResourceType.BPMN2);
KieBase kbase = kbuilder.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
SwitchYardServiceTaskHandler ssth = new SwitchYardServiceTaskHandler();
ssth.setProcessRuntime(ksession);
ssth.setInvoker(new SwitchYardServiceInvoker(serviceDomain));
ksession.getWorkItemManager().registerWorkItemHandler(SWITCHYARD_SERVICE_TASK, ssth);
WorkflowProcessInstance wpi = (WorkflowProcessInstance)ksession.startProcess("FaultEventProcess");
HandlerException he = (HandlerException)wpi.getVariable("faultEvent");
if (bomb) {
Assert.assertNotNull(he);
Assert.assertEquals("BOOM!", he.getMessage());
} else {
Assert.assertNull(he);
}
ksession.halt();
ksession.dispose();
}