I'd like to do this in Java Google App Engine
if(developmentMode)
foo();
else
bar();
Does anyone know a good way to do this?
Daniel
I'd like to do this in Java Google App Engine
if(developmentMode)
foo();
else
bar();
Does anyone know a good way to do this?
Daniel
https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/utils/SystemProperty
In Java just test
SystemProperty.environment.value() == SystemProperty.Environment.Value.Production
In Python, check the SERVER_SOFTWARE
environment variable. It'll be "Development/X.Y"
in development mode. In Java, ServletContext.getServerInfo()
.
Take a look at this thread on the GAE/J Group.
Several techniques are listed there. You might also look at this blog entry
It suggests doing: ServletContext.getServerInfo()
"In development this will be 'Google App Engine Development/x.x.x' and in production it will be 'Google App Engine/x.x.x'"
This blog suggests writing a ServletContextListener to sniff this value so you can expose it to classes that don't have access to the ServletContext.