本文整理匯總了Java中org.kie.api.runtime.KieSession.startProcess方法的典型用法代碼示例。如果您正苦於以下問題:Java KieSession.startProcess方法的具體用法?Java KieSession.startProcess怎麽用?Java KieSession.startProcess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kie.api.runtime.KieSession
的用法示例。
在下文中一共展示了KieSession.startProcess方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void doTest() {
try {
KieBase kbase = getKieBase(URL, USER, PASSWORD);
RuntimeManager manager = getRuntimeManager(kbase);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
ksession.startProcess("test.proc_ht");
// "sales-rep" reviews request
TaskService taskService = runtime.getTaskService();
long taskId = taskService.getTasksAssignedAsPotentialOwner(TASK_USER, "en-UK").get(0).getId();
taskService.claim(taskId, TASK_USER);
taskService.start(taskId, TASK_USER);
taskService.complete(taskId, TASK_USER, null);
System.out.println("Process instance completed");
manager.disposeRuntimeEngine(runtime);
} catch (Throwable t) {
t.printStackTrace();
}
System.exit(0);
}
示例2: populateSamples
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
public void populateSamples(int numTask, int numProcessVars, String processId) {
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession kieSession = runtimeEngine.getKieSession();
Map<String, Object> processVariables;
// Name, age, email, income, amount, period.
for (int i = 0; i < numTask; i++) {
// 1 2 3
processVariables = getProcessArgs(numProcessVars);
kieSession.startProcess(processId, processVariables);
}
// getTasks();
}
示例3: 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();
}
示例4: 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());
}
示例5: doTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void doTest() {
try {
RuntimeManager manager = getRuntimeManager("org/jugvale/bpms/local/processes/humantask/HumanTask.bpmn");
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
ksession.startProcess("test.proc_ht");
// "sales-rep" reviews request
TaskService taskService = runtime.getTaskService();
long taskId = taskService.getTasksAssignedAsPotentialOwner(USER, "en-UK").get(0).getId();
taskService.claim(taskId, USER);
taskService.start(taskId, USER);
taskService.complete(taskId, USER, null);
System.out.println("Process instance completed");
manager.disposeRuntimeEngine(runtime);
} catch (Throwable t) {
t.printStackTrace();
}
System.exit(0);
}
示例6: doTestResources
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
private Throwable doTestResources(String xml) {
try {
ClassLoader loader = getClass().getClassLoader();
SwitchYardModel switchyardModel = _puller.pull(xml, loader);
BPMComponentImplementationModel implementationModel = (BPMComponentImplementationModel)switchyardModel.getComposite().getComponents().get(0).getImplementation();
ServiceDomain serviceDomain = new ServiceDomainManager().createDomain();
QName serviceName = new QName("test");
KnowledgeRuntimeManagerFactory runtimeManagerFactory = new KnowledgeRuntimeManagerFactory(loader, serviceDomain, serviceName, implementationModel);
KnowledgeRuntimeManager runtimeManager = runtimeManagerFactory.newRuntimeManager(KnowledgeRuntimeManagerType.SINGLETON);
RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine();
KieSession session = runtimeEngine.getKieSession();
session.startProcess("TestProcess");
runtimeManager.disposeRuntimeEngine(runtimeEngine);
runtimeManager.close();
return null;
} catch (Throwable t) {
return t;
}
}
示例7: doTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Override
@Test
public void doTest() throws Exception {
List<Status> status = Arrays.asList(Status.Ready);
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
// you could also use getTasksAssignedAsPotentialOwner(user, lang)
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwnerByStatus(USER, status, "en-UK");
cleanTasks(taskService, tasks);
for (int i = 0; i < TOTAL_PROCESSES; i++) {
ksession.startProcess(PROCESS_WITH_TASK_ASSIGNED_TO_A_GROUP);
}
tasks = taskService.getTasksAssignedAsPotentialOwnerByStatus(USER, status, "en-UK");
assertEquals(TOTAL_PROCESSES, tasks.size());
cleanTasks(taskService, tasks);
}
示例8: main
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
RuntimeManager manager = Util.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
KieSession kSession = engine.getKieSession();
for (int i = 0; i < 50000; i++) {
System.out.println("Starting process number " + i);
kSession.startProcess("org.fxapps.bpms.helloProcess");
}
manager.disposeRuntimeEngine(engine);
manager.close();
}
示例9: doTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void doTest() throws IOException {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
UrlResource urlResource = (UrlResource) ks.getResources().newUrlResource(URL);
urlResource.setUsername(USER);
urlResource.setPassword(PASSWORD);
urlResource.setBasicAuthentication("enabled");
InputStream is = urlResource.getInputStream();
KieModule kModule = kr.addKieModule(ks.getResources().newInputStreamResource(is));
KieContainer kc = ks.newKieContainer(kModule.getReleaseId());
KieSession kSession = kc.newKieSession();
kSession.startProcess("project1.hello");
}
示例10: doTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void doTest() {
logger.info("Testing simple process without persistence");
KieContainer kc = KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.getKieBase("TestProcessKB").newKieSession();
ksession.startProcess("HelloWorldProcess");
ksession.dispose();
}
示例11: 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();
}
示例12: main
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
public static void main(String[] args) throws InterruptedException {
// no delay to call the executor and not using JMS
System.setProperty("org.kie.executor.jms", "false");
System.setProperty("org.kie.executor.initial.delay", "1");
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
// This entity manager factory contains Executor entities
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.with.executor");
ExecutorService executorService = ExecutorServiceFactory.newExecutorService();
// initialize the executor service - it is important or it won't work
executorService.init();
RuntimeEnvironment env = RuntimeEnvironmentBuilder.Factory
.get()
.newEmptyBuilder()
// remember to register the executor service
.addEnvironmentEntry("ExecutorService", executorService)
.entityManagerFactory(emf)
.addAsset(
KieServices.Factory.get().getResources()
.newClassPathResource("org.jbpm.async_test.v1.0.bpmn2"),
ResourceType.BPMN2).get();
RuntimeManager runtimeManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(env);
RuntimeEngine engine = runtimeManager.getRuntimeEngine(EmptyContext.get());
KieSession kieSession = engine.getKieSession();
// registering the WIH for the Service task
kieSession.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
kieSession.startProcess("test.async_test");
runtimeManager.disposeRuntimeEngine(engine);
}
示例13: main
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
RuntimeManager manager = Util.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
KieSession kSession = engine.getKieSession();
for (int i = 0; i < 100; i++) {
System.out.println("Starting process number " + i);
kSession.startProcess("org.fxapps.bpms.helloProcess");
}
manager.disposeRuntimeEngine(engine);
manager.close();
}
示例14: execute
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Override
void execute(KieSession kieSession, TaskService taskService, JBPMConfiguration configuration, Exchange exchange) {
ProcessInstance processInstance = kieSession.startProcess(getProcessId(configuration, exchange), getParameters(configuration, exchange));
setResult(exchange, processInstance);
}
示例15: start
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void start() {
KieSession kieSession = engine.getKieSession();
ProcessInstance pi = kieSession.startProcess(PROCESS_ID);
System.out.println("Process Started! Instance ID: " + pi.getId());
}