gpt4 book ai didi

grails - 如何实现 "remote"域?

转载 作者:行者123 更新时间:2023-12-03 23:46:29 26 4
gpt4 key购买 nike

想象两个共享一个域类的 Grails 应用程序。也许是 Book 域类。

一个应用程序被标识为数据的所有者,一个应用程序必须访问域数据。类似于亚马逊和亚马逊网络服务。

我想拥有的应用程序将使用普通的域类并通过 Web 服务公开数据是微不足道的 - 在 grails 中没有问题。

但是在其他应用程序中实现域的最佳实践是什么?

  • 使用服务访问远程域而不实现本地域类?
  • 实现本地域类,覆盖 get() 方法以获取远程数据并使用本地数据库作为缓存?
  • 你想到了什么其他解决方案?
  • 最佳答案

    Ryan Geyer有一篇很有趣的文章Modularizing your Grails application domain classes其中列出了此问题的 3 个解决方案:

  • 作为 RESTful JSON 服务 - 很容易在 Grails 中获得此设置,但随后您将失去自动 GORM 功能。
  • 将域类分离到一个库 JAR 文件中 并在我的其他两个应用程序中引用该库。这并不像听起来那么容易
  • 创建一个 Grails 插件。 将域对象放入插件中。然后,您的每个应用程序都可以导入此插件。然后,您可以根据需要创建具有不同功能的不同 Controller 。此示例代码可在以下位置获得:git clone git://ec2.nslms.com/grails/blog_example_modular

  • Ted Naleid 稍后在 post 中给出了一个很好的提示并推荐...

    "create a grails-app/conf/BuildConfig.groovy file and put the plugin name and path to the source in it. ... If you do this, your applications will see the live changes to your domain/controller/service/etc classes as if they were actually in current app and there isn't any need to repackage and reinstall the plugin when you make changes."


    Using memcache应该使两个应用程序都具有一致的数据 View ,并避免每个单独的应用程序拥有自己不一致的缓存。

    关于grails - 如何实现 "remote"域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10614058/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com