-
1. Re: Using Process variables as parameters for method calls
sebastian.s Oct 8, 2009 1:19 AM (in response to sebastian.s)Anybody?
-
2. Re: Using Process variables as parameters for method calls
kukeltje Oct 8, 2009 4:57 PM (in response to sebastian.s)sorry, no (not yet). As announced I have way less time since 01-10-09 and have not had the opportunity to look into it. It is on my list for the weekend. (pinging me around that time might help though ;-))
-
3. Re: Using Process variables as parameters for method calls
sebastian.s Oct 9, 2009 1:17 AM (in response to sebastian.s)Thanks for the update, Ronald. I was already afraid one could not understand my post. It is too kind of you that it is on your list for the week end.
-
4. Re: Using Process variables as parameters for method calls
sebastian.s Oct 10, 2009 8:52 AM (in response to sebastian.s)*ping kukeltje*
-
5. Re: Using Process variables as parameters for method calls
kukeltje Oct 10, 2009 10:14 AM (in response to sebastian.s)*ping kukeltje*
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=1 ttl=116 time=1h20m10s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=2 ttl=116 time=1h20m11s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=3 ttl=116 time=1h20m12s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=4 ttl=116 time=1h20m13s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=5 ttl=116 time=1h20m14s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=6 ttl=116 time=1h20m15s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=7 ttl=116 time=1h20m16s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=8 ttl=116 time=1h20m17s
64 bytes from kukeltje.lombox.customer.bit.nl (87.251.48.65): icmp_seq=9 ttl=116 time=1h20m18s"sebastian.s" wrote:
I was reading the section about java activities and process variables in the userguide and wondering about some things.
In a java or a custom activity I could useObject getVariable(String key);
to retrieve the values of process variables and then I could go use them as arguments for method calls.
First of all I'm not sure you can get to the executioncontext in the java task. You can in the custom tastk/node"sebastian.s" wrote:
But that means that if I changed the names of the process variables I would need to change the implementation of the java or custom activity, too. So wouldn't it be more convient to be able to specifiy process variables in the process definition which would be passed as arguments? So in case the process variable names changed just the process definition would need need changes but the java class wouldn't need to be touched?
I was also wondering why you can specify the method name for a java activity in the GPD but not the number of arguments.
For the java task you can pass arguments and use expressions for the value of the arguments. These can afaik be process variable names as well, so that solves one problem. The varying number of arguments is afaik dealt with by jBPM since it uses reflection to find the correct method signature. Not 100% completely sure though.
What you can also to in the java task is set member fields, put a list, xml document or whatever in there from the processdefinition and parse/use that in your java class. It's kind of what you mentioned in the dev forum when we talked about schema extensions.
http://docs.jboss.com/jbpm/v4/userguide/html_single/#java
I was under the impression that something like the field thing for java tasks was possible as well for custom nodes, but that might be something left in my brain from jBPM 3 (or it might just be wishful thinking) as I do not seem to be able to find anything."sebastian.s" wrote:
If I got it wrong I'd be happy for some clarifying words. If not this seems to turn out to be a discussion for the dev forum, right?
Regarding passing params to the custom node, yes. -
6. Re: Using Process variables as parameters for method calls
sebastian.s Oct 26, 2009 8:23 AM (in response to sebastian.s)Hello again!
From the documentation about java activities:<process name="Java" xmlns="http://jbpm.org/4.0/jpdl"> <start > <transition to="greet" /> </start> <java name="greet" class="org.jbpm.examples.java.JohnDoe" method="hello" var="answer" > <field name="state"><string value="fine"/></field> <arg><string value="Hi, how are you?"/></arg> <transition to="shake hand" /> </java> <java name="shake hand" expr="#{hand}" method="shake" var="hand" > <arg><object expr="#{joesmoe.handshakes.force}"/></arg> <arg><object expr="#{joesmoe.handshakes.duration}"/></arg> <transition to="wait" /> </java> <state name="wait" /> </process>
For the java task you can pass arguments and use expressions for the value of the arguments. These can afaik be process variable names as well, so that solves one problem. The varying number of arguments is afaik dealt with by jBPM since it uses reflection to find the correct method signature. Not 100% completely sure though.
How exactly can I address process instance variables to use them as arguments for method calls? -
7. Re: Using Process variables as parameters for method calls
kukeltje Oct 26, 2009 2:36 PM (in response to sebastian.s)If you take a look at the java example in the examples folder in the source, you can see that 'joesmoe' is the name of the variable. handshakes is a getter for a map which in turn contains force and duration as integers. So if you have a plain string as a variable, just use the name in the EL.
-
8. Re: Using Process variables as parameters for method calls
sebastian.s Oct 27, 2009 2:55 AM (in response to sebastian.s)Thanks, Ronald. It was somehow too obvious.
-
9. Re: Using Process variables as parameters for method calls
sebastian.s Nov 2, 2009 2:49 AM (in response to sebastian.s)I am using
<arg><object expr="#{attendeeId}"/></arg>
attendeeId is process variable of type String.Caused by: java.lang.Exception: couldn't create argument 0: script evaluation er ror: javax.el.PropertyNotFoundException: Cannot find property attendeeId at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.getArgs(Object Descriptor.java:348) at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.jav a:79)
Is the expression correct? -
10. Re: Using Process variables as parameters for method calls
jbarrez Nov 2, 2009 12:32 PM (in response to sebastian.s)The expressions looks correct. I'm using a similar one in my train ticket demo:
https://anonsvn.jboss.org/repos/jbpm/projects/demos/trainticket-demo/jbpm-on-rails/trunk/process-logic/src/main/resources/org/jbpm/trainticketdemo/process.jpdl.xml<string value="#{from}"/>
Where from is a process var. -
11. Re: Using Process variables as parameters for method calls
kukeltje Nov 2, 2009 12:40 PM (in response to sebastian.s)the difference being object vs string in the jpdl
-
12. Re: Using Process variables as parameters for method calls
jbarrez Nov 2, 2009 2:04 PM (in response to sebastian.s)Right ... too much forum posts make your head fuzzy (or at least, my head ;-)
Anyway, it should work with 'object' too, as far as I'm concerned.
@Sebastian: you have a test case I can play with? -
13. Re: Using Process variables as parameters for method calls
sebastian.s Nov 2, 2009 4:56 PM (in response to sebastian.s)Thanks for your efforts. Today my head was a bit fuzzy after almost 12 hours. I quickly posted because I did not expect such quick answers to my posts. Everyting works fine for me with:
<object expr="#{variableName}"/>
However I didn't know you should or could use when using expressions.
So thanks again. Next time I'll try to lose my fuzzy head before posting. :D -
14. Re: Using Process variables as parameters for method calls
jbarrez Nov 3, 2009 3:55 AM (in response to sebastian.s)@Sebastian: Tom ran into a similar issue this morning: https://jira.jboss.org/jira/browse/JBPM-2622. Does the issue fit with your original problem?