incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r984254 - 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/config/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/...
Date Tue, 10 Aug 2010 22:40:27 GMT
Author: cziegeler
Date: Tue Aug 10 22:40:27 2010
New Revision: 984254

URL: http://svn.apache.org/viewvc?rev=984254&view=rev
Log:
SLING-1560 : Move all config admin related stuff into config admin package, reduce usage of
installer context

Removed:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java
Modified:
    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/OsgiInstallerThread.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.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/BundleInstallTask.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/BundleStartTask.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/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -23,7 +23,6 @@ import java.io.IOException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
-import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.packageadmin.PackageAdmin;
 
 /**
@@ -41,11 +40,6 @@ public interface OsgiInstallerContext {
      */
     PackageAdmin getPackageAdmin();
 
-    /**
-     * Return the config admin.
-     */
-    ConfigurationAdmin getConfigurationAdmin();
-
     void incrementCounter(int index);
     void setCounter(int index, long value);
     /**

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -28,7 +28,6 @@ import org.apache.sling.osgi.installer.O
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
-import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
@@ -38,9 +37,6 @@ public class OsgiInstallerImpl implement
     /** Interface of the package admin */
     private static String PACKAGE_ADMIN_NAME = PackageAdmin.class.getName();
 
-    /** Interface of the config admin */
-    private static String CONFIG_ADMIN_SERVICE_NAME = ConfigurationAdmin.class.getName();
-
     public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
 
     /** The bundle context. */
@@ -55,9 +51,6 @@ public class OsgiInstallerImpl implement
     /** Tracker for the package admin. */
     private final ServiceTracker packageAdminTracker;
 
-    /** Tracker for the configuration admin. */
-    private final ServiceTracker configAdminServiceTracker;
-
     /**
      * Construct a new service
      */
@@ -66,9 +59,7 @@ public class OsgiInstallerImpl implement
         this.bundleContext = bc;
         // create and start tracker
         this.packageAdminTracker = new ServiceTracker(bc, PACKAGE_ADMIN_NAME, null);
-        this.configAdminServiceTracker = new ServiceTracker(bc, CONFIG_ADMIN_SERVICE_NAME,
null);
         this.packageAdminTracker.open();
-        this.configAdminServiceTracker.open();
 
         bundleDigestsStorage = new PersistentBundleInfo(bc.getDataFile("bundle-digests.properties"));
 
@@ -105,20 +96,12 @@ public class OsgiInstallerImpl implement
         }
 
         this.packageAdminTracker.close();
-        this.configAdminServiceTracker.close();
 
         Logger.logWarn(OsgiInstaller.class.getName()
                 + " service deactivated - this warning can be ignored if system is shutting
down");
     }
 
 	/**
-	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#getConfigurationAdmin()
-	 */
-	public ConfigurationAdmin getConfigurationAdmin() {
-	    return (ConfigurationAdmin)this.configAdminServiceTracker.getService();
-	}
-
-	/**
 	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#addTaskToCurrentCycle(org.apache.sling.osgi.installer.impl.OsgiInstallerTask)
 	 */
 	public void addTaskToCurrentCycle(OsgiInstallerTask t) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Tue Aug 10 22:40:27 2010
@@ -63,9 +63,10 @@ class OsgiInstallerThread extends Thread
     private final PersistentResourceList persistentList;
 
     private final BundleTaskCreator bundleTaskCreator = new BundleTaskCreator();
-    private final ConfigTaskCreator configTaskCreator = new ConfigTaskCreator();
+    private final ConfigTaskCreator configTaskCreator;
 
-    OsgiInstallerThread(OsgiInstallerContext ctx) {
+    OsgiInstallerThread(final OsgiInstallerContext ctx) {
+        this.configTaskCreator = new ConfigTaskCreator(ctx.getBundleContext());
         setName(getClass().getSimpleName());
         this.ctx = ctx;
         final File f = ctx.getBundleContext().getDataFile("RegisteredResourceList.ser");
@@ -74,6 +75,7 @@ class OsgiInstallerThread extends Thread
     }
 
     void deactivate() {
+        this.configTaskCreator.deactivate();
         ctx.getBundleContext().removeBundleListener(this);
         active = false;
         synchronized (newResources) {
@@ -150,7 +152,7 @@ class OsgiInstallerThread extends Thread
     void addNewResource(final InstallableResource r, final String scheme) {
         RegisteredResource rr = null;
         try {
-            rr = new RegisteredResourceImpl(ctx, r, scheme);
+            rr = new RegisteredResourceImpl(ctx.getBundleContext(), r, scheme);
         } catch(IOException ioe) {
             Logger.logWarn("Cannot create RegisteredResource (resource will be ignored):"
+ r, ioe);
             return;
@@ -171,7 +173,7 @@ class OsgiInstallerThread extends Thread
         for(InstallableResource r : data) {
             RegisteredResource rr =  null;
             try {
-                rr = new RegisteredResourceImpl(ctx, r, urlScheme);
+                rr = new RegisteredResourceImpl(ctx.getBundleContext(), r, urlScheme);
             } catch(IOException ioe) {
                 Logger.logWarn("Cannot create RegisteredResource (resource will be ignored):"
+ r, ioe);
                 continue;

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
Tue Aug 10 22:40:27 2010
@@ -66,7 +66,7 @@ public class RegisteredResourceImpl impl
 	 *  maps to a configuration and the data provides an input stream, it is
 	 *  converted to a Dictionary
 	 */
-	public RegisteredResourceImpl(final OsgiInstallerContext osgiCtx,
+	public RegisteredResourceImpl(final BundleContext ctx,
 	        final InstallableResource input,
 	        final String scheme) throws IOException {
         if ( scheme == null || scheme.length() == 0 ) {
@@ -75,7 +75,6 @@ public class RegisteredResourceImpl impl
         if ( scheme.indexOf(':') != -1 ) {
             throw new IllegalArgumentException("Scheme must not contain a colon");
         }
-	    final BundleContext ctx = osgiCtx.getBundleContext();
 		url = scheme + ':' + input.getId();
 		urlScheme = scheme;
 		resourceType = input.getType();

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/config/ConfigTaskCreator.java
Tue Aug 10 22:40:27 2010
@@ -28,13 +28,30 @@ import org.apache.sling.osgi.installer.i
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallTask;
 import org.apache.sling.osgi.installer.impl.tasks.ConfigRemoveTask;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 
 /** TaskCreator that processes a list of config RegisteredResources */
 public class ConfigTaskCreator {
 
+    /** Interface of the config admin */
+    private static String CONFIG_ADMIN_SERVICE_NAME = ConfigurationAdmin.class.getName();
+
     /** Store digests of the installed configs, keyed by config pid */
     private final Map<String, String> digests = new HashMap<String, String>();
 
+    private final ServiceTracker configAdminServiceTracker;
+
+    public ConfigTaskCreator(final BundleContext bc) {
+        this.configAdminServiceTracker = new ServiceTracker(bc, CONFIG_ADMIN_SERVICE_NAME,
null);
+        this.configAdminServiceTracker.open();
+    }
+
+    public void deactivate() {
+        this.configAdminServiceTracker.close();
+    }
+
 	/** Create tasks for a set of RegisteredResource that all represent the same config PID.
 	 */
 	public void createTasks(OsgiInstallerContext ctx, SortedSet<RegisteredResource> resources,
SortedSet<OsgiInstallerTask> tasks) {
@@ -53,7 +70,7 @@ public class ConfigTaskCreator {
 		    // None of our resources are installable, remove corresponding config
 		    // (task simply does nothing if config does not exist)
 		    final RegisteredResource first = resources.first();
-		    tasks.add(new ConfigRemoveTask(first));
+		    tasks.add(new ConfigRemoveTask(first, this.configAdminServiceTracker));
 		    digests.remove(getDigestKey(first));
 		} else {
 		    final String key = getDigestKey(toActivate);
@@ -61,7 +78,7 @@ public class ConfigTaskCreator {
 		    if(toActivate.getDigest().equals(previousDigest)) {
 		        Logger.logDebug("Configuration (" + key+ ") already installed, ignored: " + toActivate);
 		    } else {
-		        tasks.add(new ConfigInstallTask(toActivate));
+		        tasks.add(new ConfigInstallTask(toActivate, this.configAdminServiceTracker));
 		        digests.put(key, toActivate.getDigest());
 		        Logger.logDebug("Scheduling update/install of config " + toActivate + ", digest
has changed or was absent");
 		    }

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -27,22 +27,33 @@ import org.apache.sling.osgi.installer.i
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 
 /** Base class for configuration-related tasks */
 abstract class AbstractConfigTask extends OsgiInstallerTask {
 
     protected final ConfigurationPid pid;
     protected final RegisteredResource resource;
-    
-    AbstractConfigTask(RegisteredResource r) {
+
+    private final ServiceTracker configAdminServiceTracker;
+    AbstractConfigTask(final RegisteredResource r, final ServiceTracker configAdminServiceTracker)
{
+        this.configAdminServiceTracker = configAdminServiceTracker;
         resource = r;
         pid = (ConfigurationPid)r.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE);
         if(pid == null) {
             throw new IllegalArgumentException("RegisteredResource does not have CONFIG_PID_ATTRIBUTE:
" + r);
         }
     }
-    
-    protected Configuration getConfiguration(ConfigurationAdmin ca, 
+
+    /**
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#getConfigurationAdmin()
+     */
+    protected ConfigurationAdmin getConfigurationAdmin() {
+        return (ConfigurationAdmin)this.configAdminServiceTracker.getService();
+    }
+
+
+    protected Configuration getConfiguration(ConfigurationAdmin ca,
             ConfigurationPid cp, boolean createIfNeeded, OsgiInstallerContext ocs)
     throws IOException, InvalidSyntaxException
     {
@@ -67,7 +78,7 @@ abstract class AbstractConfigTask extend
 
         return result;
     }
-    
+
     @Override
     public String toString() {
         return getClass().getName() + ": " + resource;
@@ -75,6 +86,6 @@ abstract class AbstractConfigTask extend
 
     @Override
     public boolean isExecutable(OsgiInstallerContext ctx) throws Exception {
-        return ctx.getConfigurationAdmin() != null;
+        return this.getConfigurationAdmin() != null;
     }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
Tue Aug 10 22:40:27 2010
@@ -30,6 +30,8 @@ import org.osgi.framework.Version;
  *  Creates a BundleStartTask to start the bundle */
 public class BundleInstallTask extends OsgiInstallerTask {
 
+    private static final String BUNDLE_INSTALL_ORDER = "50-";
+
     private final RegisteredResource resource;
 
     public BundleInstallTask(RegisteredResource r) {
@@ -52,7 +54,7 @@ public class BundleInstallTask extends O
 
     @Override
     public String getSortKey() {
-        return TaskOrder.BUNDLE_INSTALL_ORDER + resource.getUrl();
+        return BUNDLE_INSTALL_ORDER + resource.getUrl();
     }
 
 }

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -31,6 +31,8 @@ import org.osgi.framework.Constants;
  */
 public class BundleRemoveTask extends OsgiInstallerTask {
 
+    private static final String BUNDLE_REMOVE_ORDER = "30-";
+
     private final RegisteredResource resource;
 
     public BundleRemoveTask(RegisteredResource r) {
@@ -61,7 +63,7 @@ public class BundleRemoveTask extends Os
 
     @Override
     public String getSortKey() {
-        return TaskOrder.BUNDLE_REMOVE_ORDER + resource.getUrl();
+        return BUNDLE_REMOVE_ORDER + resource.getUrl();
     }
 
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
Tue Aug 10 22:40:27 2010
@@ -35,14 +35,16 @@ import org.osgi.framework.BundleExceptio
  */
 public class BundleStartTask extends OsgiInstallerTask {
 
-	private final long bundleId;
+    private static final String BUNDLE_START_ORDER = "70-";
+
+    private final long bundleId;
 	private final String sortKey;
 	private long eventsCountForRetrying;
 	private int retryCount = 0;
 
 	public BundleStartTask(long bundleId) {
 		this.bundleId = bundleId;
-		sortKey = TaskOrder.BUNDLE_START_ORDER + new DecimalFormat("00000").format(bundleId);
+		sortKey = BUNDLE_START_ORDER + new DecimalFormat("00000").format(bundleId);
 	}
 
 	@Override

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -35,6 +35,8 @@ import org.osgi.framework.Version;
  */
 public class BundleUpdateTask extends OsgiInstallerTask {
 
+    private static final String BUNDLE_UPDATE_ORDER = "40-";
+
     private final RegisteredResource resource;
     private boolean canRetry = true;
 
@@ -108,7 +110,7 @@ public class BundleUpdateTask extends Os
 
     @Override
     public String getSortKey() {
-        return TaskOrder.BUNDLE_UPDATE_ORDER + resource.getUrl();
+        return BUNDLE_UPDATE_ORDER + resource.getUrl();
     }
 
 }
\ No newline at end of file

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -30,10 +30,13 @@ import org.apache.sling.osgi.installer.i
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 
 /** Install/remove task for configurations */
 public class ConfigInstallTask extends AbstractConfigTask {
 
+    private static final String CONFIG_INSTALL_ORDER = "20-";
+
     static final String ALIAS_KEY = "_alias_factory_pid";
     static final String CONFIG_PATH_KEY = "_jcr_config_path";
     public static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" };
@@ -45,20 +48,20 @@ public class ConfigInstallTask extends A
     	ignoredProperties.add(CONFIG_PATH_KEY);
     }
 
-    public ConfigInstallTask(RegisteredResource r) {
-        super(r);
+    public ConfigInstallTask(final RegisteredResource r, final ServiceTracker configAdminServiceTracker)
{
+        super(r, configAdminServiceTracker);
     }
 
     @Override
     public String getSortKey() {
-        return TaskOrder.CONFIG_INSTALL_ORDER + pid.getCompositePid();
+        return CONFIG_INSTALL_ORDER + pid.getCompositePid();
     }
 
     @SuppressWarnings("unchecked")
 	@Override
     public void execute(OsgiInstallerContext ctx) throws Exception {
 
-        final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
+        final ConfigurationAdmin ca = this.getConfigurationAdmin();
         if(ca == null) {
             ctx.addTaskToNextCycle(this);
             Logger.logDebug("ConfigurationAdmin not available, task will be retried later:
" + this);

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=984254&r1=984253&r2=984254&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
Tue Aug 10 22:40:27 2010
@@ -23,26 +23,29 @@ import org.apache.sling.osgi.installer.i
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 
 /** Remove a Configuration */
- public class ConfigRemoveTask extends AbstractConfigTask {
+public class ConfigRemoveTask extends AbstractConfigTask {
+
+    private static final String CONFIG_REMOVE_ORDER = "10-";
 
     static final String ALIAS_KEY = "_alias_factory_pid";
     static final String CONFIG_PATH_KEY = "_jcr_config_path";
     public static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" };
 
-    public ConfigRemoveTask(RegisteredResource r) {
-        super(r);
+    public ConfigRemoveTask(final RegisteredResource r, final ServiceTracker configAdminServiceTracker)
{
+        super(r, configAdminServiceTracker);
     }
 
     @Override
     public String getSortKey() {
-        return TaskOrder.CONFIG_REMOVE_ORDER + pid.getCompositePid();
+        return CONFIG_REMOVE_ORDER + pid.getCompositePid();
     }
 
     public void execute(OsgiInstallerContext ctx) throws Exception {
 
-        final ConfigurationAdmin ca = ctx.getConfigurationAdmin();
+        final ConfigurationAdmin ca = this.getConfigurationAdmin();
         if(ca == null) {
             ctx.addTaskToNextCycle(this);
             Logger.logDebug("ConfigurationAdmin not available, task will be retried later:
" + this);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java
Tue Aug 10 22:40:27 2010
@@ -28,6 +28,8 @@ import org.osgi.framework.FrameworkListe
 /** Execute an OSGi "refresh packages" operation, synchronously */
 public class SynchronousRefreshPackagesTask extends OsgiInstallerTask implements FrameworkListener
{
 
+    private static final String REFRESH_PACKAGES_ORDER = "60-";
+
     /** Max time allowed to refresh packages (TODO configurable??) */
     public static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
 
@@ -49,7 +51,7 @@ public class SynchronousRefreshPackagesT
 
 	@Override
 	public String getSortKey() {
-		return TaskOrder.REFRESH_PACKAGES_ORDER;
+		return REFRESH_PACKAGES_ORDER;
 	}
 
 	@Override

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java
Tue Aug 10 22:40:27 2010
@@ -29,7 +29,7 @@ class LocalFileRegisteredResource extend
 	private File storage;
 
 	LocalFileRegisteredResource(InstallableResource r) throws IOException {
-		super(new MockOsgiInstallerContext(), r, "test");
+		super(null, r, "test");
 	}
 
 	@Override

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
Tue Aug 10 22:40:27 2010
@@ -52,7 +52,7 @@ public class RegisteredResourceComparato
             data.put("foo", "bar");
         }
         final InstallableResource r = factory.create(url, null, data, null, null, priority);
-        return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r, "test");
+        return new RegisteredResourceImpl(null, r, "test");
     }
 
     private void assertOrder(RegisteredResource[] inOrder) {

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
Tue Aug 10 22:40:27 2010
@@ -128,7 +128,7 @@ public class RegisteredResourceTest {
         };
         for(String url : badOnes) {
             try {
-                new RegisteredResourceImpl(new MockOsgiInstallerContext(),
+                new RegisteredResourceImpl(null,
                         factory.create("test", null, new Hashtable<String, Object>(),
null, null, null),
                         url);
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
@@ -141,7 +141,7 @@ public class RegisteredResourceTest {
         };
 
         for(String url : goodOnes) {
-            final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),
+            final RegisteredResource r = new RegisteredResourceImpl(null,
                     factory.create("test", null, new Hashtable<String, Object>(), "digest1",
null, null),
                     url);
             assertEquals("Expected scheme '" + url + "' for URL " + url, url, r.getUrlScheme());

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
(original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
Tue Aug 10 22:40:27 2010
@@ -51,7 +51,7 @@ public class TaskOrderingTest {
 	}
 
 	private static RegisteredResource getRegisteredResource(String url) throws IOException {
-		return new RegisteredResourceImpl(new MockOsgiInstallerContext(),
+		return new RegisteredResourceImpl(null,
 		        factory.create(url, null, new Hashtable<String, Object>(), null, null, null),
 		        "test");
 	}
@@ -70,8 +70,8 @@ public class TaskOrderingTest {
 	public void testBasicOrdering() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
-		    new ConfigRemoveTask(getRegisteredResource("test:a")),
-            new ConfigInstallTask(getRegisteredResource("test:a")),
+		    new ConfigRemoveTask(getRegisteredResource("test:a"), null),
+            new ConfigInstallTask(getRegisteredResource("test:a"), null),
 		    new BundleRemoveTask(getRegisteredResource("test:url")),
 		    new BundleUpdateTask(getRegisteredResource("test:url")),
 		    new BundleInstallTask(getRegisteredResource("test:url")),

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java?rev=984254&r1=984253&r2=984254&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
(original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
Tue Aug 10 22:40:27 2010
@@ -125,10 +125,8 @@ class OsgiInstallerTestBase implements F
                 sleep(10L);
             }
         } finally {
-            if(is != null) {
-                is.close();
-            }
-            if(b != null) {
+            is.close();
+            if (b != null) {
                 b.uninstall();
             }
         }
@@ -219,10 +217,7 @@ class OsgiInstallerTestBase implements F
         final long end = System.currentTimeMillis() + timeoutMsec;
         do {
             result = findConfiguration(pid);
-            if(result != null) {
-                break;
-            }
-            if(!shouldBePresent && result == null) {
+            if (result != null ||!shouldBePresent) {
                 break;
             }
             sleep(25);



Mime
View raw message