3 Replies Latest reply on Jul 6, 2010 2:26 AM by swiderski.maciej

    Calling a Spring bean inside the JPDL

    soheildowlatshahi

      I want to access to the JBPM spring context inside a JPDL. My main target is to provide some java web service proxies which let me to call the web services inside the jbpm but on the same time I need to have a registery of web service providers (containg the name of them as well of the endpoint URL of each of them) because I don't want change and reload the process definitions (JPDLs) each time that the location of web services are changed.

      So I need to provide some java code calling (by means of java tag in jpdl) that let me to access the spring context which contains a registery of web services (like UDDI)

      Inside the JPDL I want to specify only a key or ID of my target Web Service. the java code will use it to find the web service and call it.

       

      I use JBPM 4.3, Spring 2.5.6 , AXIS on a tomcat server.

        • 1. Re: Calling a Spring bean inside the JPDL
          walterjs

          This is straighforward to do. Just use an expression like this:

           

          #{myService.callOperation('key')}

           

          As long as there is a bean in the spring context called "myService", this should work. If you want the 'key' to be a bean value as well, just drop the quotes.

           

          Cheers

          Walter

          • 2. Re: Calling a Spring bean inside the JPDL
            soheildowlatshahi

            Please give me an example

             

            where can I use these term #{myService.callOperation('key')}, in java tag? in custom tag?

            • 3. Re: Calling a Spring bean inside the JPDL
              swiderski.maciej

              You have two options if it comes to java activity:

              1. provide on runtime an instance which shall be used to invoke defined method

               

                <java name="shake hand" expr="#{hand}" method="shake" var="hand">
                  <transition to="wait" />
                </java>
              

              this will result in following code being executed: #{hand.shake()}

               

              2. provide a class and method to be invoked that accepts argument given on runtime

               

                <java name="shake \class="my.class.name" hand" method="shake" var="hand">   
                  <arg><object expr="#{hand}"/></arg>
                  <transition to="wait" />
                </java>
              

              this will result in execution of my.class.name.shake(MyObject hand).

               

              For more details about java activity plase take a look at user guide.

               

              HTH