如何在 GWT 中为 AppEngine SystemProperty 继承模块

Posted

技术标签:

【中文标题】如何在 GWT 中为 AppEngine SystemProperty 继承模块【英文标题】:How to inherit module in GWT for AppEngine SystemProperty 【发布时间】:2012-03-12 10:04:26 【问题描述】:

在 GWT 项目的客户端测试开发或生产模式时,如下行:

if (SystemProperty.environment.value() ==
                SystemProperty.Environment.Value.Production)

我收到此错误:

没有可用于类型的源代码 com.google.appengine.api.utils.SystemProperty;你忘了 继承一个必需的模块?

我可以在客户端执行此操作吗?如果是这样,我怎样才能继承正确的模块?

谢谢。

【问题讨论】:

【参考方案1】:

正如 Peter 所说,您将无法直接在 GWT 代码中使用该类。但是,这是使用 this technique 的完美用例。

【讨论】:

【参考方案2】:

不,com.google.appengine.api.utils.SystemProperty 仅在服务器端可用。在客户端,您只能使用 GWT 模块目录中或添加到源路径中的类:http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules

【讨论】:

以上是关于如何在 GWT 中为 AppEngine SystemProperty 继承模块的主要内容,如果未能解决你的问题,请参考以下文章