4 Replies Latest reply on Feb 16, 2006 7:54 PM by fwshk

    How to retrieve information from jBPM (Different VM)

    fwshk

      Hi all,

      My configuration:
      jbpm-starters-kit-3.1
      Windows XP

      How to retrieve information from jBPM (Different VM)
      Would you like to tell me if there is any available API?

      Also, I would like to know if I used MySQL as jBPM's database, will the jBPM fail of some features?

      Last question, what is the reason of the below code always return same output?

      public static final String CONFIG_FILE = "jbpm.cfg.xml";
      public static final String ACTOR_ID = "ernie";
      public static final String PAR_RESOURCE = "simple.par";
      
      public static void main(String[] args) {
       // Configure jBPM by passing configure file's resource path
       JbpmConfiguration lJbpmConfiguration = JbpmConfiguration.getInstance(CONFIG_FILE);
       // Create database schema into database
       // Comment the create schema will throw exception >.<
       lJbpmConfiguration.createSchema();
       // Start jBPM server
       JbpmContext lJbpmContext = lJbpmConfiguration.createJbpmContext();
       try {
       // Deploy process
       lJbpmContext.deployProcessDefinition(ProcessDefinition.parseParResource(PAR_RESOURCE));
       // Login user
       lJbpmContext.setActorId(ACTOR_ID);
       // Retrieve task list
       List lTaskList = lJbpmContext.getTaskList();
       System.out.println("Task: " + lTaskList.size());
       for (int i = 0; i < lTaskList.size(); i++) {
       Task lTask = (Task) lTaskList.get(i);
       System.out.println("- " + lTask.getName());
       }
       // Retrieve process list
       List lProcessList = lJbpmContext.getGraphSession().findAllProcessDefinitions();
       System.out.println("Process: " + lProcessList.size());
       for (int i = 0; i < lProcessList.size(); i++) {
       ProcessDefinition lProcessDefinition = (ProcessDefinition) lProcessList.get(i);
       System.out.println("- " + lProcessDefinition.getName());
       // Retrieve process version list
       List lVersionList = lJbpmContext.getGraphSession().findAllProcessDefinitionVersions(
       lProcessDefinition.getName());
       System.out.println("> Version: " + lVersionList.size());
       for (int j = 0; j < lVersionList.size(); j++) {
       System.out.println("-- " + lVersionList.get(j));
       }
       }
       } finally {
       lJbpmContext.close();
       }
      }
      


      The output
      Task: 0
      Process: 1
      - simple
      > Version: 1
      -- ProcessDefinition(simple)
      


      Any reply are welcome and thank you very much.
      Roy

        • 1. Re: How to retrieve information from jBPM (Different VM)
          ralfoeldi

          Hi Roy,

          ALL information is in the database. If you need jBPM in a JVM start jBPM in that JVM and access it. Or am I missing something?

          jBPM is database agnostic. Whatever Hibernate can or cannot do applies to jBPM as well.

          What sort of output are you expecting? (You are(?) expecting something else or else you wouldn't ask.)

          Greetings

          • 2. Re: How to retrieve information from jBPM (Different VM)
            fwshk

            Hi RAlfoeldi,

            Thank you very much for your reply.

            I have started a jBPM in jBoss and would like to use the program to retrieve the information. Therefore, the output show that my program is started another jBPM.

            What I going to do is to build an application similar to the webapp of jBPM.
            Is that query database is the only way of retrieving jBPM's information?

            The below graphic is my expected architecture of jBPM and I am asking for the [API]
            | --- --- Client Side --- -- | --- --- --- --- --- Server Side --- --- --- --- --- |
            [Java Application] <-> [API] <-> [jBPM] <-> [Hibernate] <-> [Database]

            Would you tell me if [Java Application] and [jBPM] must within same JVM?
            If I want [Java Application] and [jBPM] in different JVM, do I need to create the [API] my own?
            | --- --- Client Side --- --- | --- --- --- --- --- Server Side --- --- --- --- --- |
            [Java Application] <-> [My API] <-> [My API App] <-> [API] <-> [jBPM] ...

            Thank you very much again and looking forward for any reply.
            Roy

            • 3. Re: How to retrieve information from jBPM (Different VM)
              ralfoeldi

              Hi Roy,

              are you asking for a remote interface to jBPM in the sense of a stateless / statefull session bean?

              I think that's on the todo list of the jBPM Team, but hasn't been implemented yet. Right now you would have to roll your own for that. It wouldn't be totally trivial as you will run into problems with Hibenate (detached objects etc.) but it's been done :-)

              Does this answer your question?

              Greetings

              • 4. Re: How to retrieve information from jBPM (Different VM)
                fwshk

                Hi RAlfoeldi,

                Thank you very much and I got the answer of my question.

                Roy