简体   繁体   English

如何在现有Java应用程序中添加Python模块

[英]How to add Python module in existing Java Application

I have a GAE Java app already deployed which is using Datastore. 我已经部署了使用数据存储区的GAE Java应用程序。 Now, I need to split that app in modules and have second module which is written in Python to access that same Datastore. 现在,我需要将该应用程序拆分为模块,并具有用Python编写的第二个模块,以访问同一数据存储区。 I cannot find useful info on how to split app in modules in a way that: 我找不到有关如何以以下方式在模块中拆分应用程序的有用信息:

  • it supports Java in first module and Python in second module 它在第一个模块中支持Java,在第二个模块中支持Python
  • both modules can access same Datastore (I guess this implies since both are part of same GAE application) 两个模块都可以访问相同的数据存储区(我想这暗示着,因为它们都是同一GAE应用程序的一部分)

Main question would be: what are steps to do define these two modules with different programming languages. 主要问题将是:使用不同的编程语言来定义这两个模块的步骤是什么?

Thanks in advance. 提前致谢。

You can use app.yaml to configure your main (Java) module, as detailed at https://cloud.google.com/appengine/docs/java/configyaml/appconfig_yaml , and separate .yaml files to configure your other (Python, PHP, and/or Go -- or also, some of them could also be Java!-)) modules, as detailed at https://cloud.google.com/appengine/docs/python/modules/#Python_Configuration . 您可以使用app.yaml来配置您的主要(Java)模块,如https://cloud.google.com/appengine/docs/java/configyaml/appconfig_yaml中所述 ,并可以使用单独的.yaml文件来配置其他模块(Python, PHP和/或Go-或,其中一些也可能是Java!-))模块,如https://cloud.google.com/appengine/docs/python/modules/#Python_Configuration所述

As you suspect, all modules always do access exactly the same instance of the datastore. 您可能会怀疑,所有模块始终确实访问数据存储区的完全相同的实例。

So for example you could have in app.yaml ...: 因此,例如,您可以在app.yaml ...:

application: myapp
version: alpha-001
runtime: java
api_version: 1

handlers:
- url: /myjava/*
  servlet: myapp.myservlets.DoItAllServlet

to map all urls /myjava/something to that single servlet, and in eg mypython.yaml 将所有URL /myjava/something映射到单个servlet,例如在mypython.yaml

application: myapp
module: mypython
version: v1
runtime: python27

handlers:
- url: /mypy/*
  script: mypython.app

to map all URLs /mypy/something to the single WSGI application bound to global variable app in module mypython.py . 将所有URL /mypy/something映射到模块mypython.py绑定到全局变量app的单个WSGI应用程序。 Of course, there are huge numbers of degrees of freedom on both the main ("default") module, and the other ones, I'm just trying to show the very simplest "skeleton" here!-) 当然,在主模块(“默认”)和其他模块上都有大量的自由度,我只是在这里展示最简单的“骨架”!-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Play Framework - 如何在现有应用程序中添加模块 - Play Framework - How to add a module in existing application 如何将现有的Java Maven模块添加到Grails Maven模块? - How to add existing java Maven modules to Grails Maven module? 如何在Eclipse中的现有Java项目中添加Web项目模块 - How to add web project module in existing java project in eclipse IntelliJ 如何将模块添加到现有模块 - IntelliJ how to add module to existing module 如何将现有的实体对象、视图对象和应用程序模块添加到 Fusion Web 应用程序中? (JDev 12.2.1 和 JSF 2.2) - How to add existing Entity Object, View Objects, and Application Module into a Fusion Web Application? (JDev 12.2.1 and JSF 2.2) 为现有Java应用程序添加JMXMP侦听器 - Add JMXMP listener for an existing Java application 如何在旧版Java应用程序中用基于Griffon的模块替换现有的Swing UI模块? - How to replace existing Swing UI module with Griffon based one in a legacy Java application? 如何将 Intellij 14 中的模块添加到现有项目 - How to add module in Intellij 14 to existing project 如何在现有Java应用程序中实现模块化? - How to do modularity in the existing Java application? 如何将现有Java项目添加到Git存储库 - How to add an Existing Java Project to Git repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM