I have a modeling problem, I need to reuse a Java Service Task twice (or more) in the same process, passing him some "parameters" that alter slightly the behaviour.
Basically I will receive a signal from the outside that will tell a process instance that an event has happened (basically a file received event). The process will wait for more than one file over the process life, but the external system that receives files doesn't know which file will be picked up by which task so it just sends a "file received" event with the name of the file received. The process may be waiting for more than one file and all the File Received task will be woken up by the signal and will go back in the signal wait if the file is not the one they're expecting.
Besides, I'd like to use spring beans as tasks as they can integrate nicely with @Autowired dependencies from my spring environment.
So far I used a delegate expression when defining task (like ${fileLoaderTask}) and I have a @Component FileLoaderTask class that gets picked up by Spring component scanner and used by Activity.
Point is that I used an Expression fields in FileLoaderTask to indicate to the task which file that task will have to check for. Problem is that expression are set at task creation and task gets resued, so the value that the Expression will return in every path of the process will be the same and will be the last one set by the Engine. This of course screws up my process flow (as all those tasks will basically be the same).
Any suggestion about how to model this behaviour?
Only thing that comes to mind is if Activity can create those tasks instances via a Spring Factory bean so that instances will be different (and with different instance variables) specifying ${taskBeanFactory.createTask('file_1')}, ${taskBeanFactory.createTask('file_2')}, … instead of simply using ${fileLoaderTask}. That way seems working.