public class EnvironmentContextListener implements ServletContextListener {
private static Log log = LogFactory.getLog(EnvironmentContextListener.class);
public void contextInitialized(ServletContextEvent sce) {
CloudEnvironment environment = new CloudEnvironment();
if (environment.getInstanceInfo() != null) {
log.info("VCAP_SERVICES: " + environment.getServices());
System.setProperty("PROFILE", "cloud");
} else {
System.setProperty("PROFILE", "default");
}
try {
if (!CollectionUtils.isEmpty(environment.getServiceInfos(RedisServiceInfo.class))) {
log.info("Redis service detected");
System.setProperty("REDIS", "true");
}
}
catch (Exception e) {