3 Replies Latest reply on Mar 5, 2014 2:28 PM by swiderski.maciej

    Can I add new assets (BPMN workflows) to an existing RuntimeManager?

    jkranes

      I am using the session-per-request strategy with a shared RuntimeManager created at application startup.  In this application, users can submit new BPMN workflows at any time for execution.  Is there any way to attach a new workflow asset to an already created RuntimeManager?  Or do I need to dispose the current RuntimeManager and then create a new one that includes the newly added workflow asset?

       

      Thanks,

       

      Jon

        • 1. Re: Can I add new assets (BPMN workflows) to an existing RuntimeManager?
          swiderski.maciej

          It should be possible to alter RuntimeManager kbase via RuntimeEnvironment. You can cast RuntimeManager to InternalRuntimeManager to get hold of RuntimeEnvironment, next get KieBase out of the runtime environment and you should be able to add resources into that KieBase which should be visible to sessions managed by runtime manager.

           

          HTH

          • 2. Re: Can I add new assets (BPMN workflows) to an existing RuntimeManager?
            jkranes

            From KieBase I don't see any methods to add a resource.  However if I cast the RuntimeEnvironment as SimpleRuntimeEnvironment there is an addResource() method.  Does that seem like the right way to do it?

             

            Thanks,

             

            Jon

            • 3. Re: Can I add new assets (BPMN workflows) to an existing RuntimeManager?
              swiderski.maciej

              addResource is use to add them before it is used, so it won't have any impact on already existing kbase. Try following, although keep in mind that this is using impl classes so might be changed in the future.

               

                      RuntimeEnvironment env = ((InternalRuntimeManager) manager).getEnvironment();

                      KieBase base = env.getKieBase();

                     

                      KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

                      kbuilder.add(ResourceFactory.newClassPathResource("BPMN2-CustomTask.bpmn2"), ResourceType.BPMN2);

               

                      ((InternalKnowledgeBase)base).getRuleBase().addPackages(((KnowledgeBuilderImpl)kbuilder).getPackageBuilder().getPackages());

                     

               

              HTH