Skip to content

Instantly share code, notes, and snippets.

@igm
Created July 15, 2011 08:25
Show Gist options
  • Save igm/1084315 to your computer and use it in GitHub Desktop.
Save igm/1084315 to your computer and use it in GitHub Desktop.
package foo.bar;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
public class MyContextInitializer implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
private static final String PROP = "com.google.appengine.runtime.environment";
public void initialize(ConfigurableApplicationContext applicationContext) {
ConfigurableEnvironment springEnvironment = applicationContext.getEnvironment();
String appengine_property = System.getProperty(PROP);
if ("Production".equals(appengine_property))
springEnvironment.setActiveProfiles("production");
else
springEnvironment.setActiveProfiles("local");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment