views:

35

answers:

1

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.

+3  A: 

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
      ...
}
Chandra Patni