This content has been marked as final.
Show 2 replies
-
1. Re: Deploy process in runtime
jayzay212 Feb 6, 2015 9:05 AM (in response to mando87)Hey!
I'm running jBPM 6.2 snapshot in an osgi environment and i also would like to know if it's possible to deploy processes in runtime. Hopefully without re-initiating the RuntimeManager.
Regards,
Sebastian Ganser
-
2. Re: Deploy process in runtime
mando87 Feb 9, 2015 4:20 AM (in response to mando87)I found a solution using reflection. We create the RuntimeEnvironmentBuilder, use reflection to get the KnowledgeBuilderImpl and use this object to build and get the Process. After that use the knowledgeBase to deploy de process in runtime.
RuntimeEnvironmentBuilder builder; builder = RuntimeEnvironmentBuilder.Factory.get() .newDefaultBuilder() .entityManagerFactory(emf) .userGroupCallback(new ScaUserGroupCallbackImpl());//my implementation of UserGroupCallback //create RuntimeEngine with builder ... //use reflection to get the kbuilder(KnowledgeBuilderImpl) Field f = null; SimpleRuntimeEnvironment simpleRuntimeEnvironment = (SimpleRuntimeEnvironment) builder.get(); try { f = SimpleRuntimeEnvironment.class.getDeclaredField("kbuilder"); f.setAccessible(true); kbuilder = (KnowledgeBuilderImpl) f.get(simpleRuntimeEnvironment); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } //to deploy in runtime: KnowledgeBaseImpl knowledgeBase = (KnowledgeBaseImpl) ksession.getKieBase(); Resource processResource = ResourceFactory.newClassPathResource("test2.bpmn2"); builder.addAsset(resource, ResourceType.BPMN2); Process process = kbuilder.newKnowledgeBase().getProcess("test2"); knowledgeBase.addProcess(process);