incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r806575 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/test/java/org/apache/sling/osgi/installer/impl/ it/src...
Date Fri, 21 Aug 2009 14:45:25 GMT
Author: bdelacretaz
Date: Fri Aug 21 14:45:24 2009
New Revision: 806575

URL: http://svn.apache.org/viewvc?rev=806575&view=rev
Log:
SLING-1078 - code cleanup

Removed:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
Fri Aug 21 14:45:24 2009
@@ -125,17 +125,16 @@
         }
     }
     
+    /** Used for tasks that wait for a framework or bundle event before retrying their operations
*/
     public static long getTotalEventsCount() {
         return eventsCount;
     }
 
     public void frameworkEvent(FrameworkEvent arg0) {
-        // we'll retry as soon as any FrameworkEvent or BundleEvent happens
         eventsCount++;
     }
 
     public void bundleChanged(BundleEvent arg0) {
-        // we'll retry as soon as any FrameworkEvent or BundleEvent happens
         eventsCount++;
     }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
Fri Aug 21 14:45:24 2009
@@ -25,7 +25,6 @@
 import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask;
 import org.apache.sling.osgi.installer.impl.tasks.BundleRemoveTask;
 import org.apache.sling.osgi.installer.impl.tasks.BundleUpdateTask;
-import org.apache.sling.osgi.installer.impl.tasks.TaskUtilities;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
@@ -140,7 +139,7 @@
 
 	protected BundleInfo getBundleInfo(OsgiInstallerContext ctx, RegisteredResource bundle)
{
 		final String symbolicName = (String)bundle.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
-		final Bundle b = TaskUtilities.getMatchingBundle(ctx.getBundleContext(), symbolicName);
+		final Bundle b = ctx.getMatchingBundle(symbolicName);
 		if(b == null) {
 		    return null;
         }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
Fri Aug 21 14:45:24 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
@@ -25,13 +26,13 @@
 
 /** Installer context, gives access to selected methods of the {@link OsgiInstallerImpl}
*/
 public interface OsgiInstallerContext {
-	Storage getStorage();
 	BundleContext getBundleContext();
 	PackageAdmin getPackageAdmin();
 	ConfigurationAdmin getConfigurationAdmin();
 	LogService getLogService();
 	void incrementCounter(int index);
     void setCounter(int index, long value);
+    Bundle getMatchingBundle(String bundleSymbolicName);
 	
 	/** Schedule a task for execution in the current OsgiController cycle */
 	void addTaskToCurrentCycle(OsgiInstallerTask t);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
Fri Aug 21 14:45:24 2009
@@ -23,6 +23,7 @@
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -62,8 +63,6 @@
     }
 
 	public ConfigurationAdmin getConfigurationAdmin() {
-		// TODO ConfigurationAdmin should be bound/unbound rather than
-		// looking it up every time, but that caused problems in the it/OsgiControllerTest
 		if(bundleContext != null) {
 		   	final ServiceReference ref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
 		    if(ref != null) {
@@ -118,11 +117,6 @@
         }
 	}
 
-	public Storage getStorage() {
-		// TODO
-		return null;
-	}
-	
 	public void incrementCounter(int index) {
 	    counters[index]++;
 	}
@@ -130,4 +124,19 @@
     public void setCounter(int index, long value) {
         counters[index] = value;
     }
+    
+    /**
+     * Finds the bundle with given symbolic name in our BundleContext.
+     */
+    public Bundle getMatchingBundle(String bundleSymbolicName) {
+        if (bundleSymbolicName != null) {
+            Bundle[] bundles = bundleContext.getBundles();
+            for (Bundle bundle : bundles) {
+                if (bundleSymbolicName.equals(bundle.getSymbolicName())) {
+                    return bundle;
+                }
+            }
+        }
+        return null;
+    }
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java
Fri Aug 21 14:45:24 2009
@@ -69,6 +69,11 @@
     }
     
     @Override
+    public String toString() {
+        return getClass().getName() + ": " + resource;
+    }
+
+    @Override
     public boolean isExecutable(OsgiInstallerContext ctx) throws Exception {
         return ctx.getConfigurationAdmin() != null;
     }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
Fri Aug 21 14:45:24 2009
@@ -46,7 +46,7 @@
     public void execute(OsgiInstallerContext ctx) throws Exception {
         super.execute(ctx);
         final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
-        final Bundle b = TaskUtilities.getMatchingBundle(ctx.getBundleContext(), symbolicName);
+        final Bundle b = ctx.getMatchingBundle(symbolicName);
         if(b == null) {
             throw new IllegalStateException("Bundle to remove (" + symbolicName + ") not
found");
         }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
Fri Aug 21 14:45:24 2009
@@ -51,7 +51,7 @@
     public void execute(OsgiInstallerContext ctx) throws Exception {
         super.execute(ctx);
         final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME);
-        final Bundle b = TaskUtilities.getMatchingBundle(ctx.getBundleContext(), symbolicName);
+        final Bundle b = ctx.getMatchingBundle(symbolicName);
         if(b == null) {
             throw new IllegalStateException("Bundle to update (" + symbolicName + ") not
found");
         }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
Fri Aug 21 14:45:24 2009
@@ -26,9 +26,7 @@
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
 
-/** Install/remove task for configurations 
- *  TODO split into install / remove tasks and reimplement
- * */
+/** Install/remove task for configurations */ 
 public class ConfigInstallTask extends AbstractConfigTask {
 
     static final String ALIAS_KEY = "_alias_factory_pid";
@@ -45,11 +43,6 @@
     }
     
     @Override
-    public String toString() {
-        return getClass().getName() + ": " + resource;
-    }
-
-    @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
         super.execute(ctx);
         

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
Fri Aug 21 14:45:24 2009
@@ -41,11 +41,6 @@
     }
     
     @Override
-    public String toString() {
-        return getClass().getName() + ": " + resource;
-    }
-
-    @Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
         super.execute(ctx);
         

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java
Fri Aug 21 14:45:24 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
@@ -47,13 +48,13 @@
 		return null;
 	}
 
-	public Storage getStorage() {
-		return null;
-	}
-
     public void incrementCounter(int index) {
     }
     
     public void setCounter(int index, long value) {
     }
+
+    public Bundle getMatchingBundle(String bundleSymbolicName) {
+        return null;
+    }
 }

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java
Fri Aug 21 14:45:24 2009
@@ -30,12 +30,6 @@
         return result;
     }
     
-    static void setStorage(OsgiInstallerImpl c, Storage s) throws Exception {
-        final Field f = c.getClass().getDeclaredField("storage");
-        f.setAccessible(true);
-        f.set(c, s);
-    }
-    
     static void setField(Object o, String name, Object value) throws Exception {
         final Field f = o.getClass().getDeclaredField(name);
         f.setAccessible(true);

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java?rev=806575&r1=806574&r2=806575&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
(original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
Fri Aug 21 14:45:24 2009
@@ -53,13 +53,11 @@
         assertEquals("Exactly 3 OSGi tasks must have been executed after a few installer
cycles",
                 nOps + 3, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
 
-        // generate a bundle event -> must trigger just one retry
+        // generate a bundle event -> must trigger one retry
         resetCounters();
         generateBundleEvent();
         waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
-        sleep(1000L);
-        assertEquals("Exactly 5 OSGi tasks total must have been executed after bundle event
received",
-                nOps + 5, installer.getCounters()[OsgiInstaller.OSGI_TASKS_COUNTER]);
+        waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1);
     }
 
 }



Mime
View raw message