以编程方式确定Java环境的AppEngine [英] Determine AppEngine for Java environment programmatically
本文介绍了以编程方式确定Java环境的AppEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在运行时以编程方式告诉Google App Engine应用程序是在本地运行还是在运行?我正在寻找一种方法来在本地开发环境中运行时调用一些自定义存根代码,并在运行托管时进行不同调用。
您可以使用 < AppEngine 1.3中的code> com.google.appengine.api.utils.SystemProperty 。
import com.google.appengine.api.utils.SystemProperty;
import static com.google.appengine.api.utils.SystemProperty.environment;
import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Development;
import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Production;
SystemProperty.Environment.Value env = environment.value();
if(env == Production){
// prod only code
...
} else if(env == Development){
// dev only代码
...
}
Is there a way to tell programmatically at run-time whether a Google App Engine application is running locally vs. hosted? I'm looking for a way to call some custom stub code when running in a local development environment and make different calls when running hosted.
解决方案
You can use com.google.appengine.api.utils.SystemProperty
in AppEngine 1.3.
import com.google.appengine.api.utils.SystemProperty;
import static com.google.appengine.api.utils.SystemProperty.environment;
import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Development;
import static com.google.appengine.api.utils.SystemProperty.Environment.Value.Production;
SystemProperty.Environment.Value env = environment.value();
if (env == Production) {
//prod only code
...
} else if(env == Development) {
//dev only code
...
}
这篇关于以编程方式确定Java环境的AppEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文