How to distinguish between AppEngine dev and prod environments
Posted by David Chandler on February 27, 2010
How can you tell whether your server-side AppEngine code is running in dev or production? (Hopefully, you don’t need to know too often, but for purposes of substituting test email addresses, etc., it might come in handy). I’ve discovered this AppEngine system property tucked away in Vince Bonfanti’s Task Queue helper class Deferred.java:
import com.google.appengine.api.utils.SystemProperty; ... private static boolean isDevelopment() { return ( SystemProperty.environment.value() == SystemProperty.Environment.Value.Development ); }
If you need to distinguish between AppEngine environments in GWT code, you would have to make an RPC call, which would probably leave you with an if statement in your application code somewhere, although someone very clever might come up with a way to do something GWT-side similar to what Andy Stevko wrote up on StackOverflow a few weeks ago.
If you’ve done something like this in GWT or GIN, I’m all ears.
Leave a Reply