cancel
Showing results for 
Search instead for 
Did you mean: 

How to resolve variables outside process context

newbbie
Champ in-the-making
Champ in-the-making
I am implementing a "Global Variable" which could be outside the process context and it is not like the process level "global variable" as mentioned in Activiti.

1. I created a resolver api (based on this post http://forums.activiti.org/en/viewtopic.php?f=3&t=268&view=previous), just to resolve the global variables passed through contexts other than "process context", ex. from a UI context. But from bpmn file perspective, I don't see any difference for the resolver to resolve when parsing the global variables vs the local variables? since they are already inside the bpmn file, so they are under the process context, correct? If not, please explain.
2. if they have difference, how can i identify with the resolver (or please suggestions), this variable is global, not local? I am using some naming convention with a prefix "global_"?
3. after i identify that it is a global variable, i was suggested by a coworker, i need to create an interceptor in package org.activiti.engine.impl.persistence.entity.VariableScopeImpl, to check if the variable is global variable, call GlobalVariableResolver in getVariable(), otherwise, no interruption to the method - default to local variable resolver?

Thank for your help in advance.
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
No need to fiddle around with the Variable-scope. Instead, create a custom ExpressionManager (extending the default one) which adds a new ELResolver to the chain. The ELResolver should "kick in" when the "key" of the property starts with "global_".

See http://forums.activiti.org/en/viewtopic.php?f=6&t=4291&p=16719&hilit=expressionManager#p16719 for details

newbbie
Champ in-the-making
Champ in-the-making
Thank you very much for your reply.

I have a custom resolver, which is backed up by a map. The information of this map comes from some persistent source, ex. a database/registry, does it mean, it is the resolver's responsibility to fetch the data from the database, or the custom expression manager? what is the common way to do it?

2nd question: how to test the following case: "passing a JPA object as an input parameter to a java service task"?

Thanks,
newbbie

naag
Champ in-the-making
Champ in-the-making
Hi newbie,

1) Why don't you look at the Activiti sources and see how it's done there? E.g. look at the classes VariableScopeResolver and VariableScopeResolverFactory. You should see that it's the Resolver's responsibility if I'm not mistaken…

2) What exactly do you mean? 😉

Peter

newbbie
Champ in-the-making
Champ in-the-making
Thanks Peter. You are right about the first question. For the second question, I found some tests in the repository, which helped out.

Thanks,
newbbie