Author: ivol37 at gmail.com
Date: Tue Jan  4 17:36:28 2011
New Revision: 558

Log:
[AMDATU-239] Fixed support for using relative URLs in the gadget registration. 
Refactored all gadgets to start using relative URLs. Gadget registration 
services that were managed services before have been refactored and 
significantly simplified as no hostname or portnr configuration is necessary 
anymore. 

Removed:
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.authorization.login.gadget.cfg
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.authorization.useradmin.gadget.cfg
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.example.coursegadget.cfg
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.example.friendsgadget.cfg
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.example.oauth.cfg
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.semanticweb.sparqlendpoint.cfg
Modified:
   
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/osgi/Activator.java
   
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
   
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
   
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/osgi/Activator.java
   
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/service/UserAdminGadgetImpl.java
   
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
   
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
   
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin_rest.js
   
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/osgi/Activator.java
   
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
   trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
   
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
   
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friends/gadget/osgi/Activator.java
   
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
   
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
   trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
   
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/gadgets_appdata.js
   
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
   
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraAppDataServiceStore.java
   
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraOAuthStore.java
   
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/Activator.java
   
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
   
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp

Modified: 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/osgi/Activator.java
     (original)
+++ 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/osgi/Activator.java
     Tue Jan  4 17:36:28 2011
@@ -46,8 +46,7 @@
             
.add(createServiceDependency().setService(UserAdmin.class).setRequired(true))
             
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
             
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-            
.add(createServiceDependency().setService(LoginService.class).setRequired(true))
-            .add(createConfigurationDependency().setPid(LoginGadgetImpl.PID)));
+            
.add(createServiceDependency().setService(LoginService.class).setRequired(true)));
     }
 
     @Override

Modified: 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
==============================================================================
--- 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
    (original)
+++ 
trunk/amdatu-authorization/login-gadget/src/main/java/org/amdatu/authorization/login/gadget/service/LoginGadgetImpl.java
    Tue Jan  4 17:36:28 2011
@@ -28,19 +28,13 @@
 import org.apache.felix.dm.Component;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
  * This service provides the login gadget.
  * @author ivol
  */
-public class LoginGadgetImpl implements ResourceProvider, ManagedService {
-    // The PID and configuration properties
-    public final static String PID = "org.amdatu.authorization.login.gadget";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-
+public class LoginGadgetImpl implements ResourceProvider {
     // Service dependencies, injected by the Felix dependency manager
     private volatile LogService m_logService;
     private volatile BundleContext m_bundleContext;
@@ -50,10 +44,6 @@
     // The private HTTP context service for this bundle
     private Component m_httpContextComponent;
 
-    // Configruation entries
-    private volatile String m_hostname;
-    private volatile String m_portnr;
-
     /**
      * The init() method is invoked by the Felix dependency manager.
      */
@@ -61,23 +51,14 @@
         // Create our own http context service which registers static 
resources and JSPs automatically
         m_httpContextComponent = 
m_httpContextServiceFactory.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // FIXME: Because of a bug in the Felix dependency manager, 
update() is not invoked when the bundle
-            // is stopped/started. Hence m_hostname and m_portnr will be null. 
To prevent serious problems as
-            // described in issue 
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
-            // For the bug description, see 
http://jira.amdatu.org/jira/browse/AMDATU-174 
-            // and https://issues.apache.org/jira/browse/FELIX-2696
-        } else {
-            // Register the gadget with the Gadget management service. Note 
that we can do this as
-            // many times as we want, since the gadget URL is the unique 
identifier
-            String gadgetSpecUrl =
-                "http://"; + m_hostname + ":" + m_portnr + "/" + 
Activator.RESOURCE_ID + "/jsp/LoginGadget.jsp";
-            GadgetDefinition gadgetDef = new GadgetDefinition(gadgetSpecUrl, 
GadgetCategory.AMDATU_PLATFORM, true);
-            gadgetDef.setRank(0);
-            m_gadgetManagement.addGadget(gadgetDef);
-            m_logService.log(LogService.LOG_INFO, "Login gadget registered on 
URL '" + gadgetSpecUrl + "'");
-        }
-        
+        // Register the gadget with the Gadget management service. Note that 
we can do this as
+        // many times as we want, since the gadget URL is the unique identifier
+        String gadgetSpecUrl = "/" + Activator.RESOURCE_ID + 
"/jsp/LoginGadget.jsp";
+        GadgetDefinition gadgetDef = new GadgetDefinition(gadgetSpecUrl, 
GadgetCategory.AMDATU_PLATFORM, true);
+        gadgetDef.setRank(0);
+        m_gadgetManagement.addGadget(gadgetDef);
+        m_logService.log(LogService.LOG_INFO, "Login gadget registered on URL 
'" + gadgetSpecUrl + "'");
+
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
started");
     }
 
@@ -95,14 +76,6 @@
         return Activator.RESOURCE_ID;
     }
 
-    @SuppressWarnings("unchecked")
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] { HOSTNAME, PORTNR });
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
 
     @SuppressWarnings("unchecked")
     private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {

Modified: 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp
==============================================================================
--- 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp  
    (original)
+++ 
trunk/amdatu-authorization/login-gadget/src/main/resources/jsp/LoginGadget.jsp  
    Tue Jan  4 17:36:28 2011
@@ -1,9 +1,8 @@
 <%@ page language="java" session="false" buffer="none" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
 
-<c:set var="baseUrl" 
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="baseRestUrl" value="${baseUrl}/rest/authorization"/>
-<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/login"/>
+<c:set var="baseRestUrl" value="/rest/authorization"/>
+<c:set var="gadgetBaseUrl" value="/gadget/login"/>
 
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
@@ -31,7 +30,7 @@
     description="Provides login/logout functionality for Amdatu users"
     author="Ivo Ladage-van Doorn"
     screenshot="${gadgetBaseUrl}/static/images/login.png"
-    icon="${gadgetBaseUrl}/static/images/login.png"
+    icon="/static/images/login.png"
     height="400">
     <Require feature="osapi"/>
     <Require feature="dynamic-height"/>

Modified: 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/osgi/Activator.java
     (original)
+++ 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/osgi/Activator.java
     Tue Jan  4 17:36:28 2011
@@ -42,8 +42,7 @@
             .setImplementation(UserAdminGadgetImpl.class)
             
.add(createServiceDependency().setService(LogService.class).setRequired(true))
             
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
-            
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-            
.add(createConfigurationDependency().setPid(UserAdminGadgetImpl.PID)));
+            
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true)));
     }
 
     @Override

Modified: 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/service/UserAdminGadgetImpl.java
==============================================================================
--- 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/service/UserAdminGadgetImpl.java
        (original)
+++ 
trunk/amdatu-authorization/useradmin-gadget/src/main/java/org/amdatu/authorization/useradmin/gadget/service/UserAdminGadgetImpl.java
        Tue Jan  4 17:36:28 2011
@@ -17,7 +17,6 @@
 package org.amdatu.authorization.useradmin.gadget.service;
 
 import java.net.URL;
-import java.util.Dictionary;
 
 import org.amdatu.authorization.useradmin.gadget.osgi.Activator;
 import org.amdatu.opensocial.gadgetmanagement.GadgetManagement;
@@ -27,20 +26,13 @@
 import org.amdatu.web.httpcontext.ResourceProvider;
 import org.apache.felix.dm.Component;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
  * This service provides the UserAdmin gadget.
  * @author ivol
  */
-public class UserAdminGadgetImpl implements ResourceProvider, ManagedService {
-    // The PID and configuration properties
-    public final static String PID = 
"org.amdatu.authorization.useradmin.gadget";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-
+public class UserAdminGadgetImpl implements ResourceProvider {
     // Service dependencies, injected by the Felix dependency manager
     private volatile LogService m_logService;
     private volatile BundleContext m_bundleContext;
@@ -50,10 +42,6 @@
     // The private HTTP context service for this bundle
     private Component m_httpContextComponent;
 
-    // Configruation entries
-    private volatile String m_hostname;
-    private volatile String m_portnr;
-
     /**
      * The init() method is invoked by the Felix dependency manager.
      */
@@ -61,22 +49,13 @@
         // Create our own http context service which registers static 
resources and JSPs automatically
         m_httpContextComponent = 
m_httpContextServiceFactory.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // FIXME: Because of a bug in the Felix dependency manager, 
update() is not invoked when the bundle
-            // is stopped/started. Hence m_hostname and m_portnr will be null. 
To prevent serious problems as
-            // described in issue 
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
-            // For the bug description, see 
http://jira.amdatu.org/jira/browse/AMDATU-174
-            // and https://issues.apache.org/jira/browse/FELIX-2696
-        } else {
-            // Register the gadget with the Gadget management service. Note 
that we can do this as
-            // many times as we want, since the gadget URL is the unique 
identifier
-            String gadgetSpecUrl =
-                "http://"; + m_hostname + ":" + m_portnr + "/" + 
Activator.RESOURCE_ID + "/jsp/UserAdminGadget.jsp";
-            GadgetDefinition gadgetDef = new GadgetDefinition(gadgetSpecUrl, 
GadgetCategory.AMDATU_PLATFORM, false);
-            gadgetDef.setRank(0);
-            m_gadgetManagement.addGadget(gadgetDef);
-            m_logService.log(LogService.LOG_INFO, "Login gadget registered on 
URL '" + gadgetSpecUrl + "'");
-        }
+        // Register the gadget with the Gadget management service. Note that 
we can do this as
+        // many times as we want, since the gadget URL is the unique identifier
+        String gadgetSpecUrl = "/" + Activator.RESOURCE_ID + 
"/jsp/UserAdminGadget.jsp";
+        GadgetDefinition gadgetDef = new GadgetDefinition(gadgetSpecUrl, 
GadgetCategory.AMDATU_PLATFORM, false);
+        gadgetDef.setRank(0);
+        m_gadgetManagement.addGadget(gadgetDef);
+        m_logService.log(LogService.LOG_INFO, "Login gadget registered on URL 
'" + gadgetSpecUrl + "'");
 
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
started");
     }
@@ -94,22 +73,4 @@
     public String getResourceId() {
         return Activator.RESOURCE_ID;
     }
-
-    @SuppressWarnings("unchecked")
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] { HOSTNAME, PORTNR });
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {
-        for (String mandatoryKey : mandatoryKeys) {
-            if (dictionary.get(mandatoryKey) == null) {
-                throw new ConfigurationException("Missing configuration key", 
mandatoryKey);
-            }
-        }
-    }
 }

Modified: 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
==============================================================================
--- 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
      (original)
+++ 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/jsp/UserAdminGadget.jsp
      Tue Jan  4 17:36:28 2011
@@ -1,13 +1,12 @@
 <%@ page language="java" session="false" buffer="none" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
 
-<c:set var="baseUrl" 
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="restUrl" value="${baseUrl}/rest"/>
+<c:set var="restUrl" value="/rest"/>
 
-<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/useradmin"/>
-<c:set var="imgBaseUrl" value="${baseUrl}/gadget/useradmin/static/images" />
-<c:set var="jsBaseUrl" value="${baseUrl}/gadget/useradmin/static/js" />
-<c:set var="cssBaseUrl" value="${baseUrl}/gadget/useradmin/static/css" />
+<c:set var="gadgetBaseUrl" value="/gadget/useradmin"/>
+<c:set var="imgBaseUrl" value="/gadget/useradmin/static/images" />
+<c:set var="jsBaseUrl" value="/gadget/useradmin/static/js" />
+<c:set var="cssBaseUrl" value="/gadget/useradmin/static/css" />
 
 <?xml version="1.0" encoding="UTF-8" ?>
 <Module>
@@ -94,7 +93,6 @@
     </p>
 
     <script type="text/javascript">
-      var baseUrl ="${baseUrl}";
       var restUrl = "${restUrl}";
       var imgBaseUrl = "${imgBaseUrl}";
     </script>

Modified: 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
==============================================================================
--- 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
       (original)
+++ 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin.js
       Tue Jan  4 17:36:28 2011
@@ -26,7 +26,7 @@
       } else if (links[i]["rel"] == "End") {
          var end = getNavigationLink("end.gif", links[i]["href"], 
"onRolesLoaded");
       } else if (links[i]["rel"] == "Alternate") {
-         currentUrl = baseUrl + links[i]["href"];
+         currentUrl = links[i]["href"];
          if (currentView == "user") {
           currentUsersUrl = currentUrl;
          } else {
@@ -223,7 +223,7 @@
 function confirmDeleteMember(role) {
   var removeFromRole = encodeURIComponent(selectedRole);
   var removeRole = encodeURIComponent(unescape(role));
-  var url = baseUrl + "/rest/groups/" + removeFromRole + "/members/" + 
removeRole;
+  var url = "/rest/groups/" + removeFromRole + "/members/" + removeRole;
   deleteMember(url, onMemberRemoved);
 }
 
@@ -231,7 +231,7 @@
   var addToRole = encodeURIComponent(selectedRole);
   var addRole = encodeURIComponent(unescape(role));
   if (addToBasicMembers) {
-    var url = baseUrl + "/rest/groups/" + addToRole + "/basicmembers/" + 
addRole;
+    var url = "/rest/groups/" + addToRole + "/basicmembers/" + addRole;
   } else {
     // Sanity check: if you add a required member to Administrators, only this 
role has permission
     // for user amdin!
@@ -242,7 +242,7 @@
         return;
       }
     }
-    var url = baseUrl + "/rest/groups/" + addToRole + "/requiredmembers/" + 
addRole;
+    var url = "/rest/groups/" + addToRole + "/requiredmembers/" + addRole;
   }
   addMember(url, onMemberAdded);
 }
@@ -253,7 +253,7 @@
 
   if (currentView == "user") {
     var newpassword = document.getElementById('password').value
-    var url = baseUrl + "/rest/users/" + name;
+    var url = "/rest/users/" + name;
     if (method == "update") {
       url += "/credentials/password";
       updatePassword(url, onPasswordChanged, newpassword);
@@ -261,7 +261,7 @@
       addRole(url, onRoleAdded);
     }
   } else {
-    var url = baseUrl + "/rest/groups/" + name;
+    var url = "/rest/groups/" + name;
     addRole(url, onRoleAdded);
   }
 }
@@ -277,12 +277,12 @@
 }
 
 function getNavigationLink(image, href, callback) {
-  var result = "<a href='#'><img src='" + imgBaseUrl + "/" + image + "' 
onClick='javascript:loadRoles(\"" + baseUrl + href + "\", " + callback + 
")'/></a>";
+  var result = "<a href='#'><img src='" + imgBaseUrl + "/" + image + "' 
onClick='javascript:loadRoles(\"" + href + "\", " + callback + ")'/></a>";
   return result;
 }
 
 function editRole(link) {
-  loadRole(escape(baseUrl + unescape(link)), onRoleLoaded);
+  loadRole(escape(unescape(link)), onRoleLoaded);
   showEditRole();
 }
 
@@ -290,7 +290,7 @@
   var confirmMsg = prefs.getMsg('confirm_delete');
   confirmMsg = confirmMsg.replace("%s",  unescape(name));
   if (confirm(confirmMsg)) {
-    deleteRole(escape(baseUrl + unescape(link)), onRoleDeleted);
+    deleteRole(escape(unescape(link)), onRoleDeleted);
   }
 }
 

Modified: 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin_rest.js
==============================================================================
--- 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin_rest.js
  (original)
+++ 
trunk/amdatu-authorization/useradmin-gadget/src/main/resources/static/js/useradmin_rest.js
  Tue Jan  4 17:36:28 2011
@@ -1,10 +1,14 @@
+function getBaseUrl() {
+  return "http://"; + window.location.hostname + ":" + window.location.port;
+}
+
 // Loads roles and invokes the callback function with the result
 function loadRoles(url, callback) {
   var params = {};
   params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
gadgets.io.ContentType.JSON;
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
   addAmdatuToken(params);
-  url = addNoCache(url);
+  url = getBaseUrl() + addNoCache(url);
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -14,7 +18,7 @@
   params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
gadgets.io.ContentType.JSON;
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
   addAmdatuToken(params);
-  url = addNoCache(unescape(url));  
+  url = getBaseUrl() + addNoCache(unescape(url));
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -26,7 +30,7 @@
   addAmdatuToken(params);
   var postdata = {value : newpassword};
   params[gadgets.io.RequestParameters.POST_DATA] = 
gadgets.io.encodeValues(postdata);
-  url = addNoCache(url);  
+  url = getBaseUrl() + addNoCache(url);
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -35,7 +39,7 @@
   var params = {};
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.PUT;
   addAmdatuToken(params);
-  url = addNoCache(url);  
+  url = getBaseUrl() + addNoCache(url);
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -44,7 +48,7 @@
   var params = {};
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.PUT;
   addAmdatuToken(params);
-  url = addNoCache(url);  
+  url = getBaseUrl() + addNoCache(url);
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -53,7 +57,7 @@
   var params = {};
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.DELETE;
   addAmdatuToken(params);
-  url = addNoCache(url);  
+  url = getBaseUrl() + addNoCache(url);
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -63,7 +67,7 @@
   params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
gadgets.io.ContentType.JSON;
   params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.DELETE;
   addAmdatuToken(params);
-  url = addNoCache(unescape(url));
+  url = getBaseUrl() + addNoCache(unescape(url));
   gadgets.io.makeRequest(url, callback, params);
 }
 
@@ -77,15 +81,15 @@
   return url;
 }
 
-// Each invocation of gadgets.io.makeRequest is procies via the OpenSocial 
container 
-// to the REST service. For security reasons, it does not pass cookies to this 
REST 
-// service and so, since our REST service verifies authorization against 
UserAdmin, 
+// Each invocation of gadgets.io.makeRequest is procies via the OpenSocial 
container
+// to the REST service. For security reasons, it does not pass cookies to this 
REST
+// service and so, since our REST service verifies authorization against 
UserAdmin,
 // the REST service will deny all calls. The site authentication token needs 
thus
 // to be passed from the OpenSocial container to the REST service, which is 
what
 // happens here.
 function addAmdatuToken(params) {
   var token = getCookie("amdatu_token");
   if (token != null) {
-    params[gadgets.io.RequestParameters.HEADERS] = {"Authorization" : "Amdatu 
" + token}; 
+    params[gadgets.io.RequestParameters.HEADERS] = {"Authorization" : "Amdatu 
" + token};
   }
 }
\ No newline at end of file

Modified: 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/osgi/Activator.java
       (original)
+++ 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/osgi/Activator.java
       Tue Jan  4 17:36:28 2011
@@ -41,13 +41,12 @@
         // Create the CourseGadgetService which has dependencies with the Log 
service
         // and HTTP service
         Component friendsgadgetService = createComponent()
-                .setInterface(ResourceProvider.class.getName(), null)
-                .setImplementation(CourseGadgetServiceImpl.class)
-                
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-                
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
-                
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-                
.add(createConfigurationDependency().setPid(CourseGadgetServiceImpl.PID));
+        .setInterface(ResourceProvider.class.getName(), null)
+        .setImplementation(CourseGadgetServiceImpl.class)
+        
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+        
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
+        
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
+        
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true));
         manager.add(friendsgadgetService);
     }
 

Modified: 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
==============================================================================
--- 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
      (original)
+++ 
trunk/amdatu-example/course-gadget/src/main/java/org/amdatu/example/course/gadget/service/CourseGadgetServiceImpl.java
      Tue Jan  4 17:36:28 2011
@@ -17,7 +17,6 @@
 package org.amdatu.example.course.gadget.service;
 
 import java.net.URL;
-import java.util.Dictionary;
 import java.util.Map;
 
 import org.amdatu.authentication.oauth.api.ConsumerAlreadyExistsException;
@@ -33,8 +32,6 @@
 import org.amdatu.web.httpcontext.ResourceProvider;
 import org.apache.felix.dm.Component;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
@@ -42,12 +39,7 @@
  * gadget XML).
  * @author ivol
  */
-public class CourseGadgetServiceImpl implements ResourceProvider, 
ManagedService {
-    // The PID and configuration properties
-    public final static String PID = "org.amdatu.example.coursegadget";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-    
+public class CourseGadgetServiceImpl implements ResourceProvider {
     // oAuth properties of this gadget as service consumer
     private final static String CONSUMER_CALLBACK_URL = 
"/gadgets/oauthcallback";
     private final static String CONSUMER_KEY = "CcourseExampleGadget";
@@ -65,8 +57,6 @@
 
     // Other instance variables
     private Component m_httpContextComponent;
-    private String m_hostname;
-    private String m_portnr;
 
     /**
      * The init() method is invoked by the Felix dependency manager.
@@ -75,29 +65,20 @@
         // Create our own http context and register resources
         m_httpContextComponent = 
m_httpContextFactoryService.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // FIXME: Because of a bug in the Felix dependency manager, 
update() is not invoked when the bundle
-            // is stopped/started. Hence m_hostname and m_portnr will be null. 
To prevent serious problems as
-            // described in issue 
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
-            // For the bug description, see 
http://jira.amdatu.org/jira/browse/AMDATU-174 
-            // and https://issues.apache.org/jira/browse/FELIX-2696
-        } else {
-            GadgetDefinition gadgetDef =
-                new GadgetDefinition("http://"; + m_hostname + ":" + m_portnr + 
"/" + Activator.RESOURCE_ID
-                    + "/jsp/CourseGadget.jsp", GadgetCategory.AMDATU_EXAMPLES, 
false);
-            
-            // Set oAuth parameters
-            gadgetDef.setServiceName(CONSUMER_NAME);
-            gadgetDef.setConsumerPublicKey(CONSUMER_KEY);
-            gadgetDef.setConsumerPrivateKey(CONSUMER_SECRET);
-            gadgetDef.setCallbackUrl(CONSUMER_CALLBACK_URL);
-            
-            m_gadgetManagement.addGadget(gadgetDef);
-       
-            // Register the service consumer in our own oAuth server such that 
our own oAuth server
-            // can also handle oAuth of this gadget
-            registerConsumer();
-        }
+        GadgetDefinition gadgetDef = new GadgetDefinition("/" + 
Activator.RESOURCE_ID + "/jsp/CourseGadget.jsp", 
GadgetCategory.AMDATU_EXAMPLES, false);
+
+        // Set oAuth parameters
+        gadgetDef.setServiceName(CONSUMER_NAME);
+        gadgetDef.setConsumerPublicKey(CONSUMER_KEY);
+        gadgetDef.setConsumerPrivateKey(CONSUMER_SECRET);
+        gadgetDef.setCallbackUrl(CONSUMER_CALLBACK_URL);
+
+        m_gadgetManagement.addGadget(gadgetDef);
+
+        // Register the service consumer in our own oAuth server such that our 
own oAuth server
+        // can also handle oAuth of this gadget
+        registerConsumer();
+
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
initialized");
     }
 
@@ -108,7 +89,7 @@
         m_httpContextComponent.stop();
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
destroyed");
     }
-    
+
     private void registerConsumer() {
         try {
             if (m_consumerRegistry.getConsumer(CONSUMER_KEY) == null) {
@@ -136,27 +117,11 @@
         return Activator.RESOURCE_ID;
     }
 
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] {HOSTNAME, PORTNR});
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
-
-    private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {
-        for (String mandatoryKey : mandatoryKeys) {
-            if (dictionary.get(mandatoryKey) == null) {
-                throw new ConfigurationException("Missing configuration key", 
mandatoryKey);
-            }
-        }
-    }
-    
     class InternalOAuthServiceConsumer implements OAuthServiceConsumer {
         public String getCallbackUrl() {return CONSUMER_CALLBACK_URL;}
         public String getConsumerKey() {return CONSUMER_KEY;}
         public String getConsumerSecret() {return CONSUMER_SECRET;}
         public String getName() {return CONSUMER_NAME;}
-        public Map<String, String> getProperties() {return null;}              
  
+        public Map<String, String> getProperties() {return null;}
     }
 }

Modified: 
trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp
==============================================================================
--- trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp  
(original)
+++ trunk/amdatu-example/course-gadget/src/main/resources/jsp/CourseGadget.jsp  
Tue Jan  4 17:36:28 2011
@@ -21,8 +21,7 @@
 <%@ page language="java" session="false" buffer="none" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
 
-<c:set var="baseUrl" 
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="gadgetBaseUrl" value="${baseUrl}/examples/gadget/course"/>
+<c:set var="gadgetBaseUrl" value="/examples/gadget/course"/>
 
 <Module>
   <ModulePrefs
@@ -38,9 +37,9 @@
     <Require feature="dynamic-height"/>
     <OAuth>
       <Service name="Course example gadget">
-        <Request url="${baseUrl}/oauth-server/requesttoken" />
-        <Access url="${baseUrl}/oauth-server/accesstoken" />
-        <Authorization url="${baseUrl}/oauth-server/authorizetoken" />
+        <Request url="$/oauth-server/requesttoken" />
+        <Access url="/oauth-server/accesstoken" />
+        <Authorization url="/oauth-server/authorizetoken" />
       </Service>
     </OAuth>
   </ModulePrefs>
@@ -48,6 +47,10 @@
     <![CDATA[
     <link rel="stylesheet" href="/dashboard/static/css/dashboard.css">
     <script type="text/javascript">
+      function getBaseUrl() {
+        return "http://"; + window.location.hostname + ":" + 
window.location.port;
+      }
+
      /**
       * Request for course information.
       */
@@ -60,7 +63,7 @@
         params[gadgets.io.RequestParameters.AUTHORIZATION] = 
gadgets.io.AuthorizationType.OAUTH;
         params[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = "Course 
example gadget";
         params[gadgets.io.RequestParameters.OAUTH_USE_TOKEN] = "if_available";
-        var url = "${baseUrl}/rest/course?getCourses";
+        var url = getBaseUrl() + "/rest/course?getCourses";
         gadgets.io.makeRequest(url, onLoadCourses, params);
       }
 
@@ -111,7 +114,6 @@
         }
         document.getElementById('courses').innerHTML = html;
         gadgets.window.adjustHeight();
-
       };
 
       gadgets.util.registerOnLoadHandler(fetchData);

Modified: 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
==============================================================================
--- 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
   (original)
+++ 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friend/sgadget/service/FriendsGadgetServiceImpl.java
   Tue Jan  4 17:36:28 2011
@@ -19,7 +19,6 @@
 import static org.amdatu.example.friends.gadget.osgi.Activator.RESOURCE_ID;
 
 import java.net.URL;
-import java.util.Dictionary;
 
 import org.amdatu.example.friends.gadget.osgi.Activator;
 import org.amdatu.opensocial.gadgetmanagement.GadgetManagement;
@@ -29,8 +28,6 @@
 import org.amdatu.web.httpcontext.ResourceProvider;
 import org.apache.felix.dm.Component;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
@@ -38,12 +35,7 @@
  * the gadget XML).
  * @author ivol
  */
-public class FriendsGadgetServiceImpl implements ResourceProvider, 
ManagedService {
-    // The PID and configuration properties
-    public final static String PID = "org.amdatu.example.friendsgadget";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-
+public class FriendsGadgetServiceImpl implements ResourceProvider {
     // Service and other dependencies, injected by the OSGi framework
     private volatile HttpContextServiceFactory m_httpContextFactoryService;
     private volatile LogService m_logService;
@@ -54,8 +46,7 @@
 
     // Other instance variables
     private Component m_httpContextComponent;
-    private String m_hostname;
-    private String m_portnr;
+
     /**
      * The init() method is invoked by the Felix dependency manager.
      */
@@ -63,18 +54,11 @@
         // Create our own http context service
         m_httpContextComponent = 
m_httpContextFactoryService.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // FIXME: Because of a bug in the Felix dependency manager, 
update() is not invoked when the bundle
-            // is stopped/started. Hence m_hostname and m_portnr will be null. 
To prevent serious problems as
-            // described in issue 
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
-            // For the bug description, see 
http://jira.amdatu.org/jira/browse/AMDATU-174 
-            // and https://issues.apache.org/jira/browse/FELIX-2696
-        }  else {
-            GadgetDefinition gadgetDef = new GadgetDefinition("http://"; + 
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID + 
"/static/xml/FriendsGadget.xml",
-                GadgetCategory.AMDATU_EXAMPLES, false);
-            gadgetDef.setServiceName("friends");
-            m_gadgetManagement.addGadget(gadgetDef);
-        }
+        GadgetDefinition gadgetDef = new GadgetDefinition("/" + 
Activator.RESOURCE_ID + "/static/xml/FriendsGadget.xml",
+            GadgetCategory.AMDATU_EXAMPLES, false);
+        gadgetDef.setServiceName("friends");
+        m_gadgetManagement.addGadget(gadgetDef);
+
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
initialized");
     }
 
@@ -95,20 +79,4 @@
     public String getResourceId() {
         return RESOURCE_ID;
     }
-
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] {HOSTNAME, PORTNR});
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
-
-    private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {
-        for (String mandatoryKey : mandatoryKeys) {
-            if (dictionary.get(mandatoryKey) == null) {
-                throw new ConfigurationException("Missing configuration key", 
mandatoryKey);
-            }
-        }
-    }
 }

Modified: 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friends/gadget/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friends/gadget/osgi/Activator.java
     (original)
+++ 
trunk/amdatu-example/friends-gadget/src/main/java/org/amdatu/example/friends/gadget/osgi/Activator.java
     Tue Jan  4 17:36:28 2011
@@ -35,19 +35,18 @@
     // The resource identifier for this bundle. Resources are only considered 
to be 'ours' when
     // it is prefixed with this id.
     public final static String RESOURCE_ID = "examples/gadget/friends";
-    
+
     @Override
     public void init(BundleContext context, DependencyManager manager) throws 
Exception {
         // Create the FriendsGadgetService which has dependencies with the Log 
service
         // and HTTP service
         Component friendsgadgetService = createComponent()
-                .setInterface(ResourceProvider.class.getName(), null)
-                .setImplementation(FriendsGadgetServiceImpl.class)
-                
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-                
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpService.class).setRequired(true))
-                
.add(createConfigurationDependency().setPid(FriendsGadgetServiceImpl.PID));
+        .setInterface(ResourceProvider.class.getName(), null)
+        .setImplementation(FriendsGadgetServiceImpl.class)
+        
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+        
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
+        
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
+        
.add(createServiceDependency().setService(HttpService.class).setRequired(true));
         manager.add(friendsgadgetService);
     }
 

Modified: 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
       (original)
+++ 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/osgi/Activator.java
       Tue Jan  4 17:36:28 2011
@@ -50,25 +50,24 @@
         // Create the FriendsGadgetService which has dependencies with the Log 
service
         // and HTTP service
         manager.add(createComponent()
-                .setInterface(ResourceProvider.class.getName(), null)
-                .setImplementation(OAuthGadgetsRegistrationServiceImpl.class)
-                
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-                
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-                
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpService.class).setRequired(true))
-                
.add(createConfigurationDependency().setPid(OAuthGadgetsRegistrationServiceImpl.PID)));
-        
+            .setInterface(ResourceProvider.class.getName(), null)
+            .setImplementation(OAuthGadgetsRegistrationServiceImpl.class)
+            
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+            
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
+            
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
+            
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
+            
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
+
         manager.add(createComponent()
-                .setInterface(DummyInterface.class.getName(), null)
-                .setImplementation(OAuthProtectedResource.class)
-                
.add(createServiceDependency().setService(LogService.class).setRequired(true))
-                
.add(createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true))
-                
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true)));
+            .setInterface(DummyInterface.class.getName(), null)
+            .setImplementation(OAuthProtectedResource.class)
+            
.add(createServiceDependency().setService(LogService.class).setRequired(true))
+            
.add(createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true))
+            
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true)));
     }
 
     @Override
     public void destroy(BundleContext bundleContext, DependencyManager 
dependencyManager) throws Exception {
     }
-    
+
 }
\ No newline at end of file

Modified: 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
==============================================================================
--- 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
  (original)
+++ 
trunk/amdatu-example/oauth/src/main/java/org/amdatu/example/oauth/service/OAuthGadgetsRegistrationServiceImpl.java
  Tue Jan  4 17:36:28 2011
@@ -19,7 +19,6 @@
 import static org.amdatu.example.oauth.osgi.Activator.RESOURCE_ID;
 
 import java.net.URL;
-import java.util.Dictionary;
 import java.util.Map;
 
 import org.amdatu.authentication.oauth.api.ConsumerAlreadyExistsException;
@@ -34,8 +33,6 @@
 import org.amdatu.web.httpcontext.ResourceProvider;
 import org.apache.felix.dm.Component;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
@@ -43,12 +40,7 @@
  * 
  * @author ivol
  */
-public class OAuthGadgetsRegistrationServiceImpl implements ResourceProvider, 
ManagedService {
-    // The PID and configuration properties
-    public final static String PID = "org.amdatu.example.oauth";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-
+public class OAuthGadgetsRegistrationServiceImpl implements ResourceProvider {
     // oAuth properties of this gadget as service consumer
     private final static String CONSUMER_CALLBACK_URL = 
"/gadgets/oauthcallback";
     private final static String CONSUMER_KEY = "example.amdatu.org";
@@ -67,8 +59,6 @@
 
     // Other instance variables
     private Component m_httpContextComponent;
-    private String m_hostname;
-    private String m_portnr;
 
     /**
      * The init() method is invoked by the Felix dependency manager.
@@ -77,29 +67,21 @@
         // Create our own http context service
         m_httpContextComponent = 
m_httpContextFactoryService.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // TODO: update() is only invoked the very first time this service 
is created. When you stop/start the bundle,
-            // updated() will not be invoked (at all!) and so hostname and 
portnr remain null.
-            // This is a known issue in the Felix dependency manager.
-            // See http://jira.amdatu.org/jira/browse/AMDATU-174 and 
https://issues.apache.org/jira/browse/FELIX-2696
-        }
-        else {
-            String baseUrl = "http://"; + m_hostname + ":" + m_portnr;
-            String gadgetUrl = baseUrl + "/" + RESOURCE_ID + 
"/jsp/3leggedOAuthGadget.jspf";
-            GadgetDefinition gadgetDef = new GadgetDefinition(gadgetUrl, 
GadgetCategory.AMDATU_EXAMPLES, false);
-
-            // Set oAuth parameters
-            gadgetDef.setServiceName(SERVICE_NAME);
-            gadgetDef.setConsumerPublicKey(CONSUMER_KEY);
-            gadgetDef.setConsumerPrivateKey(CONSUMER_SECRET);
-            gadgetDef.setCallbackUrl(CONSUMER_CALLBACK_URL);
-
-            m_gadgetManagement.addGadget(gadgetDef);
-
-            // Register the service consumer in our own oAuth server such that 
our own oAuth server
-            // can also handle oAuth of this gadget
-            registerConsumer();
-        }
+        String gadgetUrl = "/" + RESOURCE_ID + "/jsp/3leggedOAuthGadget.jspf";
+        GadgetDefinition gadgetDef = new GadgetDefinition(gadgetUrl, 
GadgetCategory.AMDATU_EXAMPLES, false);
+
+        // Set oAuth parameters
+        gadgetDef.setServiceName(SERVICE_NAME);
+        gadgetDef.setConsumerPublicKey(CONSUMER_KEY);
+        gadgetDef.setConsumerPrivateKey(CONSUMER_SECRET);
+        gadgetDef.setCallbackUrl(CONSUMER_CALLBACK_URL);
+
+        m_gadgetManagement.addGadget(gadgetDef);
+
+        // Register the service consumer in our own oAuth server such that our 
own oAuth server
+        // can also handle oAuth of this gadget
+        registerConsumer();
+
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
initialized");
     }
 
@@ -121,24 +103,6 @@
         return RESOURCE_ID;
     }
 
-    @SuppressWarnings("unchecked")
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] { HOSTNAME, PORTNR });
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {
-        for (String mandatoryKey : mandatoryKeys) {
-            if (dictionary.get(mandatoryKey) == null) {
-                throw new ConfigurationException("Missing configuration key", 
mandatoryKey);
-            }
-        }
-    }
-
     private void registerConsumer() {
         try {
             if (m_consumerRegistry.getConsumer(CONSUMER_KEY) == null) {

Modified: 
trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf
==============================================================================
--- trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf   
(original)
+++ trunk/amdatu-example/oauth/src/main/resources/jsp/3leggedOAuthGadget.jspf   
Tue Jan  4 17:36:28 2011
@@ -1,8 +1,6 @@
 <%@ page language="java" session="false" buffer="none" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
 
-<c:set var="baseUrl" 
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -35,9 +33,9 @@
     <Require feature="dynamic-height"/>
     <OAuth>
       <Service name="oauth-example">
-        <Request url="${baseUrl}/oauth-server/requesttoken" />
-        <Access url="${baseUrl}/oauth-server/accesstoken" />
-        <Authorization url="${baseUrl}/oauth-server/authorizetoken" />
+        <Request url="/oauth-server/requesttoken" />
+        <Access url="/oauth-server/accesstoken" />
+        <Authorization url="/oauth-server/authorizetoken" />
       </Service>
     </OAuth>
   </ModulePrefs>
@@ -50,7 +48,7 @@
 
     <div id="approval" style="display: none">
       <p>
-        <img src="${baseUrl}/dashboard/static/img/new.gif">
+        <img src="/dashboard/static/img/new.gif">
         <a href="#" id="personalize">Personalize this gadget</a>
       </p>
     </div>
@@ -80,8 +78,12 @@
         }
       }
 
+      function getBaseUrl() {
+        return "http://"; + window.location.hostname + ":" + 
window.location.port;
+      }
+
       function fetchData() {
-        var url = "${baseUrl}/rest/resource";
+        var url = getBaseUrl() + "/rest/resource";
         var params = {};
         params[gadgets.io.RequestParameters.CONTENT_TYPE] = 
gadgets.io.ContentType.TEXT;
         params[gadgets.io.RequestParameters.AUTHORIZATION] = 
gadgets.io.AuthorizationType.OAUTH;

Modified: 
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/gadgets_appdata.js
==============================================================================
--- 
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/gadgets_appdata.js
   (original)
+++ 
trunk/amdatu-opensocial/dashboard/src/main/resources/static/js/gadgets_appdata.js
   Tue Jan  4 17:36:28 2011
@@ -16,24 +16,26 @@
         error: function(request, textStatus, errorThrown) {
           currentGadgets = null;
         }
-  });   
+  });
   return currentGadgets;
 }
 
 // Adds a gadget to the AppData of the current user
 addWidgetToAppData = function(obj, startId, dashboard) {
   var currentGadgets = 
retrieveCurrentWidgetsInAppData(obj.metadata.securetoken);
-  var gadgetId = startId + '-' + obj.metadata.gadgeturl;
-  
+  var gadgetUrl = obj.metadata.gadgeturl + "";
+  var gadgetId = encodeURIComponent(startId + '-' + gadgetUrl);
+
   // use appData opensocial call to add this gadget to the users appData
   var postdata = '{"registeredgadgets":"';
   if (currentGadgets == "" || !currentGadgets) {
-    postdata += gadgetId + '"}';
+    postdata += gadgetUrl + '"}';
   } else {
-    postdata += currentGadgets + " " + gadgetId + '"}';
+    postdata += currentGadgets + " " + gadgetUrl + '"}';
   }
 
   var url = "/social/rest/appdata/@me/@self/" + gadgetId + 
"?fields=registeredgadgets&st=" + obj.metadata.securetoken;
+
   jQuery.ajax({
     url: url,
     type: "PUT",
@@ -43,7 +45,7 @@
     async:false,
     success: function(response) {
       dashboard.addWidget({
-        "id":gadgetId,
+        "id":decodeURIComponent(gadgetId),
         "title":obj.title,
         "url":"",
         "metadata":obj.metadata
@@ -51,13 +53,13 @@
     },
     error: function(request, textStatus, errorThrown) {
       dashboard.addWidget({
-        "id":gadgetId,
+        "id":decodeURIComponent(gadgetId),
         "title":obj.title,
         "url":"",
         "metadata":obj.metadata
         }, dashboard.element.find('.column:first'));
     }
-  });   
+  });
 }
 
 // Removes a gadget from the AppData of the current user
@@ -77,5 +79,5 @@
       },
     error: function(request, textStatus, errorThrown) {
     }
-  });     
+  });
 }

Modified: 
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
==============================================================================
--- 
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
      (original)
+++ 
trunk/amdatu-opensocial/gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/GadgetManagementServiceImpl.java
      Tue Jan  4 17:36:28 2011
@@ -181,7 +181,7 @@
 
     /**
      * Returns gadgets available in the gadget store. URL to this resource:
-     * http://localhost:3737/rest/gadgetstore/categories
+     * /rest/gadgetstore/categories
      *
      * @return All available gadgets.
      */
@@ -215,7 +215,7 @@
 
     /**
      * Returns gadgets available in the gadget store. URL to this resource:
-     * http://localhost:3737/rest/gadgetstore/gadgets/all
+     * /rest/gadgetstore/gadgets/all
      *
      * @return All available gadgets.
      */
@@ -235,7 +235,7 @@
             }
             for (GadgetDefinition gadgetDefinition : getGadgets()) {
                 boolean skip = false;
-                JSONObject gadget = retrieveGadget(gadgetDefinition.getUrl());
+                JSONObject gadget = 
retrieveGadget(toAbsoluteUrl(gadgetDefinition.getUrl(), request));
                 if (gadget != null) {
                     if (!"".equals(categoryId)) {
                         String category = 
gadgetCategories.get(gadgetDefinition.getUrl());
@@ -273,7 +273,7 @@
 
     /**
      * Returns gadgets registered for the current user. URL to this resource:
-     * http://localhost:3737/rest/gadgetstore/gadgets/mine
+     * /rest/gadgetstore/gadgets/mine
      *
      * @return Gadgets registered for the current user.
      */
@@ -306,7 +306,7 @@
                     Map<String, String> values = new HashMap<String, String>();
                     int i = 0;
                     String sDefaultGadgetUrls = "";
-                    String[] defaultGadgetUrls = getDefaultGadgetUrls();
+                    String[] defaultGadgetUrls = getDefaultGadgetUrls(request);
                     for (String defaultGadgetUrl : defaultGadgetUrls) {
                         if (i == 0) {
                             sDefaultGadgetUrls += defaultGadgetUrl;
@@ -324,7 +324,7 @@
             boolean generateStartId = false;
             if (gadgetIds == null) {
                 generateStartId = true;
-                gadgetIds = getDefaultGadgetUrls();
+                gadgetIds = getDefaultGadgetUrls(request);
             }
 
             // For now just return all gadgets, but with additional security 
token
@@ -401,7 +401,6 @@
 
     private Map<String, String> getGadgetSpec(String gadgetUrl) {
         Map<String, String> gadgetSpec = new HashMap<String, String>();
-
         try {
             m_logService.log(LogService.LOG_DEBUG, "Retrieving gadgetspec for 
'" + gadgetUrl + "'");
             String xml = loadXMLFromCache(new URL(gadgetUrl));
@@ -654,7 +653,7 @@
         gadget.getJSONObject("metadata").put("securetoken", securityToken);
     }
 
-    private String[] getDefaultGadgetUrls() {
+    private String[] getDefaultGadgetUrls(HttpServletRequest request) {
         List<GadgetDefinition> defaultGadgetList = new 
ArrayList<GadgetDefinition>();
         for (GadgetDefinition gadgetDefinition : getGadgets()) {
             if (gadgetDefinition.isDefaultVisible()) {
@@ -664,7 +663,7 @@
         String[] gadgetUrls = new String[defaultGadgetList.size()];
         int i = 0;
         for (GadgetDefinition gadgetDefinition : defaultGadgetList) {
-            gadgetUrls[i] = gadgetDefinition.getUrl();
+            gadgetUrls[i] = toAbsoluteUrl(gadgetDefinition.getUrl(), request);
             i++;
         }
         return gadgetUrls;
@@ -703,4 +702,13 @@
         }
         return null;
     }
+
+    private String toAbsoluteUrl(String url, HttpServletRequest request) {
+        if (url.startsWith("/")) {
+            // This is a relative URL, convert to absolute URL
+            String baseUrl = request.getScheme() + "://" + 
request.getServerName() + ":" + request.getServerPort();
+            return baseUrl + url;
+        }
+        return url;
+    }
 }

Modified: 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraAppDataServiceStore.java
==============================================================================
--- 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraAppDataServiceStore.java
   (original)
+++ 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraAppDataServiceStore.java
   Tue Jan  4 17:36:28 2011
@@ -16,14 +16,14 @@
  */
 package org.amdatu.opensocial.shindig.persistence;
 
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Future;
 
-import com.google.common.collect.Maps;
+import javax.servlet.http.HttpServletResponse;
+
 import org.amdatu.libraries.utilities.ConversionUtil;
 import org.amdatu.opensocial.shindig.OpenSocialConstants;
 import org.apache.shindig.auth.SecurityToken;
@@ -37,6 +37,8 @@
 import org.osgi.service.useradmin.Role;
 import org.osgi.service.useradmin.User;
 import org.osgi.service.useradmin.UserAdmin;
+
+import com.google.common.collect.Maps;
 /**
  * This class is responsible for storage of the OpenSocial content called 
"AppData".
  * @author ivol
@@ -52,7 +54,7 @@
 
     @SuppressWarnings("unchecked")
     public Future<Void> updatePersonData(UserId userId, GroupId groupId, 
String appId, Set<String> fields,
-            Map<String, String> values, SecurityToken token) throws 
ProtocolException {
+        Map<String, String> values, SecurityToken token) throws 
ProtocolException {
         User user = getUser(userId, token);
         if (user != null) {
             // Convert the String Map to a byte array and write it to UserAdmin
@@ -62,17 +64,17 @@
                 return ImmediateFuture.newInstance(null);
             } catch (IOException e) {
                 throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                        "Could not update AppData for user with id '" + 
userId.getUserId() + "'.", e);
+                    "Could not update AppData for user with id '" + 
userId.getUserId() + "'.", e);
             }
         }
 
-        throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "User with id 
'" + userId.getUserId()
-                + "' not found");
+        // If no user is known, ignore this update person data request
+        return ImmediateFuture.newInstance(null);
     }
 
     @SuppressWarnings("unchecked")
     public Future<DataCollection> getPersonData(Set<UserId> userIds, GroupId 
groupId, String appId, Set<String> fields,
-            SecurityToken token) throws ProtocolException {
+        SecurityToken token) throws ProtocolException {
         Map<String, Map<String, String>> idToData = Maps.newHashMap();
         for (UserId userId : userIds) {
             User user = getUser(userId, token);
@@ -84,10 +86,10 @@
                         idToData.put(userId.getUserId(token), values);
                     } catch (ClassNotFoundException e) {
                         throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                                "Could not retrieve AppData for user with id 
'" + userId.getUserId() + "'.", e);
+                            "Could not retrieve AppData for user with id '" + 
userId.getUserId() + "'.", e);
                     } catch (IOException e) {
                         throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                                "Could not retrieve AppData for user with id 
'" + userId.getUserId() + "'.", e);
+                            "Could not retrieve AppData for user with id '" + 
userId.getUserId() + "'.", e);
                     }
                 } else {
                     idToData.put(userId.getUserId(token), new HashMap<String, 
String>());
@@ -99,7 +101,7 @@
 
     @SuppressWarnings("unchecked")
     public Future<Void> deletePersonData(UserId userId, GroupId groupId, 
String appId, Set<String> fields,
-            SecurityToken token) throws ProtocolException {
+        SecurityToken token) throws ProtocolException {
         User user = getUser(userId, token);
         if (user != null) {
             // Convert the String Map to a byte array and write it to UserAdmin
@@ -113,15 +115,15 @@
                 return ImmediateFuture.newInstance(null);
             } catch (IOException e) {
                 throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                        "Could not delete AppData for user with id '" + 
userId.getUserId() + "'.", e);
+                    "Could not delete AppData for user with id '" + 
userId.getUserId() + "'.", e);
             } catch (ClassNotFoundException e) {
                 throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                        "Could not delete AppData for user with id '" + 
userId.getUserId() + "'.", e);
+                    "Could not delete AppData for user with id '" + 
userId.getUserId() + "'.", e);
             }
         }
 
         throw new 
ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "User with id 
'" + userId.getUserId()
-                + "' not found");
+            + "' not found");
     }
 
     private User getUser(UserId userId, SecurityToken token) {

Modified: 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraOAuthStore.java
==============================================================================
--- 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraOAuthStore.java
    (original)
+++ 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/persistence/CassandraOAuthStore.java
    Tue Jan  4 17:36:28 2011
@@ -28,9 +28,12 @@
 import org.amdatu.opensocial.shindig.GadgetStore;
 import org.apache.shindig.auth.SecurityToken;
 import org.apache.shindig.gadgets.GadgetException;
-import org.apache.shindig.gadgets.oauth.*;
+import org.apache.shindig.gadgets.oauth.BasicOAuthStore;
+import org.apache.shindig.gadgets.oauth.BasicOAuthStoreConsumerIndex;
+import org.apache.shindig.gadgets.oauth.BasicOAuthStoreConsumerKeyAndSecret;
+import org.apache.shindig.gadgets.oauth.BasicOAuthStoreTokenIndex;
+import org.apache.shindig.gadgets.oauth.OAuthStore;
 import 
org.apache.shindig.gadgets.oauth.BasicOAuthStoreConsumerKeyAndSecret.KeyType;
-import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 
 /**
@@ -41,7 +44,6 @@
  */
 public class CassandraOAuthStore implements OAuthStore {
     // Service dependencies in jected by the framework
-    private volatile BundleContext m_bundleContext;
     private volatile LogService m_logService;
     private volatile GadgetStore m_gadgetStore;
 
@@ -64,11 +66,11 @@
         // Now load the consumers
         loadConsumers();
     }
-    
+
     public void start() {
         m_logService.log(LogService.LOG_DEBUG, "Service " + 
this.getClass().getName() + " is now available");
-    } 
-    
+    }
+
     // load the initial consumers
     // TODO: this doesn't work properly in flexible environment where gadgets 
are added and removed from the store
     // continuously.
@@ -93,7 +95,7 @@
         }
 
         BasicOAuthStoreConsumerKeyAndSecret kas =
-                new BasicOAuthStoreConsumerKeyAndSecret(consumerKey, 
consumerSecret, keyType, null, callbackUrl);
+            new BasicOAuthStoreConsumerKeyAndSecret(consumerKey, 
consumerSecret, keyType, null, callbackUrl);
 
         BasicOAuthStoreConsumerIndex index = new 
BasicOAuthStoreConsumerIndex();
         index.setGadgetUri(gadgetUrl);
@@ -102,10 +104,10 @@
     }
 
     public void setConsumerKeyAndSecret(BasicOAuthStoreConsumerIndex 
providerKey,
-            BasicOAuthStoreConsumerKeyAndSecret keyAndSecret) {
+        BasicOAuthStoreConsumerKeyAndSecret keyAndSecret) {
         m_consumerInfos.put(providerKey, keyAndSecret);
     }
-    
+
     // FIXME: for now we provide an update method that in case a token is 
retrieved for a recently added gadget
     private void update() {
         GadgetDefinition[] gadgets = m_gadgetStore.getGadgets();
@@ -120,8 +122,7 @@
     }
 
     public ConsumerInfo getConsumerKeyAndSecret(SecurityToken securityToken, 
String serviceName,
-            OAuthServiceProvider provider) throws GadgetException {
-
+        OAuthServiceProvider provider) throws GadgetException {
         BasicOAuthStoreConsumerIndex pk = new BasicOAuthStoreConsumerIndex();
         pk.setGadgetUri(securityToken.getAppUrl());
         pk.setServiceName(serviceName);
@@ -131,12 +132,18 @@
             update();
             cks = m_consumerInfos.get(pk);
             if (cks == null) {
-                cks = m_gadgetStore.getDefaultKey();
+                // Internal gadgets may be registered under the relative url 
while the appUrl is always absolute.
+                // So convert to relative url and see if we find this gadget 
then.
+                pk.setGadgetUri(toRelativeUrl(securityToken.getAppUrl()));
+                cks = m_consumerInfos.get(pk);
+                if (cks == null) {
+                    cks = m_gadgetStore.getDefaultKey();
+                }
             }
         }
         if (cks == null) {
             throw new 
GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, "No key for gadget "
-                    + securityToken.getAppUrl() + " and service " + 
serviceName);
+                + securityToken.getAppUrl() + " and service " + serviceName);
         }
         OAuthConsumer consumer = null;
         if (cks.getKeyType() == KeyType.RSA_PRIVATE) {
@@ -155,26 +162,26 @@
     }
 
     public TokenInfo getTokenInfo(SecurityToken securityToken, ConsumerInfo 
consumerInfo, String serviceName,
-            String tokenName) throws GadgetException {
+        String tokenName) throws GadgetException {
         BasicOAuthStoreTokenIndex tokenKey = 
makeBasicOAuthStoreTokenIndex(securityToken, serviceName, tokenName);
         return m_tokens.get(tokenKey);
     }
 
     public void setTokenInfo(SecurityToken securityToken, ConsumerInfo 
consumerInfo, String serviceName,
-            String tokenName, TokenInfo tokenInfo) throws GadgetException {
+        String tokenName, TokenInfo tokenInfo) throws GadgetException {
         BasicOAuthStoreTokenIndex tokenKey = 
makeBasicOAuthStoreTokenIndex(securityToken, serviceName, tokenName);
         m_tokens.put(tokenKey, tokenInfo);
     }
 
     public void removeToken(SecurityToken securityToken, ConsumerInfo 
consumerInfo, String serviceName, String tokenName)
-            throws GadgetException {
+    throws GadgetException {
         BasicOAuthStoreTokenIndex tokenKey = 
makeBasicOAuthStoreTokenIndex(securityToken, serviceName, tokenName);
         m_tokens.remove(tokenKey);
     }
 
     // Creates an index from all properties used for the token hashmap
     private BasicOAuthStoreTokenIndex 
makeBasicOAuthStoreTokenIndex(SecurityToken securityToken, String serviceName,
-            String tokenName) {
+        String tokenName) {
         BasicOAuthStoreTokenIndex tokenKey = new BasicOAuthStoreTokenIndex();
         tokenKey.setGadgetUri(securityToken.getAppUrl());
         tokenKey.setModuleId(securityToken.getModuleId());
@@ -183,4 +190,13 @@
         tokenKey.setUserId(securityToken.getViewerId());
         return tokenKey;
     }
+
+    private String toRelativeUrl(String absUrl) {
+        if (!absUrl.startsWith("/")) {
+            String relUrl = absUrl.substring(absUrl.indexOf("//") + 2);
+            relUrl = relUrl.substring(relUrl.indexOf("/"));
+            return relUrl;
+        }
+        return absUrl;
+    }
 }

Modified: 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/Activator.java
==============================================================================
--- 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/Activator.java
  (original)
+++ 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/Activator.java
  Tue Jan  4 17:36:28 2011
@@ -50,8 +50,7 @@
                 
createServiceDependency().setService(LogService.class).setRequired(true))
                 
.add(createServiceDependency().setService(GadgetManagement.class).setRequired(true))
                 
.add(createServiceDependency().setService(ModelSet.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-                
.add(createConfigurationDependency().setPid(SPARQLEndpointServiceImpl.PID)));
+                
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true)));
     }
 
     @Override

Modified: 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
==============================================================================
--- 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
  (original)
+++ 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/java/org/amdatu/semanticweb/sparqlendpoint/service/SPARQLEndpointServiceImpl.java
  Tue Jan  4 17:36:28 2011
@@ -17,7 +17,6 @@
 package org.amdatu.semanticweb.sparqlendpoint.service;
 
 import java.net.URL;
-import java.util.Dictionary;
 import java.util.List;
 
 import javax.ws.rs.Consumes;
@@ -49,8 +48,6 @@
 import org.ontoware.rdf2go.model.QueryResultTable;
 import org.ontoware.rdf2go.model.QueryRow;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 
 /**
@@ -60,15 +57,10 @@
  * @author ivol
  */
 @Path("sparqlendpoint")
-public class SPARQLEndpointServiceImpl implements ResourceProvider, 
ManagedService {
+public class SPARQLEndpointServiceImpl implements ResourceProvider {
     // Max row count for one triple query
     private static final int MAX_ROW_COUNT = 250;
 
-    // The PID and configuration properties
-    public final static String PID = "org.amdatu.semanticweb.sparqlendpoint";
-    private final static String HOSTNAME = "hostname";
-    private final static String PORTNR = "portnr";
-
     // Service dependencies, injected by the Felix dependency manager
     private volatile LogService m_logService;
     private volatile BundleContext m_bundleContext;
@@ -78,8 +70,6 @@
 
     // The private HTTP context service for this bundle
     private Component m_httpContextComponent;
-    private String m_hostname;
-    private String m_portnr;
 
     // HTTP caching policy for this REST interface
     private static CacheControl m_cacheControl;
@@ -95,19 +85,12 @@
         // Create our own http context service which registers static 
resources and JSPs automatically
         m_httpContextComponent = 
m_httpContextServiceFactory.create(m_bundleContext, this);
 
-        if (m_hostname == null || m_portnr == null) {
-            // FIXME: Because of a bug in the Felix dependency manager, 
update() is not invoked when the bundle
-            // is stopped/started. Hence m_hostname and m_portnr will be null. 
To prevent serious problems as
-            // described in issue 
http://jira.amdatu.org/jira/browse/AMDATU-199 we implement this check for now.
-            // For the bug description, see 
http://jira.amdatu.org/jira/browse/AMDATU-174
-            // and https://issues.apache.org/jira/browse/FELIX-2696
-        } else {
-            // Register the gadget with the Gadget management service. Note 
that we can do this as
-            // many times as we want, since the gadget URL is the unique 
identifier
-            GadgetDefinition gadgetDef = new GadgetDefinition("http://"; + 
m_hostname + ":" + m_portnr + "/" + Activator.RESOURCE_ID + 
"/jsp/SPARQLEndpointGadget.jsp",
-                GadgetCategory.AMDATU_PLATFORM, true);
-            m_gadgetManagement.addGadget(gadgetDef);
-        }
+        // Register the gadget with the Gadget management service. Note that 
we can do this as
+        // many times as we want, since the gadget URL is the unique identifier
+        GadgetDefinition gadgetDef = new GadgetDefinition("/" + 
Activator.RESOURCE_ID + "/jsp/SPARQLEndpointGadget.jsp",
+            GadgetCategory.AMDATU_PLATFORM, true);
+        m_gadgetManagement.addGadget(gadgetDef);
+
         m_logService.log(LogService.LOG_INFO, getClass().getName() + " service 
initialized");
     }
 
@@ -193,21 +176,4 @@
     public String getResourceId() {
         return Activator.RESOURCE_ID;
     }
-
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary != null) {
-            checkAvailability(dictionary, new String[] {HOSTNAME, PORTNR});
-            m_hostname = (String) dictionary.get(HOSTNAME);
-            m_portnr = (String) dictionary.get(PORTNR);
-        }
-    }
-
-    private void checkAvailability(Dictionary dictionary, String[] 
mandatoryKeys) throws ConfigurationException {
-        for (String mandatoryKey : mandatoryKeys) {
-            if (dictionary.get(mandatoryKey) == null) {
-                throw new ConfigurationException("Missing configuration key", 
mandatoryKey);
-            }
-        }
-    }
-
 }

Modified: 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
==============================================================================
--- 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
     (original)
+++ 
trunk/amdatu-semanticweb/sparqlendpoint/src/main/resources/jsp/SPARQLEndpointGadget.jsp
     Tue Jan  4 17:36:28 2011
@@ -21,8 +21,7 @@
 <%@ page language="java" session="false" buffer="none" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
 
-<c:set var="baseUrl" 
value="http://${pageContext.request.serverName}:${pageContext.request.serverPort}"/>
-<c:set var="gadgetBaseUrl" value="${baseUrl}/gadget/sparqlendpoint"/>
+<c:set var="gadgetBaseUrl" value="/gadget/sparqlendpoint"/>
 
 <Module>
   <ModulePrefs
@@ -53,7 +52,7 @@
         };
         params[gadgets.io.RequestParameters.POST_DATA] = 
gadgets.io.encodeValues(postdata);
 
-        var url = "${baseUrl}/rest/sparqlendpoint?executeSPARQLQuery";
+        var url = getBaseUrl() + "/rest/sparqlendpoint?executeSPARQLQuery";
         if (queryParams) {
           url += "&" + queryParams;
         }
@@ -130,6 +129,10 @@
         gadgets.window.adjustHeight();
 
       }
+
+      function getBaseUrl() {
+        return "http://"; + window.location.hostname + ":" + 
window.location.port;
+      }
     </script>
 
     <p>

Reply via email to