This content has been marked as final.
Show 4 replies
-
1. Re: programmatic passing of environment objects
heiko.braun Mar 17, 2009 5:50 AM (in response to tom.baeyens)Callbacks would be another possibility. Clients would need to provide an implementation of that callback interface:
TaskService getTaskService(CallbackInterface callback);
So, instead of 'pushing' the information into the service, the service would 'callbacl' the client environment when needed. -
2. Re: programmatic passing of environment objects
tom.baeyens Mar 17, 2009 5:56 AM (in response to tom.baeyens)maybe this is better:
TaskService taskService = processEngine.getTaskService(); try { Authentication authentication = new UserProvidedAuthentication("johndoe"); taskService.setEnvironmentObject(authentication); taskService.take(taskdbid); } finally { taskService.removeEnvironmentObjects(); }
or by nameTaskService taskService = processEngine.getTaskService(); Authentication authentication = new UserProvidedAuthentication("johndoe"); taskService.setEnvironmentObject("authentication", authentication); taskService.take(taskdbid);
-
3. Re: programmatic passing of environment objects
heiko.braun Mar 17, 2009 6:05 AM (in response to tom.baeyens)You can skip the 'finally' when using the callback because it's managed outside of the task service:
[...] finally { taskService.removeEnvironmentObjects(); }
Same applies to the lookup key. Using a callback would force the task service to engage the lookup with it's key and not the client environment.taskService.setEnvironmentObject("authentication", authentication);
-
4. Re: programmatic passing of environment objects
tom.baeyens Mar 17, 2009 6:17 AM (in response to tom.baeyens)"heiko.braun@jboss.com" wrote:
You can skip the 'finally' when using the callback because it's managed outside of the task service:
i don't think so. if the services remain process-engine-context scoped objects, then the callback object would have to be removed just like the provided objects themselves... i think.
internally we only have 1 option:
use a thread local to pass these objects down till the environment is created. in that case the services can remain process-engine-context scoped. if we use thread locals to pass the user provided objects or the callback handlers, that thread local cleanup is also needed for callback handlers.
another alternative would be to create a new service object for each request. but then we would not be able to configure the services. users will not be able to configure customized services. maybe that is an other option to consider. but i don't yet see the full implications of that. feels scary to go that route