5 Replies Latest reply on Dec 3, 2007 8:51 AM by Olivier Thierry

    Dynamic creation of JBPM processes

    Olivier Thierry Apprentice


      I need to start a JBPM process, but in some cases I can't use the @CreateProcess annotation since the process I need to start depends on an runtime value. I also need to outject variables to the business process. But I can't find how to do this ...

      What I did :

      - I injected businessProcess component in my class :

      @org.jboss.seam.annotations.In(create = true)
      protected org.jboss.seam.bpm.BusinessProcess businessProcess;

      - I used @Out annotation to outject the variables in my business process :

      @org.jboss.seam.annotations.Out(required = false, scope = org.jboss.seam.ScopeType.BUSINESS_PROCESS)
      protected java.lang.Long idDemandeAbsence;
      @org.jboss.seam.annotations.Out(required = false, scope = org.jboss.seam.ScopeType.BUSINESS_PROCESS)
      protected java.lang.String codeMotifAbsence;

      - Then I set these variables and call BusinessProcess.createProcess method :

      protected void handleValider() throws java.lang.Exception {
       this.idDemandeAbsence = this.demandeAbsence.getId();
       this.codeMotifAbsence = this.ligneDemandeAbsence.getMotif();

      It looks like the business process starts, but the outjection of variables in the business process does not seem to work ... What I understand is that the outjection is made by Seam after the handleValider() method is called. But the business process starts on the createProcess() method call, so it looks obvious that variables have not been injected yet ...

      Any idea how I should do this ?