Grails Server准备就绪后如何执行服务

时间:2010-02-24 03:25:40

标签: grails web-services client

我有一个Grails应用程序,它为自己提供虚拟Web服务。在现实世界中,它可以在另一台机器上调用webservices,但在开发和测试期间,我们需要能够访问内部Web服务来填充表。在引导期间无法完成此操作,因为内部Web服务器尚未启动(Grails最后执行此操作)。

因此,我需要能够检测到Grails已启动Web服务器,然后运行服务以从内部Web服务填充表。

我似乎没有在googleland找到任何似乎有帮助的内容......

1 个答案:

答案 0 :(得分:1)

我想到的一件事是使用石英作业(使用quartz plugin),您可以将作业调度为一次性事件,并且从服务器完成开始到服务器完成时只需短暂延迟当它实际执行时。

class LoadDataJob {
   static triggers = {
       simple name: 'triggerName', startDelay: 5000   // wait for 5 seconds to run the job
   }

   def execute(){ /* loading code here */ } 
}