2

快速查看是否可以在引导程序的 init() 完成后运行一段代码?

最好的方法是什么?

我有一些需要连接的外部系统,我想在这个块完成时显示一个“索引”页面,上面写着“连接到子系统”或类似的东西,然后一旦完成,应用程序就可以正常工作。

我是否认为您在引导之后才能访问页面?有没有一种简单的方法来限制人们在此服务运行时访问系统的其他部分?这看起来可行吗?

为任何帮助干杯!

4

1 回答 1

1

Based on your requirement as you also pointed out bootstrap is not your friend. you need a view and controller for your screen and a service for your connection logic to external systems. You also need a flag or a method for sanity check of the communication within the scope of application or session. Then I would suggest to create a filter and check if you have the connections, if not redirect them to the controller that will connect it. Sudo:

class ConnectionFilters {
def filters = {
    loginCheck(controller: '*', action: '*') {
        before = {
            if (!session.connection ) {
                redirect(controller:'connection',action: 'connect')
                return false
            }
        }
    }
}

}

class controller {
    def connectionService
    def connect (){
        try {
            connectionService.connectTo('systemx')
            connectionService.connectTo('systemy')
            connectionService.connectTo('systemz')
        }
        catch(e){
            session.connection = false
            redirect view:'error'
        }
        session.connection = true
    }
}


class ConnectionService {
    def connectTo(systemname){
        ....
    }
}
于 2013-04-29T12:50:22.290 回答