Grails(18)Grails with Plugin - Executor

Grails(18)GrailswithPlugin-Executor

Installation

Thewaytoinstalltheplugin

>grailsinstall-pluginexecutor

Usage

runAsyncclosure

TakesanyclosureandpassesitthroughtotheexecutorService.execute

callAsyncIamnotusingthis.

ExamplesofUsage

Services

classSomeService{

defmyMethod(){

…previoussteps

runAsync{

calculate()

}

…dosomethingelse...

}

defcalculate(){

…snip...

}

}

Domain

classBook{

defmyNotifyService

Stringname

defafterInsert(){

runAsync{

myNotifyService.informLibraryOfCongress(this)

}

}

}

References:

http://grails.org/plugin/executor

https://github.com/basejump/grails-executor

http://nitoprograms.blogspot.com/2012/02/async-unit-tests-part-1-wrong-way.html

http://nitoprograms.blogspot.com/2012/02/async-unit-tests-part-2-right-way.html

相关推荐