Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine AppEngine for Java environment programmatically

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.

like image 432
sam2themax Avatar asked Jan 02 '10 23:01

sam2themax


1 Answers

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
      ...
}
like image 72
Chandra Patni Avatar answered Oct 16 '22 07:10

Chandra Patni