Sharing Entities Between App Engine Modules

I migrate from Eclipse to Android Studio and connect to the App App for Android. I divided the server side into two modules (the default module for endpoints and requests to the user) and the "admin" module for the backend. Now both of these modules should use Entities. (the backend module is usually responsible for storing these objects in the DB, and the default module is the one that returns data back to Android using these Entities).

What is the best way to share these Entity classes between these two modules in Android Studio? (also make sure these classes are extended, etc.). I do not want to have duplicate classes, both in the default module and as an administrator. Maybe there is a common "java" module shared between them (but not sure if class upgrading will work). Or should the admin module NOT use objects and use other storage methods instead?

Appreciate your thoughts.

+4
source share
1 answer

Although there may be reasons not to pass the code, I personally prefer DRY.

I solved the DRY-style problem using Python by placing the model definition file in the dir app/models.yaml and linking it to the symbol in each of the sub-modules of the app/module_blah/models.yaml , so that all the modules look at the same ones same definitions of models. During deployment, symbolic links are automatically replaced by the actual contents of the symbolically linked file. From appcfg.py update :

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

Help may be needed to deploy all the modules.

I used the same technique to also share entire libraries with common code between modules, by referencing the app/lib/libX subdir in the desired app/module_blah/lib/libX as needed.

Not sure if this method can be used in Java, tho.

+3
source

Source: https://habr.com/ru/post/1260906/


All Articles