将 DAO 和网关放入 Application.cfc 时有任何问题吗?
将多次调用但只需要实例化一次的 DAO 和网关放在应用程序范围内是否可以?
谢谢
Is it ok to put DAOs and Gateways that will be called many times but only need to be instantiated once in the Application scope?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,绝对是。
另一种选择是使用 IOC 框架,例如 ColdSpring 或其他一些 bean 工厂。然后,bean 工厂可以存储在应用程序范围中并实例化 onApplicationStart()(有效地实现相同的目标,但可能具有更多控制)。
Yes, absolutely.
Another option is to use an IOC framework such as ColdSpring or some other bean factory. The bean factory can then be stored in the application scope and instantiated onApplicationStart() (effectively achieving the same thing but possibly with more control).
这是放置它们的完美位置;-)。
将它们作为 application.myDAO = xxxx & 添加到 onApplicationStart() 中application.myGateway = xxxx 就可以了!
That's the perfect place to put them ;-).
Add them into onApplicationStart() as application.myDAO = xxxx & application.myGateway = xxxx and you're good to go!