From 874884c61bb97e96cf8606dd7dc96c32b656d9ad Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 13 Apr 2012 17:05:48 -0400 Subject: [PATCH] Using the public rather than the internal address to trigger tweet storage in Cloud Foundry TweetStore while we figure out if it's possible to use the internal address (see http://support.cloudfoundry.com/requests/102117) --- .../demo/paas/config/PlatformServicesInitializer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java index f034b2a3e4..30403e646c 100644 --- a/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java +++ b/demos/tweetstore/cf-tweetstore-spring/src/main/java/org/jclouds/demo/paas/config/PlatformServicesInitializer.java @@ -19,6 +19,7 @@ package org.jclouds.demo.paas.config; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static com.google.inject.name.Names.bindProperties; import static java.util.concurrent.TimeUnit.SECONDS; @@ -83,8 +84,12 @@ public class PlatformServicesInitializer implements ServletContextListener { protected static String getBaseUrl(ServletContext context) { ApplicationInstanceInfo instanceInfo = new CloudEnvironment().getInstanceInfo(); - return "http://" + checkNotNull(instanceInfo.getHost(), "instanceInfo.getHost()") - + ":" + instanceInfo.getPort() + context.getContextPath(); + // TODO: use internal address if possible. See http://support.cloudfoundry.com/requests/102117 +// return "http://" + checkNotNull(instanceInfo.getHost(), "instanceInfo.getHost()") +// + ":" + instanceInfo.getPort() + context.getContextPath(); + checkState(!instanceInfo.getUris().isEmpty(), "instanceInfo.getUris() is empty"); + return "http://" + checkNotNull(instanceInfo.getUris().get(0), "instanceInfo.getUris().get(0)") + + context.getContextPath(); } // TODO: make the number and names of queues configurable