Grails Invoke a controller method from a scheduled job -
in grails application i'd invoke scheduled job class method contained in controller.
reading [http://www.grails.org/job+scheduling+(quartz)], can see datasources , services auto-wired name in job classes. seems not possible controllers default, 'cause controllers aren't supposed kind of stuff.
btw, there way controller method called job in grails? , such bad practice (and why)?
thanks in advance, luca
it's bad practice because controller intended handle web requests - user session , everything.
there no user session in quartz job.
second, keeping functionality in controller bad thing on own - controller should better "control" invocations other business logic method.
i'd recommend move functionality either service, domain class or pogo class in src
.
of course, can call new mycontroller().method()
, no beans injected controller default.
Comments
Post a Comment