You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by wo...@apache.org on 2011/08/18 18:01:31 UTC

svn commit: r1159290 - in /shindig/trunk: config/ java/common/src/main/java/org/apache/shindig/common/servlet/ java/gadgets/src/main/java/org/apache/shindig/gadgets/render/

Author: woodser
Date: Thu Aug 18 16:01:30 2011
New Revision: 1159290

URL: http://svn.apache.org/viewvc?rev=1159290&view=rev
Log:
Li Xu's patch to enable https support for osapi endpoints: https://reviews.apache.org/r/1578/

Modified:
    shindig/trunk/config/container.js
    shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/Authority.java
    shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/BasicAuthority.java
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java

Modified: shindig/trunk/config/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/config/container.js?rev=1159290&r1=1159289&r2=1159290&view=diff
==============================================================================
--- shindig/trunk/config/container.js (original)
+++ shindig/trunk/config/container.js Thu Aug 18 16:01:30 2011
@@ -285,7 +285,7 @@
   },
   "osapi" : {
     // The endpoints to query for available JSONRPC/REST services
-    "endPoints" : [ "http://%host%${CONTEXT_ROOT}/rpc" ]
+    "endPoints" : [ "//%host%${CONTEXT_ROOT}/rpc" ]
   },
   "osml": {
     // OSML library resource.  Can be set to null or the empty string to disable OSML

Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/Authority.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/Authority.java?rev=1159290&r1=1159289&r2=1159290&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/Authority.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/Authority.java Thu Aug 18 16:01:30 2011
@@ -35,4 +35,10 @@ public interface Authority {
    * @return the scheme and authority part of the hierarchical URI
    */
   public String getOrigin();
+  
+  /**
+   * The scheme part of the hierarchical URI. Eg "http://localhost:8080"
+   * @return the scheme a of the hierarchical URI
+   */
+  public String getScheme();
 }

Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/BasicAuthority.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/BasicAuthority.java?rev=1159290&r1=1159289&r2=1159290&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/BasicAuthority.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/BasicAuthority.java Thu Aug 18 16:01:30 2011
@@ -59,9 +59,13 @@ public class BasicAuthority implements A
         Objects.firstNonNull(port, getServerPort()));
   }
 
-  public String getOrigin(){
+  public String getScheme(){
     return Objects.firstNonNull(ServletRequestContext.getScheme(), "http");
   }
+  
+  public String getOrigin(){
+	return getScheme() + "://" + getAuthority();
+  }
 
   private String getServerPort() {
     return Objects.firstNonNull(ServletRequestContext.getPort(),

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java?rev=1159290&r1=1159289&r2=1159290&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java Thu Aug 18 16:01:30 2011
@@ -26,6 +26,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.shindig.common.logging.i18n.MessageKeys;
+import org.apache.shindig.common.servlet.Authority;
 import org.apache.shindig.common.uri.Uri;
 import org.apache.shindig.config.ContainerConfig;
 import org.apache.shindig.gadgets.GadgetException;
@@ -42,6 +43,8 @@ import com.google.common.collect.Immutab
 import com.google.common.collect.LinkedHashMultimap;
 import com.google.common.collect.Multimap;
 import com.google.inject.Inject;
+import com.google.inject.Provider;
+
 
 /**
  * Retrieves the rpc services for a container by fetching them from the container's
@@ -69,6 +72,8 @@ public class DefaultServiceFetcher {
   private final ContainerConfig containerConfig;
 
   private final HttpFetcher fetcher;
+  
+  private Provider<Authority> hostProvider;
 
   /** @param config Container Config for looking up endpoints */
   @Inject
@@ -76,6 +81,11 @@ public class DefaultServiceFetcher {
     this.containerConfig = config;
     this.fetcher = fetcher;
   }
+  
+  @Inject(optional = true)
+  public void setHostProvider( Provider<Authority> hostProvider) {
+    this.hostProvider = hostProvider;
+  }
 
   /**
    * Returns the services, keyed by endpoint for the given container.
@@ -104,7 +114,11 @@ public class DefaultServiceFetcher {
     // Merge services lazily loaded from the endpoints if any
     List<String> endpoints = getEndpointsFromContainerConfig(container, host);
     for (String endpoint : endpoints) {
-      endpointServices.putAll(endpoint, retrieveServices(endpoint.replace("%host%", host)));
+      String endpointVal = endpoint;	
+      if ( endpoint.startsWith("//") && hostProvider != null ){
+    	endpointVal = hostProvider.get().getScheme() + ":" + endpoint;
+      }
+      endpointServices.putAll(endpoint, retrieveServices(endpointVal.replace("%host%", host)));
     }
     
     return ImmutableMultimap.copyOf(endpointServices);