Since Grails is based on Spring, we can resort to ApplicationContext. Now the problem is how to get the ApplicationContext instance. After reading "%GRAILS_HOME%/scripts/Console.groovy", you can find a bind-variable named "ctx", which points to the ApplcationContext Object. So, we can use it to get the dependent object used by the script in the console. Here is an example:
def executionService= ctx.getBean('executionService')
def processInstances= executionService.createProcessInstanceQuery().processDefinitionId('StateSequence-1').list()
def executions = processInstances.collect{
def activeNames= it.findActiveActivityNames()
}
No comments:
Post a Comment