6 Replies Latest reply on Nov 10, 2009 10:25 AM by Santanu Saraswati

    [jBPM 4.1] Process Definition XML File

    Mike Burton Newbie

      Hi
      How do we create process definition XML file programtically without using designer tool? is there any API available in jBPM 4.1?
      I am new to jBPM and learning it.

      Please guid me.
      Thanks for your valuable reply..

        • 1. Re: [jBPM 4.1] Process Definition XML File
          Sebastian Schneider Master

          I just saw the jPDL doc is not up to date for jBPM 4.x but it should work in a similar way as described for 3.2:

          http://docs.jboss.com/jbpm/v3.2/javadoc-jpdl/

          ProcessDefinition processDefinition = new ProcessDefinition("processname");
          ..
          


          Just have a look at the jPDL source code to see what constructors and methods are available for ProcessDefinition.

          • 2. Re: [jBPM 4.1] Process Definition XML File
            Santanu Saraswati Novice

            Is it really possible with Jbpm 4.x?

            I thought one of the major differences between 3.x and 4.x is that, at the time of deployment in 3.x it used to decompose the xml and create a tree of persistent objects. Then it used to save all those objects, starting from ProcessDefinition object. So there was an options to skip the xml and directly create the ProcessDefinition object, set the nodes etc and then save the objects.

            But in 4.x Jbpm keeps the xml itself, and does not try to decompose it proactively. So we need the xml to be there to deploy the flow.

            I did not notice and xml writing API in Jbpm. None of the sub-classes of ProcessDefinition seem to have the methods like 3.x to add StartNode, Node etc. So I thought API for creating process definition is not there.

            • 3. Re: [jBPM 4.1] Process Definition XML File
              Sebastian Schneider Master

              Most probably you're right, saraswati.santanu. I was in the strong belief it would still be possible although jBPM stores the XML-string in the database. I haven't checked the sources like you have done. So thanks for getting this right. Maybe a solution for Mike is to use some XML lib to create a XML definition and then deploy an XML string.

              question to the dev's:
              Are there reasons speaking against shipping such an API with jBPM or is this just a feature which could be implemented but has not been implemented?

              • 4. Re: [jBPM 4.1] Process Definition XML File
                Koen Aers Master

                Sebastian,

                As you might know the API has been severely limited wrt jBPM 3 to enhance the supportability. I am not sure as to how much it would impact supportability if the API would be extended so that dynamically creating processes would be possible. In any case, it is possible to create the processes dynamically using the implementation classes. Then you can write a little tool to serialize the model to xml and deploy it as you suggest.
                If it is needed in a way that can be supported, I am sure it needs thorough discussion first.

                Cheers,
                Koen

                • 5. Re: [jBPM 4.1] Process Definition XML File
                  Mike Burton Newbie

                  Hi

                  Thanks to all of you for your valuable responses.

                  you are absolutely right saraswati.santanu. There is no API to create the process definition xml programatically. I checked out the source and did not find any way to create programatically.

                  If this can be included in jBPM4.x as a feature, it would be very helpful to programmers to generate xml dynamically at run time.

                  • 6. Re: [jBPM 4.1] Process Definition XML File
                    Santanu Saraswati Novice

                    Koen,

                    My two cents. All that people might need is a nice wrapper over a DOM API which makes Jpdl xml writing using Java code simpler. This may not really require to touch any of the core classes for this. For e.g. I can write something like:

                    //this is the step where we generate the xml dynamically
                    JpdlWriter writer = new JpdlWriter();
                    String xmlString = writer.startNode("Start Node Name")
                     .transition("Transition Name", "Next Task")
                     .task("Next Task")
                     ... etc.
                     .xml();
                    
                    //this is deployment, which is the same even for a static xml, read from a file
                    String deploymentId = repositoryService.createDeployment()
                     .addResourceFromString(resourceName, xmlString)
                     .deploy();
                    

                    I would assume the JpdlWriter class and any other associated classes will not do anything with the real process definition object. However code above is just a random thought to elaborate the idea.

                    I believe something like this Sebastian suggested and you also mentioned.