incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r803922 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer/impl/tasks/ test/java/org/apache/sling/osgi/install...
Date Thu, 13 Aug 2009 15:10:06 GMT
Author: bdelacretaz
Date: Thu Aug 13 15:10:05 2009
New Revision: 803922

URL: http://svn.apache.org/viewvc?rev=803922&view=rev
Log:
SLING-1078 - controller interface reworked, unit tests pass but not usable yet

Added:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
      - copied, changed from r803805, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableData.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java
      - copied, changed from r803805, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTaskContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java   (with props)
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.java
      - copied, changed from r803805, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java
      - copied, changed from r803805, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/DigestTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java   (with props)
Removed:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DictionaryInstallableData.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableData.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerStatistics.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/ResourceOverrideRules.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableDataWrapper.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTaskContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReader.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/DigestTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockInstallableData.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java
Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java
    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/OsgiControllerImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java
    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/BundleInstallRemoveTask.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/ConfigInstallRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.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
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java

Copied: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (from r803805, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableData.java)
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?p2=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java&p1=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableData.java&r1=803805&r2=803922&rev=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableData.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Thu Aug 13 15:10:05 2009
@@ -18,23 +18,75 @@
  */
 package org.apache.sling.osgi.installer;
 
-/** A piece of data that can be installed by
- * 	the OSGi controller.
+import java.io.InputStream;
+import java.util.Dictionary;
+
+/** A piece of data that can be installed by the OSGi controller.
+ * 	Wraps either a Dictionary or an InputStream.
+ *  Extension is used to decide which type of data (bundle, config, etc.). 
  */
-public interface InstallableData {
-	/** String that must change if the underlying data
-	 * 	changes. Stored by the OsgiController when installing
-	 * 	the data, meant to be used by the OsgiController client
-	 * 	when deciding if the data needs to be updated.
-	 */
-	String getDigest();
+public class InstallableResource {
+	private final String url;
+	private final String extension;
+	private final InputStream inputStream;
+	private final Dictionary<String, Object> dictionary;
+	
+	/** Create an empty data object, used when removing resources */
+	public InstallableResource(String url) {
+		this.url = url;
+		this.extension = getExtension(url);
+		this.inputStream = null;
+		this.dictionary = null;
+	}
+	
+	/** Create a data object that wraps an InputStream */
+	public InstallableResource(String url, InputStream is) {
+		this.url = url;
+		this.extension = getExtension(url);
+		this.inputStream = is;
+		this.dictionary = null;
+	}
+	
+	/** Create a data object that wraps a Dictionary */
+	public InstallableResource(String url, Dictionary<String, Object> d) {
+		this.url = url;
+		this.extension = getExtension(url);
+		this.inputStream = null;
+		this.dictionary = d;
+	}
+
+	@Override
+	public String toString() {
+		return getClass().getSimpleName() + ", url=" + url;
+	}
 	
-	/** Adapt the underlying data to the provided type.
-	 *	@return null if cannot be adapted */
-	<AdapterType> AdapterType adaptTo(Class<AdapterType> type);
+	/** Compute the extension */ 
+	private static String getExtension(String url) {
+		final int pos = url.lastIndexOf('.');
+		return (pos < 0 ? "" : url.substring(pos+1));
+	}
 	
-	/** If data to install is a Bundle, this is the start level
-	 *  to use when installing it.
+	/** Return this data's URL. It is opaque for the {@link OsgiController}
+	 * 	but the scheme must be the one used in the 
+	 * 	{@link OsgiController#registerResources} call.
 	 */
-	int getBundleStartLevel();
+	public String getURL() {
+		return url;
+	}
+
+	public String getUrl() {
+		return url;
+	}
+
+	public String getExtension() {
+		return extension;
+	}
+
+	public InputStream getInputStream() {
+		return inputStream;
+	}
+
+	public Dictionary<String, Object> getDictionary() {
+		return dictionary;
+	}
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java Thu Aug 13 15:10:05 2009
@@ -19,43 +19,41 @@
 package org.apache.sling.osgi.installer;
 
 import java.io.IOException;
-import java.util.Set;
+import java.util.Collection;
+import java.util.Map;
 
-/** jcrinstall component that installs/updates/removes
- *  OSGi resources (bundles, deployment packages, configs)
- *  in the OSGi framework.
+/** Controller that installs/updates/removes InstallableData
+ * 	in the OSGi framework. The client can register a number of such
+ *  resources, and the controller decides based on the resource weights,
+ *	bundle version numbers, etc. which ones are actually installed.
+ *
+ *	An InstallableResource can be a bundle, a configuration, and later 
+ *	we might support deployment packages as well.    	
  */
 public interface OsgiController {
-
-    /** Schedule installation or update of supplied resource
-     *  @param uri Unique identifier for the resource
-     *  @param data The data to install
-     */
-    void scheduleInstallOrUpdate(String uri, InstallableData data) throws IOException;
-
-    /** Schedule uninstallation of resource that was installed via given uri.
-     *  Might be called several times for the same URI - needless calls should
-     *  be ignored.
-     *  @param uri Unique identifier for the resource
-     *  @param attributes metadata stored by the OsgiController, will be
-     *      removed after calling this method
-     */
-    void scheduleUninstall(String uri) throws IOException;
-
-    /** Return the list of uri for resources that have been installed
-     *  by this controller.
-     */
-    Set<String> getInstalledUris();
-
-    /** Get the lastModified value for given uri, assuming the resource pointed
-     *  to by that uri was installed.
-     *  @return -1 if we don't have info for given uri
-     */
-    String getDigest(String uri);
-
-    /** Optionally set ResourceOverrideRules */
-    void setResourceOverrideRules(ResourceOverrideRules r);
-
-    /** Do the actual installs/uninistalls which were scheduled by the other methods */
-    void executeScheduledOperations() throws Exception;
+	
+	/** Provide the controller with the complete list of installable
+	 * 	resources for a given client.
+	 * 
+	 * 	Client must call this at startup and/or when the controller 
+	 * 	service becomes available. The controller stores the list of
+	 * 	previously registered/added resources, compares with the new
+	 * 	list and removes resources that have disappeared.
+	 * 
+	 * 	@param data the list of available resources
+	 * 	@param urlScheme identifies the client. All URLs of the supplied data
+	 * 		must use this scheme
+	 */
+	void registerResources(Collection<InstallableResource> data, String urlScheme) throws IOException;
+	
+	/** Inform the controller that a resource is available for installation.
+	 * 	also called if the resource has been modified since it was registered.
+	 */
+	void addResource(InstallableResource d) throws IOException;
+	
+	/** Inform the controller that a resource is no longer available */
+	void removeResource(InstallableResource d) throws IOException;
+	
+	/** Return counters used for statistics, console display, testing, etc. */
+	Map<String, Long> getCounters();
 }

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=803922&r1=803921&r2=803922&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 Thu Aug 13 15:10:05 2009
@@ -21,7 +21,6 @@
 import java.util.Hashtable;
 
 import org.apache.sling.osgi.installer.OsgiController;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -76,8 +75,7 @@
                     (PackageAdmin)checkNotNull(this.packageAdminTracker.getService(), "PackageAdmin"),
                     logServiceTracker);
             final String [] serviceInterfaces = {
-                    OsgiController.class.getName(),
-                    OsgiControllerServices.class.getName()
+                    OsgiController.class.getName()
             };
             osgiControllerServiceReg = context.registerService(serviceInterfaces, osgiControllerService, props);
         }

Copied: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java (from r803805, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTaskContext.java)
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java?p2=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java&p1=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTaskContext.java&r1=803805&r2=803922&rev=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTaskContext.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java Thu Aug 13 15:10:05 2009
@@ -18,18 +18,18 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
-import org.apache.sling.osgi.installer.OsgiControllerServices;
-import org.apache.sling.osgi.installer.ResourceOverrideRules;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 
 /** Context for OsgiControllerTask */
-public interface OsgiControllerTaskContext {
-	ResourceOverrideRules getResourceOverrideRules();
+public interface OsgiControllerContext {
 	Storage getStorage();
 	BundleContext getBundleContext();
 	PackageAdmin getPackageAdmin();
-	OsgiControllerServices getOsgiControllerServices();
+	ConfigurationAdmin getConfigurationAdmin();
+	LogService getLogService();
 	
 	/** Schedule a task for execution in the current OsgiController cycle */
 	void addTaskToCurrentCycle(OsgiControllerTask t);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Thu Aug 13 15:10:05 2009
@@ -19,19 +19,12 @@
 package org.apache.sling.osgi.installer.impl;
 
 import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 
-import org.apache.sling.osgi.installer.InstallableData;
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiController;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
-import org.apache.sling.osgi.installer.OsgiControllerStatistics;
-import org.apache.sling.osgi.installer.ResourceOverrideRules;
-import org.apache.sling.osgi.installer.impl.tasks.BundleInstallRemoveTask;
-import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallRemoveTask;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -39,37 +32,13 @@
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
-/**
- * OsgiController service
- *
- */
-public class OsgiControllerImpl
-    implements OsgiController,
-               OsgiControllerServices,
-               OsgiControllerTaskContext,
-               OsgiControllerStatistics {
+/** OsgiController service */
+public class OsgiControllerImpl implements OsgiController, OsgiControllerContext {
 
 	private final BundleContext bundleContext;
-    private final Storage storage;
-    private ResourceOverrideRules roRules;
-    
-    // The data type of the "tasks" member must be consistent with the {@link TaskOrderingTest} class
-    private final Set<OsgiControllerTask> tasks = new TreeSet<OsgiControllerTask>();
-    private final Set<OsgiControllerTask> tasksForNextCycle = new TreeSet<OsgiControllerTask>();
-    private final Set<OsgiControllerTask> tasksForThisCycle = new TreeSet<OsgiControllerTask>();
-    private final ServiceTracker logServiceTracker;
-    private int threadCounter;
     private final PackageAdmin packageAdmin;
-    private int executedTasksCount;
-
-    public static final String BUNDLE_EXTENSION = ".jar";
-    public static final String STORAGE_FILENAME = "controller.storage";
-
-    /** Storage key: digest of an InstallableData */
-    public static final String KEY_DIGEST = "data.digest";
-
-    /** Default value for getLastModified() */
-    public static final long LAST_MODIFIED_NOT_FOUND = -1;
+    private final ServiceTracker logServiceTracker;
+    private Map<String, Long> counters = new HashMap<String, Long>();
 
     public OsgiControllerImpl(final BundleContext bc,
                               final PackageAdmin pa,
@@ -78,170 +47,14 @@
         this.bundleContext = bc;
         this.packageAdmin = pa;
         this.logServiceTracker = logServiceTracker;
-        storage = new Storage(bc.getDataFile(STORAGE_FILENAME), this);
     }
 
     public void deactivate() {
-        try {
-            storage.saveToFile();
-        } catch(IOException ioe) {
-        	if (getLogService() != null) {
-        		getLogService().log(LogService.LOG_WARNING, "IOException in Storage.saveToFile()", ioe);
-        	}
-        }
-
         if(getLogService() != null) {
             getLogService().log(LogService.LOG_WARNING,
                     OsgiController.class.getName()
                     + " service deactivated - this warning can be ignored if system is shutting down");
         }
-
-    }
-
-    public void scheduleInstallOrUpdate(String uri, InstallableData data) throws IOException {
-    	synchronized (tasks) {
-        	tasks.add(getTaskForUri(uri, data));
-		}
-    }
-
-    public void scheduleUninstall(String uri) throws IOException {
-    	synchronized (tasks) {
-        	tasks.add(getTaskForUri(uri, null));
-    	}
-    }
-    
-    protected OsgiControllerTask getTaskForUri(String uri, InstallableData data) {
-        if(uri.endsWith(BUNDLE_EXTENSION)) {
-        	return new BundleInstallRemoveTask(uri, data, bundleContext, this);
-        } else {
-        	return new ConfigInstallRemoveTask(uri, data, this);
-        }
-    }
-
-    public Set<String> getInstalledUris() {
-        return storage.getKeys();
-    }
-
-    /** {@inheritDoc}
-     *  @return null if uri not found
-     */
-    public String getDigest(String uri) {
-        String result = null;
-
-        if(storage.contains(uri)) {
-            final Map<String, Object> uriData = storage.getMap(uri);
-            result = (String)uriData.get(KEY_DIGEST);
-        }
-        return result;
-    }
-
-    public static String getResourceLocation(String uri) {
-        return "jcrinstall://" + uri;
-    }
-
-    /** {@inheritDoc} */
-    public void executeScheduledOperations() throws Exception {
-
-        // Anything to do?
-        if(tasks.isEmpty()) {
-        	return;
-        }
-        
-        // No executable tasks?
-        boolean exec = false;
-        synchronized (tasks) {
-            for(OsgiControllerTask t : tasks) {
-                if(t.isExecutable(this)) {
-                    exec = true;
-                    break;
-                }
-            }
-        }
-        
-    	if(getLogService() != null) {
-    	    if(exec) {
-                getLogService().log(LogService.LOG_INFO, "executeScheduledOperations() starts");
-    	    } else {
-                getLogService().log(LogService.LOG_DEBUG, "No executable tasks, nothing to do");
-    	    }
-    	}
-    	
-    	if(!exec) {
-    	    return;
-    	}
-    	
-        synchronized (tasks) {
-        	if(getLogService() != null) {
-                getLogService().log(LogService.LOG_INFO, "Executing " + tasks.size() 
-                		+ " queued tasks (more might be created during execution cycle)");
-        	}
-            final long start = System.currentTimeMillis();
-            
-            // Now execute all our tasks in a separate thread
-        	// and re-add tasks scheduled for next cycle
-        	executeTasksInSeparateThread();
-        	tasks.clear();
-        	tasks.addAll(tasksForNextCycle);
-        	tasksForNextCycle.clear();
-
-        	if(getLogService() != null) {
-                getLogService().log(LogService.LOG_INFO,
-                		"executeScheduledOperations() ends (" + (System.currentTimeMillis() - start) + " msec)");
-        	}
-		}
-	}
-    
-    /** Execute a single task - meant to be called from worker thread */
-    private void executeTask(OsgiControllerTask t) {
-    	final long start = System.currentTimeMillis();
-    	final LogService log = getLogService();
-    	if(log != null) {
-    		log.log(LogService.LOG_DEBUG, "Executing task " + t);
-    	}
-    	
-    	try {
-    		t.execute(this);
-    		if(log != null) {
-    			final long delta = System.currentTimeMillis() - start;
-    			log.log(LogService.LOG_INFO, "Successfully executed " + t + " in " + delta + " msec");
-    		}
-    	} catch(Throwable th) {
-    		if(log != null) {
-    			log.log(LogService.LOG_INFO, "Task execution failed (" + th + ") will retry " + t);
-    		}
-    		tasksForNextCycle.add(t);
-    	}
-    }
-    
-    void executeTasksInSeparateThread() throws InterruptedException {
-		final Runnable r = new Runnable() {
-			public void run() {
-				while(!tasks.isEmpty()) {
-					final List<OsgiControllerTask> toRemove = new LinkedList<OsgiControllerTask>();
-					for(OsgiControllerTask t : tasks) {
-						toRemove.add(t);
-						executedTasksCount++;
-						executeTask(t);
-						if(!tasksForThisCycle.isEmpty()) {
-							break;
-						}
-					}
-					tasks.removeAll(toRemove);
-					tasks.addAll(tasksForThisCycle);
-					tasksForThisCycle.clear();
-				}
-			}
-		};
-		
-		final String threadName = getClass().getSimpleName() + " #" + (++threadCounter);
-		final Thread t = new Thread(r, threadName);
-		t.setDaemon(true);
-		t.start();
-		t.join();
-    }
-
-	public void setResourceOverrideRules(ResourceOverrideRules r) {
-        roRules = r;
     }
 
 	public ConfigurationAdmin getConfigurationAdmin() {
@@ -256,14 +69,6 @@
 		return null;
 	}
 
-	public ResourceOverrideRules getResourceOverrideRules() {
-		return roRules;
-	}
-
-	public Storage getStorage() {
-		return storage;
-	}
-	
 	public LogService getLogService() {
 		return (LogService)logServiceTracker.getService();
 	}
@@ -272,14 +77,16 @@
 		if(getLogService() != null) {
 			getLogService().log(LogService.LOG_DEBUG, "adding task to current cycle:" + t);
 		}
-		tasksForThisCycle.add(t);
+		// TODO
+		//tasksForThisCycle.add(t);
 	}
 
 	public void addTaskToNextCycle(OsgiControllerTask t) {
 		if(getLogService() != null) {
 			getLogService().log(LogService.LOG_DEBUG, "adding task to next cycle:" + t);
 		}
-		tasksForNextCycle.add(t);
+		// TODO
+		//tasksForNextCycle.add(t);
 	}
 
 	public BundleContext getBundleContext() {
@@ -290,11 +97,25 @@
 		return packageAdmin;
 	}
 	
-	public OsgiControllerServices getOsgiControllerServices() {
-		return this;
+	public Map<String, Long> getCounters() {
+		return counters;
 	}
 
-	public long getExecutedTasksCount() {
-	    return executedTasksCount;
+	public void addResource(InstallableResource d) throws IOException {
+		// TODO
+	}
+
+	public void registerResources(Collection<InstallableResource> data,
+			String urlScheme) throws IOException {
+		// TODO
+	}
+
+	public void removeResource(InstallableResource d) throws IOException {
+		// TODO
+	}
+
+	public Storage getStorage() {
+		// TODO
+		return null;
 	}
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java Thu Aug 13 15:10:05 2009
@@ -21,7 +21,7 @@
 /** Base class for tasks that can be executed by the OsgiController */ 
 public abstract class OsgiControllerTask implements Comparable<OsgiControllerTask> {
 	/** Execute this task */
-	public abstract void execute(OsgiControllerTaskContext ctx) throws Exception;
+	public abstract void execute(OsgiControllerContext ctx) throws Exception;
 	
 	/** Tasks are sorted according to this key */
 	public abstract String getSortKey();
@@ -32,7 +32,7 @@
 	}
 	
 	/** Is it worth executing this task now? */
-	public boolean isExecutable(OsgiControllerTaskContext ctx) throws Exception {
+	public boolean isExecutable(OsgiControllerContext ctx) throws Exception {
 	    return true;
 	}
 

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=803922&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Thu Aug 13 15:10:05 2009
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.osgi.installer.impl;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyConverter;
+import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyValue;
+import org.osgi.framework.BundleContext;
+
+/** A resource that's been registered in the OSGi controller.
+ * 	Data can be either an InputStream or a Dictionary, and we store
+ *  it locally to avoid holding up to classes or data from our 
+ *  clients, in case those disappear while we're installing stuff. 
+ */
+public class RegisteredResource {
+	private final String url;
+	private final String digest;
+	private final File dataFile;
+	private final Dictionary<String, Object> dictionary;
+	private static long fileNumber;
+	
+	public static final String DIGEST_TYPE = "MD5";
+	
+	public RegisteredResource(BundleContext ctx, InstallableResource input) throws IOException {
+		url = input.getUrl();
+		
+		try {
+			if(input.getDictionary() == null) {
+				dictionary = null;
+				if(input.getInputStream() == null) {
+					throw new IllegalArgumentException("input provides no Dictionary and no InputStream:" + input);
+				} else {
+					dataFile = getDataFile(ctx);
+					digest = copyToLocalStorage(input.getInputStream(), dataFile);
+				}
+			} else {
+				// TODO Copy dictionary
+				dataFile = null;
+				dictionary = input.getDictionary();
+				digest = computeDigest(dictionary);
+			}
+			
+    	} catch(NoSuchAlgorithmException nse) {
+    		throw new IOException("NoSuchAlgorithmException:" + DIGEST_TYPE);
+    		
+    	} finally {
+    		if(input.getInputStream() != null) {
+    			input.getInputStream().close();
+    		}
+    	}
+	}
+	
+	protected File getDataFile(BundleContext ctx) {
+		String filename = null;
+		synchronized (getClass()) {
+			filename = getClass().getSimpleName() + "." + fileNumber++;
+		}
+		return ctx.getDataFile(filename);
+	}
+	
+	public void cleanup() {
+		if(dataFile != null && dataFile.exists()) {
+			dataFile.delete();
+		}
+	}
+	
+	public String getURL() {
+		return url;
+	}
+	
+	public InputStream getInputStream() throws IOException {
+		if(dataFile == null) {
+			return null;
+		}
+		return new BufferedInputStream(new FileInputStream(dataFile));
+	}
+	
+	public Dictionary<String, Object> getDictionary() {
+		return dictionary;
+	}
+	
+	public String getDigest() {
+		return digest;
+	}
+	
+    /** Digest is needed to detect changes in data 
+     * @throws  */
+    static String computeDigest(Dictionary<String, Object> data) throws IOException, NoSuchAlgorithmException {
+        final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE);
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final ObjectOutputStream oos = new ObjectOutputStream(bos);
+        oos.writeObject(data);
+        bos.flush();
+        d.update(bos.toByteArray());
+        return digestToString(d);
+    }
+
+    /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
+    private static String digestToString(MessageDigest d) {
+        final BigInteger bigInt = new BigInteger(1, d.digest());
+        return new String(bigInt.toString(16));
+    }
+    
+    /** Copy data to local storage and return digest */
+	private String copyToLocalStorage(InputStream data, File f) throws IOException, NoSuchAlgorithmException {
+        final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE);
+		final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
+		try {
+			final byte[] buffer = new byte[16384];
+			int count = 0;
+			while( (count = data.read(buffer, 0, buffer.length)) > 0) {
+				os.write(buffer, 0, count);
+				d.update(buffer, 0, count);
+			}
+			os.flush();
+		} finally {
+			if(os != null) {
+				os.close();
+			}
+			data.close();
+		}
+		return digestToString(d);
+	}
+	
+	/** Convert InputStream to Dictionary using our extended properties format,
+	 * 	which supports multi-value properties 
+	 */
+	static Dictionary<String, Object> readDictionary(InputStream is) throws IOException {
+		final Dictionary<String, Object> result = new Hashtable<String, Object>();
+		final PropertyConverter converter = new PropertyConverter();
+		final Properties p = new Properties();
+        p.load(is);
+        for(Map.Entry<Object, Object> e : p.entrySet()) {
+            final PropertyValue v = converter.convert((String)e.getKey(), (String)e.getValue());
+            result.put(v.getKey(), v.getValue());
+        }
+        return result;
+	}
+}

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java Thu Aug 13 15:10:05 2009
@@ -30,7 +30,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.sling.osgi.installer.OsgiControllerServices;
 import org.osgi.service.log.LogService;
 
 /** Storage for the OSGi controller, stores Maps for the resources
@@ -46,7 +45,7 @@
     /** Create Storage that uses dataFile for persistence, and
      *  read the current status from that file */
     @SuppressWarnings("unchecked")
-    Storage(File dataFile, OsgiControllerServices ocs) throws IOException {
+    Storage(File dataFile, OsgiControllerContext ocs) throws IOException {
         this.dataFile = dataFile;
         ObjectInputStream ois = null;
         Map<String, Map<String, Object>> loadedData = null;

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java Thu Aug 13 15:10:05 2009
@@ -23,10 +23,9 @@
 import java.util.Map;
 import java.util.jar.Manifest;
 
-import org.apache.sling.osgi.installer.InstallableData;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
 import org.apache.sling.osgi.installer.impl.OsgiControllerImpl;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
+import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.apache.sling.osgi.installer.impl.Storage;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -42,7 +41,7 @@
 	
     public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
 
-    public BundleInstallRemoveTask(String uri, InstallableData data, BundleContext ctx, OsgiControllerServices ocs) {
+    public BundleInstallRemoveTask(String uri, RegisteredResource data, BundleContext ctx, OsgiControllerContext ocs) {
     	super(uri, data, ocs);
     	this.bundleContext = ctx;
     }
@@ -57,7 +56,7 @@
 	}
 
 	@Override
-	protected void doUninstall(OsgiControllerTaskContext tctx, Map<String, Object> attributes) throws Exception {
+	protected void doUninstall(OsgiControllerContext tctx, Map<String, Object> attributes) throws Exception {
         final Long longId = (Long) attributes.get(Storage.KEY_BUNDLE_ID);
         if (longId == null) {
         	if(ocs.getLogService() != null) {
@@ -81,17 +80,17 @@
 	}
 
 	@Override
-	protected boolean doInstallOrUpdate(OsgiControllerTaskContext tctx, Map<String, Object> attributes) throws Exception {
+	protected boolean doInstallOrUpdate(OsgiControllerContext tctx, Map<String, Object> attributes) throws Exception {
 
     	// Check that we have bundle data and manifest
-    	InputStream is = data.adaptTo(InputStream.class);
+    	InputStream is = data.getInputStream();
     	if(is == null) {
-    		throw new IOException("InstallableData does not adapt to an InputStream: " + uri);
+    		throw new IOException("RegisteredResource does not adapt to an InputStream: " + uri);
     	}
 
 		final Manifest m = TaskUtilities.getManifest(data);
 		if(m == null) {
-			throw new IOException("Manifest not found for InstallableData " + uri);
+			throw new IOException("Manifest not found for RegisteredResource " + uri);
 		}
 
         // Update if we already have a bundle id, else install
@@ -137,11 +136,7 @@
 			    tctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId()));
 			} else {
 				// New bundle -> install
-			    final String fullUri = OsgiControllerImpl.getResourceLocation(uri);
-			    int level = data.getBundleStartLevel();
-			    if(level > 0) {
-			    	throw new BundleException("Non-zero start level is not supported anymore (" + level + ")");
-			    }
+			    final String fullUri = data.getURL();
 			    b = bundleContext.installBundle(fullUri, is);
 		    	if(ocs.getLogService() != null) {
 		    		ocs.getLogService().log(LogService.LOG_INFO, 

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=803922&r1=803921&r2=803922&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 Thu Aug 13 15:10:05 2009
@@ -22,7 +22,7 @@
 
 import org.apache.sling.osgi.installer.impl.Activator;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.service.log.LogService;
@@ -50,9 +50,9 @@
 		return getClass().getSimpleName() + " (bundle " + bundleId + ")";
 	}
 
-	public void execute(OsgiControllerTaskContext tctx) throws Exception {
+	public void execute(OsgiControllerContext tctx) throws Exception {
 		final Bundle b = tctx.getBundleContext().getBundle(bundleId);
-		final LogService log = tctx.getOsgiControllerServices().getLogService();
+		final LogService log = tctx.getLogService();
 		boolean needToRetry = false;
 		
 		if(b == null) {
@@ -104,12 +104,12 @@
 	}
 	
 	/** Do not execute this task if waiting for events */
-    public boolean isExecutable(OsgiControllerTaskContext tctx) {
+    public boolean isExecutable(OsgiControllerContext tctx) {
         final long eventsCount = Activator.getTotalEventsCount(); 
         final boolean result = eventsCount >= eventsCountForRetrying; 
         if(!result) {
-            if(tctx.getOsgiControllerServices().getLogService() != null) {
-                tctx.getOsgiControllerServices().getLogService().log(LogService.LOG_DEBUG, 
+            if(tctx.getLogService() != null) {
+                tctx.getLogService().log(LogService.LOG_DEBUG, 
                         this + " is not executable at this time, counters=" + eventsCountForRetrying + "/" + eventsCount);
             }
         }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java Thu Aug 13 15:10:05 2009
@@ -18,14 +18,11 @@
  */
 package org.apache.sling.osgi.installer.impl.tasks;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.InstallableData;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
+import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.log.LogService;
 
@@ -36,9 +33,7 @@
     static final String CONFIG_PATH_KEY = "_jcr_config_path";
     static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" };
     
-    private final DictionaryReader reader = new DictionaryReader();
-    
-	public ConfigInstallRemoveTask(String uri, InstallableData data, OsgiControllerServices ocs) {
+	public ConfigInstallRemoveTask(String uri, RegisteredResource data, OsgiControllerContext ocs) {
 		super(uri, data, ocs);
 	}
 	
@@ -52,20 +47,9 @@
 	}
 
 	@Override
-	protected boolean doInstallOrUpdate(OsgiControllerTaskContext tctx, Map<String, Object> attributes) throws Exception {
+	protected boolean doInstallOrUpdate(OsgiControllerContext tctx, Map<String, Object> attributes) throws Exception {
     	// Convert data to a configuration Dictionary
-    	Dictionary dict = data.adaptTo(Dictionary.class);
-    	if(dict == null) {
-	    	InputStream is = data.adaptTo(InputStream.class);
-	    	if (data == null) {
-	    		throw new IOException("InstallableData does not adapt to an InputStream: " + uri);
-	    	}
-	    	try {
-	    		dict = reader.load(is);
-	    	} finally {
-	    	    is.close();
-	    	}
-    	}
+    	Dictionary dict = data.getDictionary();
 
     	if (dict == null) {
     		throw new IllegalArgumentException("Null Dictionary for uri=" + uri);
@@ -104,7 +88,7 @@
 	}
 
 	@Override
-	protected void doUninstall(OsgiControllerTaskContext tctx, Map<String, Object> attributes) throws Exception {
+	protected void doUninstall(OsgiControllerContext tctx, Map<String, Object> attributes) throws Exception {
         final ConfigurationPid pid = new ConfigurationPid(uri);
         final Configuration cfg = TaskUtilities.getConfiguration(pid, false, ocs);
         // TODO defer delete if ConfigAdmin not available?

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java Thu Aug 13 15:10:05 2009
@@ -20,13 +20,9 @@
 
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.InstallableData;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
-import org.apache.sling.osgi.installer.impl.InstallableDataWrapper;
-import org.apache.sling.osgi.installer.impl.OsgiControllerImpl;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
-import org.osgi.service.log.LogService;
+import org.apache.sling.osgi.installer.impl.RegisteredResource;
 
 /** Base class for OsgiControllerTasks that install or
  * 	remove OSGi bundles or configs (or deployment packages, etc.)
@@ -34,10 +30,10 @@
 abstract class InstallRemoveTask extends OsgiControllerTask {
 
 	protected final String uri;
-	protected final InstallableData data;
-	protected final OsgiControllerServices ocs;
+	protected final RegisteredResource data;
+	protected final OsgiControllerContext ocs;
 
-    protected InstallRemoveTask(String uri, InstallableData data, OsgiControllerServices ocs) {
+    protected InstallRemoveTask(String uri, RegisteredResource data, OsgiControllerContext ocs) {
     	this.uri = uri;
     	this.data = data;
     	this.ocs = ocs;
@@ -55,17 +51,8 @@
 	}
 
 	/** {@inheritDoc} */
-	public void execute(OsgiControllerTaskContext context) throws Exception {
-		if(isInstallOrUpdate()) {
-			executeInstallOrUpdate(context);
-		} else {
-			executeUninstall(context);
-		}
-
-		// Cleanup InstallableDataWrapper
-		if(data instanceof InstallableDataWrapper) {
-			((InstallableDataWrapper)data).cleanup();
-		}
+	public void execute(OsgiControllerContext context) throws Exception {
+		// TODO cleanup stored data? (previously RegisteredResourceWrapper)
 	}
 	
 	/** @return true if this is an install/update task, false if it is an uninstall */
@@ -73,66 +60,9 @@
 		return data != null;
 	}
 	
-	protected final void executeInstallOrUpdate(OsgiControllerTaskContext context) throws Exception {
-        
-        // If a corresponding higher priority resource is already installed, ignore this one
-        if(context.getResourceOverrideRules() != null) {
-            for(String r : context.getResourceOverrideRules().getHigherPriorityResources(uri)) {
-                if(context.getStorage().contains(r)) {
-                	if(ocs.getLogService() != null) {
-                		ocs.getLogService().log(LogService.LOG_INFO, 
-                				"Resource " + uri + " ignored, overridden by " + r + " which has higher priority");
-                	}
-                    return;
-                }
-            }
-        }
-
-        // If a corresponding lower priority resource is installed, uninstall it first
-        if(context.getResourceOverrideRules() != null) {
-            for(String r : context.getResourceOverrideRules().getLowerPriorityResources(uri)) {
-                if(context.getStorage().contains(r)) {
-                	if(ocs.getLogService() != null) {
-                		ocs.getLogService().log(LogService.LOG_INFO, 
-                				"Resource " + uri + " overrides " + r + ", uninstalling the latter");
-                	}
-                    executeUninstall(context);
-                }
-            }
-        }
-
-        // process install
-        final Map<String, Object> map = context.getStorage().getMap(uri);
-        if(doInstallOrUpdate(context, map)) {
-            map.put(OsgiControllerImpl.KEY_DIGEST, data.getDigest());
-        }
-        context.getStorage().saveToFile();
-	}
-	
-	protected final void executeUninstall(OsgiControllerTaskContext context) throws Exception {
-        // If a corresponding higher priority resource is installed, ignore this request
-        if(context.getResourceOverrideRules() != null) {
-            for(String r : context.getResourceOverrideRules().getHigherPriorityResources(uri)) {
-                if(context.getStorage().contains(r)) {
-                	if(ocs.getLogService() != null) {
-                		ocs.getLogService().log(LogService.LOG_INFO,
-                				"Resource " + uri + " won't be uninstalled, overridden by " + r + " which has higher priority");
-                	}
-                    return;
-                }
-            }
-        }
-
-        doUninstall(context, context.getStorage().getMap(uri));
-
-    	context.getStorage().remove(uri);
-    	context.getStorage().saveToFile();
-		
-	}
-
 	/** Do the actual uninstall */
-	protected abstract void doUninstall(OsgiControllerTaskContext ctx, Map<String, Object> attributes) throws Exception;
+	protected abstract void doUninstall(OsgiControllerContext ctx, Map<String, Object> attributes) throws Exception;
 	
 	/** Do the actual install or update */
-	protected abstract boolean doInstallOrUpdate(OsgiControllerTaskContext ctx, Map<String, Object> attributes) throws Exception;
+	protected abstract boolean doInstallOrUpdate(OsgiControllerContext ctx, Map<String, Object> attributes) throws Exception;
 }

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=803922&r1=803921&r2=803922&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 Thu Aug 13 15:10:05 2009
@@ -18,9 +18,8 @@
  */
 package org.apache.sling.osgi.installer.impl.tasks;
 
-import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
-import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
@@ -33,7 +32,7 @@
     public static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
 
 	private int packageRefreshEventsCount;
-	private OsgiControllerServices ocs;
+	private OsgiControllerContext ctx;
 
     /**
      * Handles the PACKAGES_REFRESHED framework event which is sent after
@@ -44,8 +43,8 @@
      */
     public void frameworkEvent(FrameworkEvent event) {
         if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
-        	if(ocs.getLogService() != null) {
-	    		ocs.getLogService().log(LogService.LOG_DEBUG,
+        	if(ctx!= null && ctx.getLogService() != null) {
+	    		ctx.getLogService().log(LogService.LOG_DEBUG,
 	    				"FrameworkEvent.PACKAGES_REFRESHED");
         	}
         	packageRefreshEventsCount++;
@@ -62,11 +61,11 @@
 		return getClass().getSimpleName();
 	}
 
-	public void execute(OsgiControllerTaskContext ctx) throws Exception {
+	public void execute(OsgiControllerContext ctx) throws Exception {
+		this.ctx = ctx;
         final int targetEventCount = packageRefreshEventsCount + 1;
         final long start = System.currentTimeMillis();
         final long timeout = System.currentTimeMillis() + MAX_REFRESH_PACKAGES_WAIT_SECONDS * 1000L;
-        ocs = ctx.getOsgiControllerServices();
 
         // Refreshing packages might cause some bundles to be stopped,
         // make sure all currently active ones are restarted after
@@ -75,8 +74,8 @@
     		if(b.getState() == Bundle.ACTIVE) {
     			final OsgiControllerTask t = new BundleStartTask(b.getBundleId());
     			ctx.addTaskToCurrentCycle(t);
-            	if(ctx.getOsgiControllerServices().getLogService() != null) {
-            		ctx.getOsgiControllerServices().getLogService().log(LogService.LOG_DEBUG, 
+            	if(ctx.getLogService() != null) {
+            		ctx.getLogService().log(LogService.LOG_DEBUG, 
             				"Added " + t + " to restart bundle if needed after refreshing packages"); 
             	}
     		}
@@ -89,8 +88,8 @@
         try {
             while(true) {
                 if(System.currentTimeMillis() > timeout) {
-                	if(ocs.getLogService() != null) {
-        	    		ocs.getLogService().log(LogService.LOG_WARNING,
+                	if(ctx.getLogService() != null) {
+        	    		ctx.getLogService().log(LogService.LOG_WARNING,
         	    				"No FrameworkEvent.PACKAGES_REFRESHED event received within "
         	    				+ MAX_REFRESH_PACKAGES_WAIT_SECONDS
         	    				+ " seconds after refresh");
@@ -99,8 +98,8 @@
                 }
                 if(packageRefreshEventsCount >= targetEventCount) {
                     final long delta = System.currentTimeMillis() - start;
-                    if(ocs.getLogService() != null) {
-        	    		ocs.getLogService().log(LogService.LOG_DEBUG,
+                    if(ctx.getLogService() != null) {
+        	    		ctx.getLogService().log(LogService.LOG_DEBUG,
         	    				"FrameworkEvent.PACKAGES_REFRESHED received "
         	    				+ delta
         	    				+ " msec after refreshPackages call");

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java Thu Aug 13 15:10:05 2009
@@ -5,8 +5,8 @@
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
-import org.apache.sling.osgi.installer.InstallableData;
-import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.apache.sling.osgi.installer.impl.OsgiControllerContext;
+import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -27,7 +27,7 @@
      * This method gets its own input stream from the installable data object
      * and closes it after haing read the manifest file.
      *
-     * @param installableData The installable data providing the bundle jar file
+     * @param RegisteredResource The installable data providing the bundle jar file
      *            from the input stream.
      * @return The installed bundle with the same symbolic name as the bundle
      *         provided by the input stream or <code>null</code> if no such
@@ -51,10 +51,10 @@
     	return null;
     }
 
-    /** Read the manifest from the InstallableData */
-    static Manifest getManifest(InstallableData data) throws IOException {
+    /** Read the manifest from the RegisteredResource */
+    static Manifest getManifest(RegisteredResource data) throws IOException {
     	Manifest result = null;
-        InputStream ins = data.adaptTo(InputStream.class);
+        InputStream ins = data.getInputStream();
         if (ins == null) {
         	return null;
        	}
@@ -87,7 +87,7 @@
     }
     
     /** Get or create configuration */
-    static Configuration getConfiguration(ConfigurationPid cp, boolean createIfNeeded, OsgiControllerServices ocs)
+    static Configuration getConfiguration(ConfigurationPid cp, boolean createIfNeeded, OsgiControllerContext ocs)
     throws IOException, InvalidSyntaxException
     {
     	final ConfigurationAdmin configurationAdmin = ocs.getConfigurationAdmin();

Copied: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.java (from r803805, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java)
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.java?p2=sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.java&p1=sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java&r1=803805&r2=803922&rev=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.java Thu Aug 13 15:10:05 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.osgi.installer.impl.tasks;
+package org.apache.sling.osgi.installer.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -24,13 +24,11 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Dictionary;
-import java.util.Properties;
 
 import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyConverter;
 import org.apache.sling.osgi.installer.impl.propertyconverter.ValueConverterException;
 
-/** Test the DictionaryReader */
-public class DictionaryReaderTest {
+public class DictionaryConversionTest {
     
     private void assertArray(String info, String [] expected, Object obj) {
         assertTrue(info + ":obj (" + obj.getClass().getName() + ") must be a String[]", obj instanceof String[]);
@@ -65,22 +63,6 @@
         assertArray("a,b,c,d", new String[] { "a", "b, c ,", "d" }, c.convert("x[]", "a, b\\, c \\,,d ").getValue());
     }
      
-    @org.junit.Test public void testConvertProperties() throws ValueConverterException {
-        final Properties p = new Properties();
-        p.setProperty("a", "1");
-        p.setProperty("b", "2");
-        p.setProperty("c[]", "1, 2, 3");
-        p.setProperty("d []", "4, 5, 6");
-        
-        final DictionaryReader r = new DictionaryReader();
-        final Dictionary<?, ?> d = r.convert(p);
-        assertEquals("a", d.get("a"), "1");
-        assertEquals("b", d.get("b"), "2");
-        
-        assertArray("c", new String[] { "1", "2", "3" }, d.get("c"));
-        assertArray("d", new String[] { "4", "5", "6" }, d.get("d"));
-    }
-    
     @org.junit.Test public void testFromStream() throws IOException {
         final String data =
             "a = 1\n"
@@ -92,13 +74,8 @@
             ;
         
         final ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        final DictionaryReader r = new DictionaryReader();
-        Dictionary<?, ?> d = null;
-        try {
-            d = r.load(is);
-        } finally {
-            is.close();
-        }
+        final Dictionary<?, ?> d = RegisteredResource.readDictionary(is);
+        is.close();
         
         assertEquals("Number of entries must match", 4, d.size());
         assertEquals("a", d.get("a"), "1");
@@ -119,13 +96,8 @@
             ;
         
         final ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        final DictionaryReader r = new DictionaryReader();
-        Dictionary<?, ?> d = null;
-        try {
-            d = r.load(is);
-        } finally {
-            is.close();
-        }
+        final Dictionary<?, ?> d = RegisteredResource.readDictionary(is);
+        is.close();
         
         assertEquals("Number of entries must match", 5, d.size());
         assertEquals("String value matches", "1", d.get("a"));

Copied: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java (from r803805, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/DigestTest.java)
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java?p2=sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java&p1=sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/DigestTest.java&r1=803805&r2=803922&rev=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/DigestTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java Thu Aug 13 15:10:05 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.osgi.installer;
+package org.apache.sling.osgi.installer.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -24,7 +24,7 @@
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-public class DigestTest {
+public class DictionaryDigestTest {
 	private void setTestData(Hashtable<String, Object> d) {
 		d.put("str", "value");
 		d.put("long", new Long(12));
@@ -33,7 +33,7 @@
 	
 	private String testDigestChanged(Dictionary<String, Object> d, 
 			String oldDigest, int step, boolean shouldChange) throws Exception {
-		final String newDigest = DictionaryInstallableData.computeDigest(d);
+		final String newDigest = RegisteredResource.computeDigest(d);
 		if(shouldChange) {
 			assertTrue("Digest (" + newDigest + ") should have changed at step " + step, !newDigest.equals(oldDigest));
 		} else {
@@ -51,8 +51,8 @@
 		
 		assertEquals(
 				"Two dictionary with same values have the same key", 
-				DictionaryInstallableData.computeDigest(d1),
-				DictionaryInstallableData.computeDigest(d2)
+				RegisteredResource.computeDigest(d1),
+				RegisteredResource.computeDigest(d2)
 		);
 	}
 	

Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java?rev=803922&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java (added)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java Thu Aug 13 15:10:05 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.osgi.installer.impl;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class MockOsgiControllerContext implements OsgiControllerContext {
+
+	public void addTaskToCurrentCycle(OsgiControllerTask t) {
+	}
+
+	public void addTaskToNextCycle(OsgiControllerTask t) {
+	}
+
+	public BundleContext getBundleContext() {
+		return null;
+	}
+
+	public ConfigurationAdmin getConfigurationAdmin() {
+		return null;
+	}
+
+	public LogService getLogService() {
+		return null;
+	}
+
+	public PackageAdmin getPackageAdmin() {
+		return null;
+	}
+
+	public Storage getStorage() {
+		return null;
+	}
+}

Propchange: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java Thu Aug 13 15:10:05 2009
@@ -26,23 +26,10 @@
 import java.io.File;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.OsgiControllerServices;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.log.LogService;
-
 /** Test the Storage class */
 public class StorageTest {
 
-	private final OsgiControllerServices ocs = new OsgiControllerServices() {
-		
-		public LogService getLogService() {
-			return null;
-		}
-		
-		public ConfigurationAdmin getConfigurationAdmin() {
-			return null;
-		}
-	};
+	private final OsgiControllerContext ocs = new MockOsgiControllerContext();
 	
     @org.junit.Test public void testEmptyDataFile() throws Exception {
         final Storage s = new Storage(Utilities.getTestFile(), ocs);

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=803922&r1=803921&r2=803922&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 Thu Aug 13 15:10:05 2009
@@ -20,10 +20,13 @@
 
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.util.Collection;
+import java.util.Hashtable;
 import java.util.Set;
 import java.util.TreeSet;
 
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.impl.tasks.BundleInstallRemoveTask;
 import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask;
 import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallRemoveTask;
@@ -42,6 +45,10 @@
 		taskSet = new TreeSet<OsgiControllerTask>(); 
 	}
 	
+	private static RegisteredResource getRegisteredResource(String url) throws IOException {
+		return new RegisteredResource(null, new InstallableResource(url, new Hashtable<String, Object>()));
+	}
+	
 	private void assertOrder(int testId, Collection<OsgiControllerTask> actual, OsgiControllerTask [] expected) {
 		int index = 0;
 		for(OsgiControllerTask t : actual) {
@@ -53,13 +60,13 @@
 	}
 	
 	@org.junit.Test 
-	public void testBasicOrdering() {
+	public void testBasicOrdering() throws Exception {
 		int testIndex = 1;
 		final OsgiControllerTask [] tasksInOrder = {
 			new ConfigInstallRemoveTask("someURI.cfg", null, null),
-			new ConfigInstallRemoveTask("someURI.cfg", new MockInstallableData("someURI.cfg"), null),
+			new ConfigInstallRemoveTask("someURI.cfg", getRegisteredResource("someURI.cfg"), null),
 			new BundleInstallRemoveTask("someURI", null, null, null),
-			new BundleInstallRemoveTask("someURI", new MockInstallableData("someURI.jar"), null, null),
+			new BundleInstallRemoveTask("someURI", getRegisteredResource("someURI.jar"), null, null),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
@@ -106,17 +113,17 @@
 	}
 	
 	@org.junit.Test 
-	public void testMultipleConfigAndBundles() {
+	public void testMultipleConfigAndBundles() throws Exception {
 		int testIndex = 1;
 		final OsgiControllerTask [] tasksInOrder = {
 			new ConfigInstallRemoveTask("someURIa.cfg", null, null),
 			new ConfigInstallRemoveTask("someURIb.cfg", null, null),
-			new ConfigInstallRemoveTask("someURIa.cfg", new MockInstallableData("someURIa.cfg"), null),
-			new ConfigInstallRemoveTask("someURIb.cfg", new MockInstallableData("someURIb.cfg"), null),
+			new ConfigInstallRemoveTask("someURIa.cfg", getRegisteredResource("someURIa.cfg"), null),
+			new ConfigInstallRemoveTask("someURIb.cfg", getRegisteredResource("someURIb.cfg"), null),
 			new BundleInstallRemoveTask("someURIa.jar", null, null, null),
 			new BundleInstallRemoveTask("someURIb.jar", null, null, null),
-			new BundleInstallRemoveTask("someURIa.jar", new MockInstallableData("someURIa.jar"), null, null),
-			new BundleInstallRemoveTask("someURIb.jar", new MockInstallableData("someURIb.jar"), null, null),
+			new BundleInstallRemoveTask("someURIa.jar", getRegisteredResource("someURIa.jar"), null, null),
+			new BundleInstallRemoveTask("someURIb.jar", getRegisteredResource("someURIb.jar"), null, null),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
@@ -130,13 +137,13 @@
 	}
 	
 	@org.junit.Test 
-	public void testMultipleRefreshAndStart() {
+	public void testMultipleRefreshAndStart() throws Exception {
 		int testIndex = 1;
 		final OsgiControllerTask [] tasksInOrder = {
 			new ConfigInstallRemoveTask("someURI.cfg", null, null),
-			new ConfigInstallRemoveTask("someURI.cfg", new MockInstallableData("someURI.cfg"), null),
+			new ConfigInstallRemoveTask("someURI.cfg", getRegisteredResource("someURI.cfg"), null),
 			new BundleInstallRemoveTask("someURI", null, null, null),
-			new BundleInstallRemoveTask("someURI", new MockInstallableData("someURI.jar"), null, null),
+			new BundleInstallRemoveTask("someURI", getRegisteredResource("someURI.jar"), null, null),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 			new BundleStartTask(1),

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java?rev=803922&r1=803921&r2=803922&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java Thu Aug 13 15:10:05 2009
@@ -21,10 +21,8 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.apache.sling.osgi.installer.impl.MockOsgiControllerContext;
 import org.osgi.framework.Version;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.log.LogService;
 
 /** Test ignoring bundle updates based on Versions (SLING-1001) */
 public class BundleInstallRemoveIgnoreTest {
@@ -34,17 +32,7 @@
 	private BundleInstallRemoveTask task;
 	
     @org.junit.Before public void setup() {
-    	OsgiControllerServices s = new OsgiControllerServices() {
-			public LogService getLogService() {
-				return null;
-			}
-			
-			public ConfigurationAdmin getConfigurationAdmin() {
-				return null;
-			}
-		};
-		
-        task = new BundleInstallRemoveTask(null, null, null, s);
+        task = new BundleInstallRemoveTask(null, null, null, new MockOsgiControllerContext());
     }
 
 	@org.junit.Test public void testLowerVersion() {



Mime
View raw message