Why are you doing that? the main idea of using work items is that you can copy information from the process scope to the work item scope using parameter mappings. If you define what pieces of information you will need inside the work item handler you can do the mappings and the engine will copy those values for you. You don't need to have the session to retrieve the process variables.
Take a look at the examples here: https://github.com/Salaboy/Drools_jBPM5-Training-Examples
inside the jBPM5 directory for more information.
Look at the processes definition to see how to move information from the process scope to the workitem scope.
Thanks for your reply. I'll give more info behind what I am trying to do. I have an object model which looks something like this:
Set<ClassB> data --> ClassB String name, String value
In my flow we create Class A and a collection of ClassB but in the process variable we store the reference as opposed to the serialised version of ClassA (there is already persistence behind ClassA).
I now have a domain specific work item handler which is registered in eclipse and has a set of properties which a user can define. These properties can be statically defined or they can use an expression based approach for example
Name: ClassA(variableName defined in flow).elementName + ':' + ClassA(variableName defined in flow).reference
The idea is then to load ClassA id via variableName and then get the value of elementName and reference which are stored in ClassA object model. I have a small ANTLR program that parses the string and then looks up the data. The ANTLR parser uses session.getProcessInstance(..) to load the relevant data and I was hoping to load the process and get the value out, although it probably is possible to pass the work item parameter mapping to my parser.
Hope this made sense!
I think that you can pass the StatefulKnowledgeSession to a constructor of your custom WorkItemHandler and then in executeWorkItem(WorkItem i,WorkItemManager m) method calls:
Hope this is helpful.
Your procedure looks so complicated to me. You should use the Variable Persisntece Strategies to handle such situations. Are your expessions propietary? Do you need to do that kind of resolutions in runtime? or you can solve the same things with the current methods?
If you create a variable persistence strategy for handling your classes that are being persisted externally, you shouldn't use the process instance ID to restore the information. You should use your own/external persisters (the one that handles the Class A and B) to restore the information about those classes using the ID that you pass to the work item handler.
Wow...completely forgot about this post. I have handled this differently and so longer an issue.
Can you share ur approach????????????