Hi Amin,
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.
Greetings.