Author: ivol37 at gmail.com
Date: Mon Jan 17 12:07:36 2011
New Revision: 664

Log:
[AMDATU-267] Fixed proper setting of service.rank property

Modified:
   
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/osgi/Activator.java
   
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/osgi/FSUserAdminStorageProviderActivator.java
   
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigRegistrationServiceImpl.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java

Modified: 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/osgi/Activator.java
       (original)
+++ 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/osgi/Activator.java
       Mon Jan 17 12:07:36 2011
@@ -42,14 +42,14 @@
     // 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 = "useradmin";
-    
+
     @Override
     public void init(BundleContext context, DependencyManager manager) throws 
Exception {
         // First define a service that provides the Role ColumnFamily we need
         manager.add(createComponent()
                 .setInterface(new 
String[]{ColumnFamilyProvider.class.getName()}, null)
                 .setImplementation(RoleColumnFamilyProvider.class));
-        
+
         // This filter is used to define a service dependency on the 
ColumnFamilyAvailable service
         // for the Role ColumnFamily. As a result, our service will depend on 
the availability
         // of this ColumnFamily.
@@ -58,11 +58,11 @@
             "(" + CassandraPersistenceManager.KEYSPACE_AWARE_KEY + "="
                     + CassandraPersistenceManager.DEFAULT_KEYSPACE + ")";
         roleFilter = "(&" + roleFilter + keyspaceFilter + ")";
-        
+
         // Create and register the CassandraStorageProvider service.
-        Hashtable<String, String> properties = new Hashtable<String, String>();
+        Hashtable<String, Object> properties = new Hashtable<String, Object>();
         properties.put(UserAdminConstants.STORAGEPROVIDER_TYPE, "Cassandra");
-        properties.put("service.ranking", "10");
+        properties.put("service.ranking", 10);
         manager.add(createComponent()
                 .setInterface(new String[]{StorageProvider.class.getName()}, 
properties)
                 .setImplementation(CassandraStorageProvider.class)
@@ -70,14 +70,14 @@
                 
.add(createServiceDependency().setService(CassandraPersistenceManager.class, 
keyspaceFilter).setRequired(true))
                 
.add(createServiceDependency().setService(ColumnFamilyAvailable.class, 
roleFilter).setRequired(true))
                 
.add(createServiceDependency().setService(CassandraDaemonService.class).setRequired(true)));
-        
+
         // Create and register the http context registration service
         manager.add(createComponent()
                 .setInterface(ResourceProvider.class.getName(), null)
                 .setImplementation(HttpContextRegistrationServiceImpl.class)
                 
.add(createServiceDependency().setService(LogService.class).setRequired(true))
                 
.add(createServiceDependency().setService(HttpContextServiceFactory.class).setRequired(true))
-                
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
            
+                
.add(createServiceDependency().setService(HttpService.class).setRequired(true)));
     }
 
     @Override

Modified: 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/osgi/FSUserAdminStorageProviderActivator.java
==============================================================================
--- 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/osgi/FSUserAdminStorageProviderActivator.java
   (original)
+++ 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/osgi/FSUserAdminStorageProviderActivator.java
   Mon Jan 17 12:07:36 2011
@@ -30,15 +30,15 @@
 
 /**
  * This class represents the OSGi activator for the tenant service
- * 
+ *
  */
 public class FSUserAdminStorageProviderActivator extends 
DependencyActivatorBase {
 
     @Override
     public void init(BundleContext context, DependencyManager manager) throws 
Exception {
-        Dictionary<String, String> properties = new Hashtable<String, 
String>();
+        Dictionary<String, Object> properties = new Hashtable<String, 
Object>();
         properties.put(UserAdminConstants.STORAGEPROVIDER_TYPE, "FS");
-        properties.put("service.ranking", "0");
+        properties.put("service.ranking", 0);
         manager.add(
                 createComponent()
                     .setImplementation(new FSUserAdminStorageProvider())

Modified: 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigRegistrationServiceImpl.java
==============================================================================
--- 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigRegistrationServiceImpl.java
     (original)
+++ 
trunk/amdatu-opensocial/shindig/src/main/java/org/amdatu/opensocial/shindig/service/ShindigRegistrationServiceImpl.java
     Mon Jan 17 12:07:36 2011
@@ -52,7 +52,7 @@
 /**
  * This service is responsible for registration and unregistration of Shindig 
servlets, filters and static
  * resources.
- * 
+ *
  * @author ivol
  */
 public class ShindigRegistrationServiceImpl implements ShindigService, 
ResourceProvider {
@@ -89,7 +89,7 @@
      */
     public void init() {
         // Beware! The order in which httpcontext, Guice servlet and other 
services are created is very important!
-        
+
         // First of all copy the security token key, this is needed by the 
Guice injector
         copySecurityTokenKey();
 
@@ -198,9 +198,9 @@
             + REST_BASE + baseMatch + "|"
             + GADGETS_REST_BASE + baseMatch + "|"
             + GADGETS_RPC_BASE + baseMatch + ")";
-        Dictionary<String, String> properties = new Hashtable<String, 
String>();
+        Dictionary<String, Object> properties = new Hashtable<String, 
Object>();
         properties.put("pattern", regex);
-        properties.put("service.ranking", "0");
+        properties.put("service.ranking", 0);
         properties.put("contextId", this.getResourceId());
         Component component = m_dependencyManager.createComponent();
         component.setImplementation(AuthenticationServletFilter.class);

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        Mon Jan 17 12:07:36 2011
@@ -68,7 +68,7 @@
     private final static String TEST_HEADER_AFTER = "testFilterAfter";
     private final static String TEST_HEADER_AFTER_VALUE = "after";
     private final static String TEST_JSP_CONTENT = "<html><body>Test JSP 
body</body></html>";
-    
+
     private final static int TIMEOUT = 5000;
 
     private volatile LogService m_logService;
@@ -102,10 +102,10 @@
     @Override
     protected Component[] getDependencies(DependencyManager manager) {
         // We register a servlet filter (whiteboard-style) that adds a test 
header to each HTTP response
-        Dictionary<String, String> filterProperties = new Hashtable<String, 
String>();
+        Dictionary<String, Object> filterProperties = new Hashtable<String, 
Object>();
         filterProperties.put("pattern", ".*");
         filterProperties.put("contextId", SERVLET_ALIAS);
-        filterProperties.put("service.ranking", "0");
+        filterProperties.put("service.ranking", 0);
         Component filterComponent = manager.createComponent()
                 .setImplementation(new TestFilter())
                 .setInterface(new String[] {Filter.class.getName(), 
TestFilterInterface.class.getName()},
@@ -133,12 +133,12 @@
 
         return new Component[] { filterComponent, servletComponent, 
testComponent };
     }
-    
-    @Before 
+
+    @Before
     public void initConfig() throws IOException, BundleException {
        m_configAdmin = getService(ConfigurationAdmin.class);
        m_logService = getService(LogService.class);
-       
+
        // Add cassandra and templates configs
        ConfigProvider configProvider = new ConfigProvider();
        configProvider.addFelixHttpServiceConfig(m_configAdmin);
@@ -160,12 +160,12 @@
     @Test
     public void testFilter() throws Exception {
        initialize();
-       
+
        // Wait until the test servlet is available, for a maximum of 5 seconds
        String url = m_baseUrl + SERVLET_ALIAS;
        m_logService.log(LogService.LOG_DEBUG, "Start waiting for url '" + url 
+ "' to become available, timeout= " + TIMEOUT + "...");
         if (!ConfigProvider.waitForURL(new URL(url), HttpStatus.SC_OK, 
TIMEOUT)) {
-            // NB: Due to issue 
https://issues.apache.org/jira/browse/FELIX-2714 it may happen that the 
HttpService 
+            // NB: Due to issue 
https://issues.apache.org/jira/browse/FELIX-2714 it may happen that the 
HttpService
             // throws a connection refused, still listens to the default port 
8080 or returns a 404. Therefore we
             // retry once to connect to the default port 8080, if that fails 
we skip running this integration test
             // since it is likely that the reason that it fails is not caused 
by any Amdatu code.
@@ -182,7 +182,7 @@
         // Our filter should be registered, use httpclient to do a GET 
request. The filter should
         // set some response header and we check if this header has been set
         HttpClient httpClient = new HttpClient();
-        
+
         m_logService.log(LogService.LOG_DEBUG, "Testing filter bound to " + 
url);
         HttpMethod method = new GetMethod(url);
         try {
@@ -222,7 +222,7 @@
        String url = m_baseUrl + "/" + RESOURCE_ID + "/jsp/test.jsp";
        m_logService.log(LogService.LOG_DEBUG, "Start waiting for url '" + url 
+ "' to become available, timeout= " + TIMEOUT + "...");
         if (!ConfigProvider.waitForURL(new URL(url), HttpStatus.SC_OK, 
TIMEOUT)) {
-            // NB: Due to issue 
https://issues.apache.org/jira/browse/FELIX-2714 it may happen that the 
HttpService 
+            // NB: Due to issue 
https://issues.apache.org/jira/browse/FELIX-2714 it may happen that the 
HttpService
             // throws a connection refused, still listens to the default port 
8080 or returns a 404. Therefore we
             // retry once to connect to the default port 8080, if that fails 
we skip running this integration test
             // since it is likely that the reason that it fails is not caused 
by any Amdatu code.
@@ -231,7 +231,7 @@
                 return;
             }
         }
-        
+
        // Wait for two seconds such that the Felix whiteboard service has the 
time to receive the filter added
        // callback and register it. See 
http://jira.amdatu.org/jira/browse/AMDATU-189
        Thread.sleep(2000);

Reply via email to