在 App Engine 模块之间共享实体 [英] Sharing entities between App Engine modules

查看:21
本文介绍了在 App Engine 模块之间共享实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Eclipse 迁移到 Android Studio,并且有一个 Android 应用程序连接到 AppEngine.我已将服务器端分为两个模块(端点和面向用户的请求的默认模块)和后端内容的管理"模块.现在这两个模块都需要使用实体.(后端模块通常负责将这些实体保存到数据库中,而前端默认模块是使用这些实体将数据返回给 Android 的模块).

I am migrating from Eclipse to Android Studio and have a Android App connected to AppEngine. I have split the Server side into two modules (default module for Endpoints and user facing requests) and "admin" module for backend stuff. Now both these modules need to use the Entities. (backend module usually is responsible for saving these entities to DB, while the frontend default module is the one who returns data back to Android using these Entities).

在 Android Studio 中的这两个模块之间共享这些实体类的最佳方式是什么?(还要确保这些类得到增强等).我不希望在默认模块和管理中都有重复的类.也许在两者之间共享一个通用的java"模块(但不确定类增强是否有效).或者管理模块不应该使用实体而是使用其他持久化方式?

What is the best way to share these Entity classes between these two modules in Android Studio? (also making sure these classes get enhanced etc). I do not wish to have duplicate classes, both in the default module as well as admin. Maybe have a common "java" module shared between the two (but not sure class enhancing would work). Or should the admin module NOT use the Entities and instead use other ways of persistence?

欣赏你的想法.

推荐答案

虽然不共享代码可能有原因,但我个人更喜欢 DRY.

While there may be reasons for not sharing the code, personally I prefer DRY.

我通过将模型定义文件放在应用程序目录 app/models.yaml 中并将其符号链接到每个模块子目录 app/module_blah/models.yaml,从而确保所有模块看到相同的模型定义.在部署时,符号链接会自动替换为被符号链接的文件的实际内容.来自 appcfg.py 更新:

I solved the issue in DRY spirit with the Python backend by placing the models definition file in the app dir app/models.yaml and sym-linking it into each of the modules subdirs app/module_blah/models.yaml, thus ensuring all modules see the same models definitions. At deployment time the symlinks are automatically replaced with the actual content of the file being symlinked. From appcfg.py update:

该命令遵循符号链接并递归地将所有文件上传到服务器.临时或源控制文件,例如 foo~, .svn/* 是跳过.

The command follows symlinks and recursively uploads all files to the server. Temporary or source control files, such as foo~, .svn/* are skipped.

可能需要小心同时部署所有模块.

Care may be needed to deploy all modules at the same time.

我使用了相同的技术,通过将 app/lib/libX 子目录符号链接到所需的 app/module_blah/lib/libX 根据需要.

I used the same technique to also share entire libraries with common code across modules, by symlinking app/lib/libX subdirs into the desired app/module_blah/lib/libX as needed.

不确定此技术是否可用于 Java,不过.

Not sure if this technique is usable in Java, tho.

这篇关于在 App Engine 模块之间共享实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆