David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler

    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 224 other subscribers
  • Sleepless Nights…

    February 2010
    S M T W T F S
  • Blog Stats

    • 1,040,366 hits

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: