See: Description
Class | Description |
---|---|
ProcessBuilderFactories |
Holds an utility method to retrieve
ProcessBuilderFactory default instance. |
Variable<T> |
Builder pattern like class used to build a variable.
|
Enum | Description |
---|---|
Dialect |
Supported programming languages for action scripts
|
ProcessBuilder
several methods// Obtain default ProcessBuilderFactory ProcessBuilderFactory factory = ProcessBuilderFactories.get(); ProcessBuilderFactory factory = ProcessBuilderFactories.get(); Process process = // Create process builder factory.processBuilder(processId) // package and name .packageName("org.jbpm") .name("My process") // start node .startNode(1).name("Start").done() // Add variable of type string .variable(var("pepe", String.class)) // Add exception handler .exceptionHandler(IllegalArgumentException.class, Dialect.JAVA, "System.out.println(\"Exception\");") // script node in Java language that prints "action" .actionNode(2).name("Action") .action(Dialect.JAVA, "System.out.println(\"Action\");").done() // end node .endNode(3).name("End").done() // connections .connection(1, 2) .connection(2, 3) .build();
ProcessBuilderFactory
)// Build resource from ProcessBuilder KieResources resources = ServiceRegistry.getInstance().get(KieResources.class); Resource res = resources .newByteArrayResource(factory.toBytes(process)) .setSourcePath("/tmp/processFactory.bpmn2"); // source path or target path must be set to be added into kbase
KieServices ks = KieServices.Factory.get(); KieRepository kr = ks.getRepository(); KieFileSystem kfs = ks.newKieFileSystem(); kfs.write(res); KieBuilder kb = ks.newKieBuilder(kfs); kb.buildAll(); // kieModule is automatically deployed to KieRepository if successfully built. KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId()); KieBase kbase = kContainer.getKieBase();
// Create kie session
KieSessionConfiguration conf = ...;
Environment env = ....;
KieSession ksession = kbase.newKieSession(conf,env);
// execute process using same process id that was used to obtain ProcessBuilder
instance
ksession.startProcess(processId);
Copyright © 2001–2021 JBoss by Red Hat. All rights reserved.