incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r955699 - in /sling/trunk/installer: jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ osgi/installer/src/main/java/org/apache/sling/osgi/installer/ osgi/in...
Date Thu, 17 Jun 2010 18:34:40 GMT
Author: cziegeler
Date: Thu Jun 17 18:34:39 2010
New Revision: 955699

URL: http://svn.apache.org/viewvc?rev=955699&view=rev
Log:
SLING-1560 : Improve and clean up code
Make InstallableResource an interface and create two implementations. Factor out digest handling into an utility class.

Added:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java   (with props)
Modified:
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.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/tasks/ConfigInstallTask.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.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

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java Thu Jun 17 18:34:39 2010
@@ -29,52 +29,56 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
+import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** Converts configuration nodes to InstallableData */
 class ConfigNodeConverter implements JcrInstaller.NodeConverter {
-	
+
 	public static final String CONFIG_NODE_TYPE = "sling:OsgiConfig";
 	private final Logger log = LoggerFactory.getLogger(getClass());
-	
+
 	/** Convert n to an InstallableData, or return null
 	 * 	if we don't know how to convert it.
 	 */
-	public InstallableResource convertNode(String urlScheme, Node n) throws Exception {
+	/**
+	 * @see org.apache.sling.jcr.jcrinstall.impl.JcrInstaller.NodeConverter#convertNode(java.lang.String, javax.jcr.Node, int)
+	 */
+	public InstallableResource convertNode(String urlScheme, Node n, final int priority) throws Exception {
 		InstallableResource result = null;
 
 		// We only consider CONFIG_NODE_TYPE nodes
 		if(n.isNodeType(CONFIG_NODE_TYPE)) {
-			result = new InstallableResource(urlScheme + ":" + n.getPath(), load(n));
+			result = new InstallableConfigResource(urlScheme + ":" + n.getPath(), load(n), priority);
 			log.debug("Converted node {} to {}", n.getPath(), result);
 		} else {
 			log.debug("Node is not a {} node, ignored:{}", CONFIG_NODE_TYPE, n.getPath());
 		}
 		return result;
 	}
-	
+
     /** Load config from node n */
     protected Dictionary<String, Object> load(Node n) throws RepositoryException {
         Dictionary<String, Object> result = new Hashtable<String, Object>();
-        
+
         log.debug("Loading config from Node {}", n.getPath());
-        
+
         // load default values from node itself
         log.debug("Loading {} properties", n.getPath());
         loadProperties(result, n);
-        
+
         return result;
     }
-    
+
     /** Load properties of n into d */
     protected void loadProperties(Dictionary<String, Object> d, Node n) throws RepositoryException {
         final PropertyIterator pi = n.getProperties();
         while(pi.hasNext()) {
             final Property p = pi.nextProperty();
             final String name = p.getName();
-            
+
             // ignore jcr: and similar properties
             if(name.contains(":")) {
                 continue;
@@ -91,7 +95,7 @@ class ConfigNodeConverter implements Jcr
                     data[i++] = o;
                 }
                 d.put(name, data);
-                
+
             } else {
                 final Object o = convertValue(p.getValue());
                 if(o != null) {

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java Thu Jun 17 18:34:39 2010
@@ -23,29 +23,33 @@ import java.util.regex.Pattern;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
+import org.apache.sling.osgi.installer.InstallableBundleResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/** Convert a Node that is a file to an InstallableResource that wraps an InputStream */ 
+/** Convert a Node that is a file to an InstallableResource that wraps an InputStream */
  public class FileNodeConverter implements JcrInstaller.NodeConverter {
     // regexp for filenames that we accept
     public static final String FILENAME_REGEXP = "[a-zA-Z0-9].*\\.(jar|cfg|properties)";
-    
+
     public static final String JCR_CONTENT = "jcr:content";
     public static final String JCR_CONTENT_DATA = JCR_CONTENT + "/jcr:data";
     public static final String JCR_LAST_MODIFIED = "jcr:lastModified";
     public static final String JCR_CONTENT_LAST_MODIFIED = JCR_CONTENT + "/" + JCR_LAST_MODIFIED;
-    
+
     private final Pattern namePattern = Pattern.compile(FILENAME_REGEXP);
     private final Logger log = LoggerFactory.getLogger(getClass());
-    
-	public InstallableResource convertNode(String urlScheme, Node n) throws RepositoryException {
+
+	/**
+	 * @see org.apache.sling.jcr.jcrinstall.impl.JcrInstaller.NodeConverter#convertNode(java.lang.String, javax.jcr.Node, int)
+	 */
+	public InstallableResource convertNode(String urlScheme, Node n, final int priority) throws RepositoryException {
 		InstallableResource result = null;
 		if(n.hasProperty(JCR_CONTENT_DATA) && n.hasProperty(JCR_CONTENT_LAST_MODIFIED)) {
 			if(acceptNodeName(n.getName())) {
 				try {
-					result = convert(urlScheme, n, n.getPath());
+					result = convert(urlScheme, n, n.getPath(), priority);
 				} catch(IOException ioe) {
 					log.info("Conversion failed, node {} ignored ({})", n.getPath(), ioe);
 				}
@@ -54,29 +58,29 @@ import org.slf4j.LoggerFactory;
 			}
 			return result;
 		}
-		log.debug("Node {} has no {} properties, ignored", n.getPath(), 
+		log.debug("Node {} has no {} properties, ignored", n.getPath(),
 				JCR_CONTENT_DATA + " or " + JCR_CONTENT_LAST_MODIFIED);
 		return null;
 	}
-	
-	private InstallableResource convert(String urlScheme, Node n, String path) throws IOException, RepositoryException {
+
+	private InstallableResource convert(String urlScheme, Node n, String path, final int priority) throws IOException, RepositoryException {
 		String digest = null;
         if (n.hasProperty(JCR_CONTENT_LAST_MODIFIED)) {
         	digest = String.valueOf(n.getProperty(JCR_CONTENT_LAST_MODIFIED).getDate().getTimeInMillis());
         } else {
         	throw new IOException("Missing " + JCR_CONTENT_LAST_MODIFIED + " property");
 	    }
-	    
+
         InputStream is = null;
         if(n.hasProperty(JCR_CONTENT_DATA)) {
         	is = n.getProperty(JCR_CONTENT_DATA).getStream();
         } else {
         	throw new IOException("Missing " + JCR_CONTENT_DATA + " property");
         }
-		
-        return new InstallableResource(urlScheme + ":" + path, is, digest);
+
+        return new InstallableBundleResource(urlScheme + ":" + path, is, digest, priority);
 	}
-	
+
 	boolean acceptNodeName(String name) {
 		return namePattern.matcher(name).matches();
 	}

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java Thu Jun 17 18:34:39 2010
@@ -131,7 +131,7 @@ public class JcrInstaller implements Eve
 
     /** Convert Nodes to InstallableResources */
     static interface NodeConverter {
-    	InstallableResource convertNode(String urlScheme, Node n) throws Exception;
+    	InstallableResource convertNode(String urlScheme, Node n, int priority) throws Exception;
     }
 
     /** Our NodeConverters*/
@@ -370,8 +370,8 @@ public class JcrInstaller implements Eve
      *  @return a list of InstallableResource that must be unregistered,
      *  	for folders that have been removed
      */
-    private List<InstallableResource> updateFoldersList() throws Exception {
-    	final List<InstallableResource> result = new LinkedList<InstallableResource>();
+    private List<String> updateFoldersList() throws Exception {
+    	final List<String> result = new LinkedList<String>();
 
     	// If one of our root folders was just created, scan it for folders to watch
     	if(newRoots.size() > 0) {
@@ -458,7 +458,7 @@ public class JcrInstaller implements Eve
                     WatchedFolder.getRescanTimer().reset();
                     counters[SCAN_FOLDERS_COUNTER]++;
                     final WatchedFolder.ScanResult sr = wf.scan();
-                    for(InstallableResource r : sr.toRemove) {
+                    for(String r : sr.toRemove) {
                         log.info("Removing resource from OSGi installer: {}",r);
                         installer.removeResource(r);
                     }
@@ -474,8 +474,8 @@ public class JcrInstaller implements Eve
             if(scanWf || updateFoldersListTimer.expired()) {
                 updateFoldersListTimer.reset();
                 counters[UPDATE_FOLDERS_LIST_COUNTER]++;
-                final List<InstallableResource> toRemove = updateFoldersList();
-                for(InstallableResource r : toRemove) {
+                final List<String> toRemove = updateFoldersList();
+                for(String r : toRemove) {
                     log.info("Removing resource from OSGi installer (folder deleted): {}",r);
                     installer.removeResource(r);
                 }

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java Thu Jun 17 18:34:39 2010
@@ -52,28 +52,28 @@ class WatchedFolder implements EventList
     private final Collection <JcrInstaller.NodeConverter> converters;
     private final Set<String> existingResourceUrls = new HashSet<String>();
     protected final Logger log = LoggerFactory.getLogger(getClass());
-    
+
     static class ScanResult {
-        List<InstallableResource> toAdd = new ArrayList<InstallableResource>(); 
-        List<InstallableResource> toRemove = new ArrayList<InstallableResource>();
+        List<InstallableResource> toAdd = new ArrayList<InstallableResource>();
+        List<String> toRemove = new ArrayList<String>();
     };
-    
+
     /** Store the digests of the last returned resources, keyed by path, to detect changes */
     private final Map<String, String> digests = new HashMap<String, String>();
-    
-    WatchedFolder(Session session, String path, int priority, 
+
+    WatchedFolder(Session session, String path, int priority,
     		String urlScheme, Collection<JcrInstaller.NodeConverter> converters) throws RepositoryException {
         if(priority < 1) {
             throw new IllegalArgumentException("Cannot watch folder with priority 0:" + path);
         }
-        
+
         this.path = path;
         this.converters = converters;
         this.priority = priority;
         this.urlScheme = urlScheme;
-        
+
         this.session = session;
-        
+
         // observe any changes in our folder (and under it, as changes to properties
         // might be lower in the hierarchy)
         final int eventTypes = Event.NODE_ADDED | Event.NODE_REMOVED
@@ -85,7 +85,7 @@ class WatchedFolder implements EventList
 
         log.info("Watching folder {} (priority {})", path, priority);
     }
-    
+
     void cleanup() {
     	try {
 	    	session.getWorkspace().getObservationManager().removeEventListener(this);
@@ -93,41 +93,41 @@ class WatchedFolder implements EventList
     		log.warn("RepositoryException in cleanup()", re);
     	}
     }
-    
+
     @Override
     public String toString() {
     	return getClass().getSimpleName() + ":" + path;
     }
-    
+
     String getPath() {
         return path;
     }
-    
+
     /** Set a static "timer" whenever an event occurs */
     public void onEvent(EventIterator it) {
         log.debug("JCR event received for path {}", path);
     	scheduleScan();
     }
-    
+
     void scheduleScan() {
         log.debug("Scheduling scan of {}", path);
-        rescanTimer.scheduleScan(); 
+        rescanTimer.scheduleScan();
         needsScan = true;
     }
-    
+
     boolean needsScan() {
     	return needsScan;
     }
-    
+
     static RescanTimer getRescanTimer() {
     	return rescanTimer;
     }
-    
+
     /** Scan the contents of our folder and return the corresponding InstallableResource */
     ScanResult scan() throws Exception {
         log.debug("Scanning {}", path);
         needsScan = false;
-        
+
         Node folder = null;
         if(session.itemExists(path)) {
         	Item i = session.getItem(path);
@@ -135,7 +135,7 @@ class WatchedFolder implements EventList
         		folder = (Node)i;
         	}
         }
-        
+
         // Return an InstallableResource for all child nodes for which we have a NodeConverter
         final ScanResult result = new ScanResult();
         final Set<String> resourcesSeen = new HashSet<String>();
@@ -144,14 +144,13 @@ class WatchedFolder implements EventList
             while(it.hasNext()) {
             	final Node n = it.nextNode();
             	for(JcrInstaller.NodeConverter nc : converters) {
-            		final InstallableResource r = nc.convertNode(urlScheme, n);
+            		final InstallableResource r = nc.convertNode(urlScheme, n, priority);
             		if(r != null) {
             			resourcesSeen.add(r.getUrl());
             		    final String oldDigest = digests.get(r.getUrl());
             		    if(r.getDigest().equals(oldDigest)) {
             		    	log.debug("Digest didn't change, ignoring " + r);
             		    } else {
-                            r.setPriority(priority);
                             result.toAdd.add(r);
             		    }
             			break;
@@ -159,26 +158,25 @@ class WatchedFolder implements EventList
             	}
             }
         }
-        
-        // Resources that existed but are not in resourcesSeen need to be 
+
+        // Resources that existed but are not in resourcesSeen need to be
         // unregistered from OsgiInstaller
         for(String url : existingResourceUrls) {
         	if(!resourcesSeen.contains(url)) {
-                InstallableResource r = new InstallableResource(url);
-                result.toRemove.add(r);
+                result.toRemove.add(url);
         	}
         }
-        for(InstallableResource r : result.toRemove) {
-        	existingResourceUrls.remove(r.getUrl());
-        	digests.remove(r.getUrl());
+        for(String u : result.toRemove) {
+        	existingResourceUrls.remove(u);
+        	digests.remove(u);
         }
-        
+
         // Update saved digests of the resources that we're returning
         for(InstallableResource r : result.toAdd) {
             existingResourceUrls.add(r.getUrl());
             digests.put(r.getUrl(), r.getDigest());
         }
-        
+
         return result;
     }
 }

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java Thu Jun 17 18:34:39 2010
@@ -100,6 +100,10 @@ class MiscUtil {
         public void close() {
             // nothing to do
         }
+
+        public String getUserID() {
+            return null;
+        }
     }
 
     /** Set a non-public Field */
@@ -110,7 +114,7 @@ class MiscUtil {
     }
 
     /** Return a JcrInstaller setup for testing */
-    static JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller) throws Exception {
+    static synchronized JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller) throws Exception {
         final JcrInstaller installer = new JcrInstaller();
         setField(installer, "repository", repository);
         setField(installer, "installer", osgiInstaller);
@@ -120,21 +124,25 @@ class MiscUtil {
         return installer;
     }
 
+    private static ComponentContext COMPONENT_CONTEXT;
     static ComponentContext getMockComponentContext() {
-        // Setup fake ComponentContext to allow JcrInstaller to start
-        final ComponentContext cc = mockery.mock(ComponentContext.class);
-        final BundleContext bc = mockery.mock(BundleContext.class);
-
-        final Dictionary<String, Object> emptyDict = new Hashtable<String, Object>();
-        mockery.checking(new Expectations() {{
-            allowing(cc).getProperties();
-            will(returnValue(emptyDict));
-            allowing(cc).getBundleContext();
-            will(returnValue(bc));
-            allowing(bc).getProperty(with(any(String.class)));
-            will(returnValue(null));
-        }});
-        return cc;
+        if ( COMPONENT_CONTEXT == null ) {
+            // Setup fake ComponentContext to allow JcrInstaller to start
+            final ComponentContext cc = mockery.mock(ComponentContext.class);
+            final BundleContext bc = mockery.mock(BundleContext.class);
+
+            final Dictionary<String, Object> emptyDict = new Hashtable<String, Object>();
+            mockery.checking(new Expectations() {{
+                allowing(cc).getProperties();
+                will(returnValue(emptyDict));
+                allowing(cc).getBundleContext();
+                will(returnValue(bc));
+                allowing(bc).getProperty(with(any(String.class)));
+                will(returnValue(null));
+            }});
+            COMPONENT_CONTEXT = cc;
+        }
+        return COMPONENT_CONTEXT;
     }
 
     static private void waitForCycles(JcrInstaller installer, long initialCycleCount, int expectedCycles, long timeoutMsec) throws Exception {

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java Thu Jun 17 18:34:39 2010
@@ -20,20 +20,20 @@ package org.apache.sling.jcr.jcrinstall.
 
 import java.io.ByteArrayInputStream;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableBundleResource;
 
-public class MockInstallableResource extends InstallableResource {
+public class MockInstallableResource extends InstallableBundleResource {
 
     private static int counter;
-    
+
     public MockInstallableResource(String uri) {
         this(uri, "", null);
     }
-    
+
     public MockInstallableResource(String uri, String data, String digest) {
         super(uri, new ByteArrayInputStream(data.getBytes()), getNextDigest(digest));
     }
-    
+
     static String getNextDigest(String digest) {
         if(digest != null) {
             return digest;
@@ -41,5 +41,5 @@ public class MockInstallableResource ext
         synchronized (MockInstallableResource.class) {
             return String.valueOf(System.currentTimeMillis() + (counter++));
         }
-    }    
+    }
 }

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java Thu Jun 17 18:34:39 2010
@@ -67,12 +67,14 @@ class MockOsgiInstaller implements OsgiI
         }
     }
 
-    public void removeResource(InstallableResource d) {
-    	if(!d.isEmpty()) {
-    		throw new IllegalArgumentException("InstallableResource must be empty for removeResource call");
+    /**
+     * @see org.apache.sling.osgi.installer.OsgiInstaller#removeResource(java.lang.String)
+     */
+    public void removeResource(String url) {
+    	urls.remove(url);
+    	synchronized ( this) {
+            recordedCalls.add("remove:" + url + ":100");
     	}
-    	urls.remove(d.getUrl());
-        recordCall("remove", d);
     }
 
     private synchronized void recordCall(String prefix, InstallableResource r) {

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java?rev=955699&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java Thu Jun 17 18:34:39 2010
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * Utility methods for the digest handling.
+ */
+public abstract class DigestUtil {
+
+    /** The digest to be used. */
+    public static final String DIGEST_TYPE = "MD5";
+
+    /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
+    public static String digestToString(MessageDigest d) {
+        final BigInteger bigInt = new BigInteger(1, d.digest());
+        return new String(bigInt.toString(16));
+    }
+
+    /** Compute digest on all keys of supplied data */
+    public static String computeDigest(Dictionary<String, Object> data) throws IOException, NoSuchAlgorithmException {
+    	return computeDigest(data, null);
+    }
+
+    /** Digest is needed to detect changes in data, and must not depend on dictionary ordering */
+    public static String computeDigest(Dictionary<String, Object> data, Set<String> keysToIgnore) throws IOException, NoSuchAlgorithmException {
+        final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE);
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final ObjectOutputStream oos = new ObjectOutputStream(bos);
+
+        final SortedSet<String> sortedKeys = new TreeSet<String>();
+        if(data != null) {
+            for(Enumeration<String> e = data.keys(); e.hasMoreElements(); ) {
+            	final String key = e.nextElement();
+            	if(keysToIgnore == null || !keysToIgnore.contains(key)) {
+            		sortedKeys.add(key);
+            	}
+            }
+        }
+        for(String key : sortedKeys) {
+        	oos.writeObject(key);
+        	oos.writeObject(data.get(key));
+        }
+
+        bos.flush();
+        d.update(bos.toByteArray());
+        return digestToString(d);
+    }
+}
\ No newline at end of file

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

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/DigestUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java?rev=955699&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java Thu Jun 17 18:34:39 2010
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+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 class InstallableBundleResource implements InstallableResource {
+	private final String url;
+	private final String extension;
+	private final String digest;
+	private final InputStream inputStream;
+	private final int priority;
+
+	/** Default resource priority */
+	public static final int DEFAULT_PRIORITY = 100;
+
+	/** Create a data object that wraps an InputStream
+	 *  @param url unique URL of the supplied data, must start with the scheme used
+	 *     {@link OsgiInstaller#registerResources} call
+	 *  @param is the resource contents
+	 *  @param digest must be supplied by client. Does not need to be an actual digest
+	 *     of the contents, but must change if the contents change. Having this supplied
+	 *     by the client avoids having to compute real digests to find out if a resource
+	 *     has changed, which can be expensive.
+	 */
+	public InstallableBundleResource(String url, InputStream is, String digest) {
+	    this(url, is, digest, DEFAULT_PRIORITY);
+	}
+
+    /** Create a data object that wraps an InputStream
+     *  @param url unique URL of the supplied data, must start with the scheme used
+     *     {@link OsgiInstaller#registerResources} call
+     *  @param is the resource contents
+     *  @param digest must be supplied by client. Does not need to be an actual digest
+     *     of the contents, but must change if the contents change. Having this supplied
+     *     by the client avoids having to compute real digests to find out if a resource
+     *     has changed, which can be expensive.
+     */
+    public InstallableBundleResource(String url, InputStream is, String digest, final int priority) {
+        this.url = url;
+        this.extension = getExtension(url);
+        this.inputStream = is;
+        this.digest = digest;
+        this.priority = priority;
+    }
+
+    @Override
+	public String toString() {
+		return getClass().getSimpleName() + ", priority=" + priority + ", url=" + url;
+	}
+
+	/** Compute the extension */
+	private static String getExtension(String url) {
+		final int pos = url.lastIndexOf('.');
+		return (pos < 0 ? "" : url.substring(pos+1));
+	}
+
+	/** Return this data's URL. It is opaque for the {@link OsgiInstaller}
+	 * 	but the scheme must be the one used in the
+	 * 	{@link OsgiInstaller#registerResources} call.
+	 */
+	public String getUrl() {
+		return url;
+	}
+
+	/** Return this resource's extension, based on its URL */
+	public String getExtension() {
+		return extension;
+	}
+
+	/** Return an input stream with the data of this resource. Null if resource
+	 *  contains a dictionary instead. Caller is responsible for closing the stream.
+	 */
+	public InputStream getInputStream() {
+		return inputStream;
+	}
+
+	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
+	public Dictionary<String, Object> getDictionary() {
+		return null;
+	}
+
+	/** Return this resource's digest. Not necessarily an actual md5 or other digest of the
+	 *  data, can be any string that changes if the data changes.
+	 */
+	public String getDigest() {
+	    return digest;
+	}
+
+	/** Return the priority of this resource. Priorities are used to decide which
+	 *  resource to install when several are registered for the same OSGi entity
+	 *  (bundle, config, etc.)
+	 */
+    public int getPriority() {
+        return priority;
+    }
+}
\ No newline at end of file

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

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java?rev=955699&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java Thu Jun 17 18:34:39 2010
@@ -0,0 +1,120 @@
+/*
+ * 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;
+
+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 class InstallableConfigResource implements InstallableResource {
+	private final String url;
+	private final String extension;
+	private final String digest;
+	private final Dictionary<String, Object> dictionary;
+	private final int priority;
+
+	/** Default resource priority */
+	public static final int DEFAULT_PRIORITY = 100;
+
+	/** Create a data object that wraps a Dictionary. Digest will be computed
+	 *  by the installer in this case, as configuration dictionaries are
+	 *  usually small so computing a real digest to find out if they changed
+	 *  is ok.
+	 *
+     *  @param url unique URL of the supplied data, must start with the scheme used
+     *     {@link OsgiInstaller#registerResources} call
+	 */
+	public InstallableConfigResource(final String url, final Dictionary<String, Object> d) {
+		this(url, d, DEFAULT_PRIORITY);
+	}
+
+    /** Create a data object that wraps a Dictionary. Digest will be computed
+     *  by the installer in this case, as configuration dictionaries are
+     *  usually small so computing a real digest to find out if they changed
+     *  is ok.
+     *
+     *  @param url unique URL of the supplied data, must start with the scheme used
+     *     {@link OsgiInstaller#registerResources} call
+     */
+    public InstallableConfigResource(final String url, final Dictionary<String, Object> d, final int priority) {
+        this.url = url;
+        this.extension = getExtension(url);
+        this.dictionary = d;
+        try {
+            this.digest = url + ":" + DigestUtil.computeDigest(d);
+        } catch(Exception e) {
+            throw new IllegalStateException("Unexpected Exception while computing digest", e);
+        }
+        this.priority = priority;
+    }
+
+    @Override
+	public String toString() {
+		return getClass().getSimpleName() + ", priority=" + priority + ", url=" + url;
+	}
+
+	/** Compute the extension */
+	private static String getExtension(String url) {
+		final int pos = url.lastIndexOf('.');
+		return (pos < 0 ? "" : url.substring(pos+1));
+	}
+
+	/** Return this data's URL. It is opaque for the {@link OsgiInstaller}
+	 * 	but the scheme must be the one used in the
+	 * 	{@link OsgiInstaller#registerResources} call.
+	 */
+	public String getUrl() {
+		return url;
+	}
+
+	/** Return this resource's extension, based on its URL */
+	public String getExtension() {
+		return extension;
+	}
+
+	/** Return an input stream with the data of this resource. Null if resource
+	 *  contains a dictionary instead. Caller is responsible for closing the stream.
+	 */
+	public InputStream getInputStream() {
+		return null;
+	}
+
+	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
+	public Dictionary<String, Object> getDictionary() {
+		return dictionary;
+	}
+
+	/** Return this resource's digest. Not necessarily an actual md5 or other digest of the
+	 *  data, can be any string that changes if the data changes.
+	 */
+	public String getDigest() {
+	    return digest;
+	}
+
+	/** Return the priority of this resource. Priorities are used to decide which
+	 *  resource to install when several are registered for the same OSGi entity
+	 *  (bundle, config, etc.)
+	 */
+    public int getPriority() {
+        return priority;
+    }
+}
\ No newline at end of file

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

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Thu Jun 17 18:34:39 2010
@@ -18,181 +18,40 @@
  */
 package org.apache.sling.osgi.installer;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
 
 /** 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 class InstallableResource {
-	private final String url;
-	private final String extension;
-	private final String digest;
-	private final InputStream inputStream;
-	private final Dictionary<String, Object> dictionary;
-	private int priority;
-	private final boolean empty;
-    public static final String DIGEST_TYPE = "MD5";
-
-	/** Default resource priority */
-	public static final int DEFAULT_PRIORITY = 100;
-
-	/** 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;
-		this.digest = null;
-		this.priority = DEFAULT_PRIORITY;
-		this.empty = true;
-	}
-
-	/** Create a data object that wraps an InputStream
-	 *  @param url unique URL of the supplied data, must start with the scheme used
-	 *     {@link OsgiInstaller#registerResources} call
-	 *  @param is the resource contents
-	 *  @param digest must be supplied by client. Does not need to be an actual digest
-	 *     of the contents, but must change if the contents change. Having this supplied
-	 *     by the client avoids having to compute real digests to find out if a resource
-	 *     has changed, which can be expensive.
-	 */
-	public InstallableResource(String url, InputStream is, String digest) {
-		this.url = url;
-		this.extension = getExtension(url);
-		this.inputStream = is;
-		this.dictionary = null;
-		this.digest = digest;
-        this.priority = DEFAULT_PRIORITY;
-        this.empty = false;
-	}
-
-	/** Create a data object that wraps a Dictionary. Digest will be computed
-	 *  by the installer in this case, as configuration dictionaries are
-	 *  usually small so computing a real digest to find out if they changed
-	 *  is ok.
-	 *
-     *  @param url unique URL of the supplied data, must start with the scheme used
-     *     {@link OsgiInstaller#registerResources} call
-	 */
-	public InstallableResource(String url, Dictionary<String, Object> d) {
-		this.url = url;
-		this.extension = getExtension(url);
-		this.inputStream = null;
-		this.dictionary = d;
-		try {
-	        this.digest = url + ":" + computeDigest(d);
-		} catch(Exception e) {
-		    throw new IllegalStateException("Unexpected Exception while computing digest", e);
-		}
-        this.priority = DEFAULT_PRIORITY;
-        this.empty = false;
-	}
-
-	@Override
-	public String toString() {
-		return getClass().getSimpleName() + ", priority=" + priority + ", url=" + url;
-	}
-
-	/** Compute the extension */
-	private static String getExtension(String url) {
-		final int pos = url.lastIndexOf('.');
-		return (pos < 0 ? "" : url.substring(pos+1));
-	}
+public interface InstallableResource {
 
 	/** Return this data's URL. It is opaque for the {@link OsgiInstaller}
 	 * 	but the scheme must be the one used in the
 	 * 	{@link OsgiInstaller#registerResources} call.
 	 */
-	public String getUrl() {
-		return url;
-	}
+    String getUrl();
 
 	/** Return this resource's extension, based on its URL */
-	public String getExtension() {
-		return extension;
-	}
+    String getExtension();
 
 	/** Return an input stream with the data of this resource. Null if resource
 	 *  contains a dictionary instead. Caller is responsible for closing the stream.
 	 */
-	public InputStream getInputStream() {
-		return inputStream;
-	}
+    InputStream getInputStream();
 
 	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
-	public Dictionary<String, Object> getDictionary() {
-		return dictionary;
-	}
+	Dictionary<String, Object> getDictionary();
 
 	/** Return this resource's digest. Not necessarily an actual md5 or other digest of the
 	 *  data, can be any string that changes if the data changes.
 	 */
-	public String getDigest() {
-	    return digest;
-	}
+    String getDigest();
 
 	/** Return the priority of this resource. Priorities are used to decide which
 	 *  resource to install when several are registered for the same OSGi entity
 	 *  (bundle, config, etc.)
 	 */
-    public int getPriority() {
-        return priority;
-    }
-
-    /** Set the priority of this resource */
-    public void setPriority(int priority) {
-        this.priority = priority;
-    }
-
-    /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
-    public static String digestToString(MessageDigest d) {
-        final BigInteger bigInt = new BigInteger(1, d.digest());
-        return new String(bigInt.toString(16));
-    }
-
-    /** Compute digest on all keys of supplied data */
-    public static String computeDigest(Dictionary<String, Object> data) throws IOException, NoSuchAlgorithmException {
-    	return computeDigest(data, null);
-    }
-
-    /** Digest is needed to detect changes in data, and must not depend on dictionary ordering */
-    public static String computeDigest(Dictionary<String, Object> data, Set<String> keysToIgnore) throws IOException, NoSuchAlgorithmException {
-        final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE);
-        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        final ObjectOutputStream oos = new ObjectOutputStream(bos);
-
-        final SortedSet<String> sortedKeys = new TreeSet<String>();
-        if(data != null) {
-            for(Enumeration<String> e = data.keys(); e.hasMoreElements(); ) {
-            	final String key = e.nextElement();
-            	if(keysToIgnore == null || !keysToIgnore.contains(key)) {
-            		sortedKeys.add(key);
-            	}
-            }
-        }
-        for(String key : sortedKeys) {
-        	oos.writeObject(key);
-        	oos.writeObject(data.get(key));
-        }
-
-        bos.flush();
-        d.update(bos.toByteArray());
-        return digestToString(d);
-    }
-
-    public boolean isEmpty() {
-    	return empty;
-    }
-}
\ No newline at end of file
+    int getPriority();
+}

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Thu Jun 17 18:34:39 2010
@@ -56,7 +56,7 @@ public interface OsgiInstaller {
 
 	/** Inform the installer that a resource is no longer available
 	 * 	@param r an empty InstallableResource, isEmpty() must return true */
-	void removeResource(InstallableResource r);
+	void removeResource(String url);
 
 	/** Return counters used for statistics, console display, testing, etc. */
 	long [] getCounters();

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=955699&r1=955698&r2=955699&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 Thu Jun 17 18:34:39 2010
@@ -109,22 +109,22 @@ public class OsgiInstallerImpl implement
 	/**
 	 * @see org.apache.sling.osgi.installer.OsgiInstaller#addResource(org.apache.sling.osgi.installer.InstallableResource)
 	 */
-	public void addResource(InstallableResource r) {
+	public void addResource(final InstallableResource r) {
         installerThread.addNewResource(r);
 	}
 
 	/**
 	 * @see org.apache.sling.osgi.installer.OsgiInstaller#registerResources(java.util.Collection, java.lang.String)
 	 */
-	public void registerResources(Collection<InstallableResource> data, String urlScheme) {
+	public void registerResources(final Collection<InstallableResource> data, String urlScheme) {
         installerThread.addNewResources(data, urlScheme, bundleContext);
 	}
 
 	/**
-	 * @see org.apache.sling.osgi.installer.OsgiInstaller#removeResource(org.apache.sling.osgi.installer.InstallableResource)
+	 * @see org.apache.sling.osgi.installer.OsgiInstaller#removeResource(java.lang.String)
 	 */
-	public void removeResource(InstallableResource r) {
-        installerThread.removeResource(r);
+	public void removeResource(final String url) {
+        installerThread.removeResource(url);
 	}
 
 	public void incrementCounter(int index) {

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=955699&r1=955698&r2=955699&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 Thu Jun 17 18:34:39 2010
@@ -133,16 +133,12 @@ class OsgiInstallerThread extends Thread
     }
 
     /** Register a resource for removal, or ignore if we don't have that URL */
-    void removeResource(InstallableResource r) {
-		if(!r.isEmpty()) {
-			throw new IllegalArgumentException("removeResource() got non-empty InstallableResource: " + r);
-		}
-
+    void removeResource(String url) {
 		// Will mark all resources which have r's URL as uninstallable
-		ctx.logDebug("Adding URL " + r.getUrl() + " to urlsToRemove");
+		ctx.logDebug("Adding URL " + url + " to urlsToRemove");
 
         synchronized (newResources) {
-            urlsToRemove.add(r.getUrl());
+            urlsToRemove.add(url);
             newResources.notify();
         }
     }

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=955699&r1=955698&r2=955699&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 Thu Jun 17 18:34:39 2010
@@ -24,7 +24,7 @@ import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.DigestUtil;
 import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
 import org.osgi.service.cm.Configuration;
@@ -111,8 +111,8 @@ public class ConfigInstallTask extends A
     boolean isSameData(Dictionary<String, Object>a, Dictionary<String, Object>b) throws NoSuchAlgorithmException, IOException {
     	boolean result = false;
     	if(a != null && b != null) {
-    		final String da = InstallableResource.computeDigest(a, ignoredProperties);
-    		final String db = InstallableResource.computeDigest(b, ignoredProperties);
+    		final String da = DigestUtil.computeDigest(a, ignoredProperties);
+    		final String db = DigestUtil.computeDigest(b, ignoredProperties);
     		result = da.equals(db);
     	}
     	return result;

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java Thu Jun 17 18:34:39 2010
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTru
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.DigestUtil;
 
 public class DictionaryDigestTest {
 	private void setTestData(Hashtable<String, Object> d) {
@@ -32,10 +32,10 @@ public class DictionaryDigestTest {
 		d.put("long", new Long(12));
 		d.put("array", new String[] { "a", "b"});
 	}
-	
-	private String testDigestChanged(Dictionary<String, Object> d, 
+
+	private String testDigestChanged(Dictionary<String, Object> d,
 			String oldDigest, int step, boolean shouldChange) throws Exception {
-		final String newDigest = InstallableResource.computeDigest(d);
+		final String newDigest = DigestUtil.computeDigest(d);
 		if(shouldChange) {
 			assertTrue("Digest (" + newDigest + ") should have changed at step " + step, !newDigest.equals(oldDigest));
 		} else {
@@ -43,43 +43,43 @@ public class DictionaryDigestTest {
 		}
 		return newDigest;
 	}
-	
+
 	@org.junit.Test public void testDictionaryDigestSameData() throws Exception {
 		final Hashtable<String, Object> d1 = new Hashtable<String, Object>();
 		final Hashtable<String, Object> d2 = new Hashtable<String, Object>();
-		
+
 		setTestData(d1);
 		setTestData(d2);
-		
+
 		assertEquals(
-				"Two dictionary with same values have the same key", 
-				InstallableResource.computeDigest(d1),
-				InstallableResource.computeDigest(d2)
+				"Two dictionary with same values have the same key",
+				DigestUtil.computeDigest(d1),
+				DigestUtil.computeDigest(d2)
 		);
 	}
-	
+
 	@org.junit.Test public void testDictionaryDigestChanges() throws Exception {
 		String digest = "";
 		int step = 1;
-		
+
 		final Dictionary<String, Object> d = new Hashtable<String, Object>();
 		digest = testDigestChanged(d, digest, step, true);
 		digest = testDigestChanged(d, digest, step, false);
-		
+
 		d.put("key", "value");
 		digest = testDigestChanged(d, digest, step, true);
 		d.put("key", "value");
 		digest = testDigestChanged(d, digest, step, false);
 		d.put("key", "valueB");
 		digest = testDigestChanged(d, digest, step, true);
-		                		
+
 		d.put("int", new Integer(12));
 		digest = testDigestChanged(d, digest, step, true);
 		d.put("int", new Integer(12));
 		digest = testDigestChanged(d, digest, step, false);
 		d.put("int", new Integer(13));
 		digest = testDigestChanged(d, digest, step, true);
-		
+
 		d.put("array", new String [] { "a", "b", "c"});
 		digest = testDigestChanged(d, digest, step, true);
 		d.put("array", new String [] { "a", "b", "c"});
@@ -89,21 +89,21 @@ public class DictionaryDigestTest {
 		d.put("another", new String [] { "a", "b", "D"});
 		digest = testDigestChanged(d, digest, step, true);
 	}
-	
+
 	@org.junit.Test public void testDictionaryOrderDoesNotMatter() throws Exception {
 		final Dictionary<String, Object> a = new Hashtable<String, Object>();
 		a.put("one", "A");
 		a.put("two", "B");
 		a.put("three", "C");
-		
+
 		final Dictionary<String, Object> b = new Hashtable<String, Object>();
 		b.put("two", "B");
 		b.put("one", "A");
 		b.put("three", "C");
-		
-		assertEquals("Same data in different order must have same digest", 
-				InstallableResource.computeDigest(a),
-				InstallableResource.computeDigest(b)
+
+		assertEquals("Same data in different order must have same digest",
+		        DigestUtil.computeDigest(a),
+		        DigestUtil.computeDigest(b)
 		);
 	}
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java Thu Jun 17 18:34:39 2010
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNot
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.junit.Test;
 
@@ -32,7 +33,7 @@ public class InstallableResourceTest {
     @Test
     public void testDictionaryDigest() {
         final Dictionary<String, Object> d = new Hashtable<String, Object>();
-        final InstallableResource r = new InstallableResource("x:url", d);
+        final InstallableResource r = new InstallableConfigResource("x:url", d);
         assertNotNull("Expected InstallableResource to compute its own digest", r.getDigest());
     }
 
@@ -48,8 +49,8 @@ public class InstallableResourceTest {
             d2.put(keys[i], keys[i] + "." + keys[i]);
         }
 
-        final InstallableResource r1 = new InstallableResource("test:url1", d1);
-        final InstallableResource r2 = new InstallableResource("test:url1", d2);
+        final InstallableResource r1 = new InstallableConfigResource("test:url1", d1);
+        final InstallableResource r2 = new InstallableConfigResource("test:url1", d2);
 
         assertEquals(
                 "Two InstallableResource (Dictionary) with same values but different key orderings must have the same key",

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=955699&r1=955698&r2=955699&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java Thu Jun 17 18:34:39 2010
@@ -25,7 +25,7 @@ import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableBundleResource;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
@@ -39,11 +39,11 @@ public class MockBundleResource implemen
 	private final int priority;
 	private final long serialNumber;
 	private static long serialNumberCounter = System.currentTimeMillis();
-	
+
     MockBundleResource(String symbolicName, String version) {
-        this(symbolicName, version, InstallableResource.DEFAULT_PRIORITY);
+        this(symbolicName, version, InstallableBundleResource.DEFAULT_PRIORITY);
     }
-    
+
 	MockBundleResource(String symbolicName, String version, int priority) {
 		attributes.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
 		attributes.put(Constants.BUNDLE_VERSION, version);
@@ -51,7 +51,7 @@ public class MockBundleResource implemen
 		this.priority = priority;
 		serialNumber = getNextSerialNumber();
 	}
-	
+
     MockBundleResource(String symbolicName, String version, int priority, String digest) {
         attributes.put(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
         attributes.put(Constants.BUNDLE_VERSION, version);
@@ -59,23 +59,23 @@ public class MockBundleResource implemen
         this.priority = priority;
         serialNumber = getNextSerialNumber();
     }
-    
+
     private static long getNextSerialNumber() {
         synchronized (MockBundleResource.class) {
-            return serialNumberCounter++; 
+            return serialNumberCounter++;
         }
     }
-    
+
 	@Override
 	public String toString() {
-	    return getClass().getSimpleName() 
+	    return getClass().getSimpleName()
 	    + ", n=" + attributes.get(Constants.BUNDLE_SYMBOLICNAME)
         + ", v= " + attributes.get(Constants.BUNDLE_VERSION)
         + ", d=" + digest
         + ", p=" + priority
         ;
 	}
-	
+
 	public void cleanup(OsgiInstallerContext ctx) {
 	}
 
@@ -110,7 +110,7 @@ public class MockBundleResource implemen
 	public String getURL() {
 		return null;
 	}
-	
+
     public String getUrlScheme() {
         return null;
     }
@@ -122,11 +122,11 @@ public class MockBundleResource implemen
     public void setInstallable(boolean installable) {
         this.installable = installable;
     }
-    
+
     public int getPriority() {
         return priority;
     }
-    
+
     public long getSerialNumber() {
         return serialNumber;
     }

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=955699&r1=955698&r2=955699&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 Thu Jun 17 18:34:39 2010
@@ -28,11 +28,11 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.junit.Test;
 
 public class RegisteredResourceComparatorTest {
-    
+
     private void assertOrder(Set<RegisteredResource> toTest, RegisteredResource[] inOrder) {
         assertEquals("Expected sizes to match", toTest.size(), inOrder.length);
         int i = 0;
@@ -42,17 +42,16 @@ public class RegisteredResourceComparato
             i++;
         }
     }
-    
+
     private RegisteredResource getConfig(String url, Dictionary<String, Object> data, int priority) throws IOException {
         if(data == null) {
             data = new Hashtable<String, Object>();
             data.put("foo", "bar");
         }
-        final InstallableResource r = new InstallableResource("test:" + url, data);
-        r.setPriority(priority);
+        final InstallableConfigResource r = new InstallableConfigResource("test:" + url, data, priority);
         return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r);
     }
-    
+
     private void assertOrder(RegisteredResource[] inOrder) {
         final SortedSet<RegisteredResource> toTest = new TreeSet<RegisteredResource>(new RegisteredResourceComparator());
         for(int i = inOrder.length - 1 ; i >= 0; i--) {
@@ -65,7 +64,7 @@ public class RegisteredResourceComparato
         }
         assertOrder(toTest, inOrder);
     }
-    
+
     @Test
     public void testBundleName() {
         final RegisteredResource [] inOrder = {
@@ -76,7 +75,7 @@ public class RegisteredResourceComparato
         };
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testBundleVersion() {
         final RegisteredResource [] inOrder = {
@@ -88,7 +87,7 @@ public class RegisteredResourceComparato
         };
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testBundlePriority() {
         final RegisteredResource [] inOrder = {
@@ -99,7 +98,7 @@ public class RegisteredResourceComparato
         };
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testComposite() {
         final RegisteredResource [] inOrder = {
@@ -112,7 +111,7 @@ public class RegisteredResourceComparato
         };
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testBundleDigests() {
         final RegisteredResource a = new MockBundleResource("a", "1.2.0", 0, "digestA");
@@ -120,7 +119,7 @@ public class RegisteredResourceComparato
         final RegisteredResourceComparator c = new RegisteredResourceComparator();
         assertEquals("Digests must not be included in bundles comparison", 0, c.compare(a, b));
     }
-    
+
     @Test
     public void testSnapshotSerialNumber() {
         // Verify that snapshots with a higher serial number come first
@@ -130,16 +129,16 @@ public class RegisteredResourceComparato
         inOrder[0] = new MockBundleResource("a", "1.2.0.SNAPSHOT", 0, "digestA");
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testConfigPriority() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [3];
-        inOrder[0] = getConfig("pid", null, 2); 
-        inOrder[1] = getConfig("pid", null, 1); 
-        inOrder[2] = getConfig("pid", null, 0); 
+        inOrder[0] = getConfig("pid", null, 2);
+        inOrder[1] = getConfig("pid", null, 1);
+        inOrder[2] = getConfig("pid", null, 0);
         assertOrder(inOrder);
     }
-    
+
     @Test
     /** Digests must not be included in comparisons: a and b might represent the same
      * 	config even if their digests are different */
@@ -152,29 +151,29 @@ public class RegisteredResourceComparato
         final RegisteredResourceComparator c = new RegisteredResourceComparator();
         assertEquals("Digests must not be included in configs comparison", 0, c.compare(a, b));
     }
-    
+
     @Test
     public void testConfigPid() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [3];
-        inOrder[0] = getConfig("pidA", null, 0); 
-        inOrder[1] = getConfig("pidB", null, 0); 
-        inOrder[2] = getConfig("pidC", null, 0); 
+        inOrder[0] = getConfig("pidA", null, 0);
+        inOrder[1] = getConfig("pidB", null, 0);
+        inOrder[2] = getConfig("pidC", null, 0);
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testConfigComposite() throws IOException {
         final RegisteredResource [] inOrder = new RegisteredResource [4];
-        inOrder[0] = getConfig("pidA", null, 10); 
-        inOrder[1] = getConfig("pidA", null, 0); 
-        inOrder[2] = getConfig("pidB", null, 1); 
-        inOrder[3] = getConfig("pidB", null, 0); 
+        inOrder[0] = getConfig("pidA", null, 10);
+        inOrder[1] = getConfig("pidA", null, 0);
+        inOrder[2] = getConfig("pidB", null, 1);
+        inOrder[3] = getConfig("pidB", null, 0);
         assertOrder(inOrder);
     }
-    
+
     @Test
     public void testConfigAndBundle() throws IOException {
-    	final RegisteredResource cfg = getConfig("pid", null, InstallableResource.DEFAULT_PRIORITY);
+    	final RegisteredResource cfg = getConfig("pid", null, InstallableConfigResource.DEFAULT_PRIORITY);
     	final RegisteredResource b = new MockBundleResource("a", "1.0");
     	final RegisteredResourceComparator c = new RegisteredResourceComparator();
     	assertEquals("bundle is > config when compared", 1, c.compare(b, cfg));

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=955699&r1=955698&r2=955699&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 Thu Jun 17 18:34:39 2010
@@ -18,8 +18,8 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -34,24 +34,26 @@ import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.apache.sling.osgi.installer.InstallableBundleResource;
+import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.osgi.framework.Constants;
 
 public class RegisteredResourceTest {
-	
+
     public static final String TEST_URL = "test:url";
-    
+
     static File getTestBundle(String name) {
         return new File(System.getProperty("osgi.installer.base.dir"),
                 "org.apache.sling.osgi.installer-" + System.getProperty("osgi.installer.pom.version") + "-" + name);
     }
-    
+
 	@org.junit.Test public void testStreamIsClosed() throws Exception {
 		final String data = "some data";
-		
+
 		class TestInputStream extends FilterInputStream {
 			int closeCount;
-			
+
 			TestInputStream(InputStream i) {
 				super(i);
 			}
@@ -61,21 +63,21 @@ public class RegisteredResourceTest {
 				super.close();
 				closeCount++;
 			}
-			
+
 		}
-		
+
 		final TestInputStream t = new TestInputStream(new ByteArrayInputStream(data.getBytes()));
-		final InstallableResource ir = new InstallableResource(TEST_URL, t, "somedigest");
+		final InstallableResource ir = new InstallableBundleResource(TEST_URL, t, "somedigest");
 		assertEquals("TestInputStream must not be closed before test", 0, t.closeCount);
 		new LocalFileRegisteredResource(ir);
 		assertEquals("TestInputStream must be closed by RegisteredResource", 1, t.closeCount);
 	}
-	
+
     @org.junit.Test public void testResourceType() throws Exception {
         {
             final InputStream s = new FileInputStream(getTestBundle("testbundle-1.0.jar"));
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, "some digest"));
-            assertEquals(".jar URL creates a BUNDLE resource", 
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableBundleResource("test:1.jar", s, "some digest"));
+            assertEquals(".jar URL creates a BUNDLE resource",
                     RegisteredResource.ResourceType.BUNDLE, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNotNull("BUNDLE resource provides an InputStream", rs);
@@ -83,11 +85,11 @@ public class RegisteredResourceTest {
             assertNull("BUNDLE resource does not provide a Dictionary", r.getDictionary());
             assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
         }
-        
+
         {
             final InputStream s = new ByteArrayInputStream("foo=bar\nother=2".getBytes());
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.properties", s, "digest1"));
-            assertEquals(".properties URL creates a CONFIG resource", 
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableBundleResource("test:1.properties", s, "digest1"));
+            assertEquals(".properties URL creates a CONFIG resource",
                     RegisteredResource.ResourceType.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNull("CONFIG resource does not provide an InputStream", rs);
@@ -96,13 +98,13 @@ public class RegisteredResourceTest {
             assertEquals("CONFIG resource dictionary has two properties", 2, d.size());
             assertNotNull("CONFIG resource has a pid attribute", r.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE));
         }
-        
+
         {
             final Hashtable<String, Object> data = new Hashtable<String, Object>();
             data.put("foo", "bar");
             data.put("other", 2);
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1", data));
-            assertEquals("No-extension URL with Dictionary creates a CONFIG resource", 
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableConfigResource("test:1", data));
+            assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
                     RegisteredResource.ResourceType.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNull("CONFIG resource does not provide an InputStream", rs);
@@ -112,60 +114,60 @@ public class RegisteredResourceTest {
             assertNotNull("CONFIG resource has a pid attribute", r.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE));
         }
     }
-    
+
 	@org.junit.Test public void testLocalFileCopy() throws Exception {
 	    final File f = getTestBundle("testbundle-1.0.jar");
         final InputStream s = new FileInputStream(f);
-		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, "somedigest"));
+		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableBundleResource("test:1.jar", s, "somedigest"));
 		assertTrue("Local file exists", r.getDataFile(null).exists());
-		
+
 		assertEquals("Local file length matches our data", f.length(), r.getDataFile(null).length());
 	}
-	
+
     @org.junit.Test public void testMissingDigest() throws Exception {
         final String data = "This is some data";
         final InputStream in = new ByteArrayInputStream(data.getBytes());
-        
+
         try {
-            new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, null));
+            new LocalFileRegisteredResource(new InstallableBundleResource("test:1.jar", in, null));
             fail("With jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
-        
+
         try {
-            new LocalFileRegisteredResource(new InstallableResource("test:1.foo", in, null));
+            new LocalFileRegisteredResource(new InstallableBundleResource("test:1.foo", in, null));
             fail("With non-jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
     }
-    
+
     @org.junit.Test public void testBundleManifest() throws Exception {
         final File f = getTestBundle("testbundle-1.0.jar");
-        final InstallableResource i = new InstallableResource("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName());
+        final InstallableResource i = new InstallableBundleResource("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNotNull("RegisteredResource must have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
     }
-    
+
     @org.junit.Test public void testConfigEntity() throws Exception {
-        final InstallableResource i = new InstallableResource("test:/foo/someconfig", new Hashtable<String, Object>());
+        final InstallableResource i = new InstallableConfigResource("test:/foo/someconfig", new Hashtable<String, Object>());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNull("RegisteredResource must not have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
     }
-    
+
     @org.junit.Test public void testConfigDigestIncludesUrl() throws Exception {
         final Dictionary<String, Object> data = new Hashtable<String, Object>();
-        final InstallableResource rA = new InstallableResource("test:urlA", data);
-        final InstallableResource rB = new InstallableResource("test:urlB", data);
+        final InstallableResource rA = new InstallableConfigResource("test:urlA", data);
+        final InstallableResource rB = new InstallableConfigResource("test:urlB", data);
         assertFalse(
                 "Expecting configs with same data but different URLs to have different digests",
                 rA.getDigest().equals(rB.getDigest()));
     }
-    
+
     @org.junit.Test public void testUrlScheme() throws Exception {
         final ByteArrayInputStream s = new ByteArrayInputStream("foo".getBytes());
-        
+
 
         final String [] badOnes = {
                 "",
@@ -175,22 +177,22 @@ public class RegisteredResourceTest {
         };
         for(String url : badOnes) {
             try {
-                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, s, null));
+                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableBundleResource(url, s, null));
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
             } catch(IllegalArgumentException asExpected) {
             }
         }
-        
+
         final String [] goodOnes = {
             "foo:bar",
             "foo:bar:",
             "foo::bar",
             "foo://bar",
         };
-        
+
         for(String url : goodOnes) {
-            final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(), 
-                    new InstallableResource(url, s, "digest1"));
+            final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),
+                    new InstallableBundleResource(url, s, "digest1"));
             assertEquals("Expected scheme 'foo' for URL " + url, "foo", 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=955699&r1=955698&r2=955699&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 Jun 17 18:34:39 2010
@@ -26,7 +26,7 @@ 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.InstallableConfigResource;
 import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask;
 import org.apache.sling.osgi.installer.impl.tasks.BundleRemoveTask;
 import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask;
@@ -41,17 +41,17 @@ import org.apache.sling.osgi.installer.i
 public class TaskOrderingTest {
 
 	private Set<OsgiInstallerTask> taskSet;
-	
+
 	@org.junit.Before public void setUp() {
 	    // The data type must be consistent with the "tasks" member
 	    // of the {@link OsgiControllerImpl} class.
-		taskSet = new TreeSet<OsgiInstallerTask>(); 
+		taskSet = new TreeSet<OsgiInstallerTask>();
 	}
-	
+
 	private static RegisteredResource getRegisteredResource(String url) throws IOException {
-		return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, new Hashtable<String, Object>()));
+		return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableConfigResource(url, new Hashtable<String, Object>()));
 	}
-	
+
 	private void assertOrder(int testId, Collection<OsgiInstallerTask> actual, OsgiInstallerTask [] expected) {
 		int index = 0;
 		for(OsgiInstallerTask t : actual) {
@@ -61,20 +61,20 @@ public class TaskOrderingTest {
 			index++;
 		}
 	}
-	
-	@org.junit.Test 
+
+	@org.junit.Test
 	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")),
+            new ConfigInstallTask(getRegisteredResource("test:a")),
 		    new BundleRemoveTask(getRegisteredResource("test:url")),
 		    new BundleUpdateTask(getRegisteredResource("test:url")),
 		    new BundleInstallTask(getRegisteredResource("test:url")),
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
-	
+
 		taskSet.clear();
         taskSet.add(tasksInOrder[6]);
 		taskSet.add(tasksInOrder[5]);
@@ -83,9 +83,9 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[2]);
         taskSet.add(tasksInOrder[1]);
         taskSet.add(tasksInOrder[0]);
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
-		
+
 		taskSet.clear();
         taskSet.add(tasksInOrder[0]);
         taskSet.add(tasksInOrder[1]);
@@ -94,9 +94,9 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[4]);
 		taskSet.add(tasksInOrder[5]);
 		taskSet.add(tasksInOrder[6]);
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
-		
+
 		taskSet.clear();
 		taskSet.add(tasksInOrder[3]);
 		taskSet.add(tasksInOrder[2]);
@@ -105,9 +105,9 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[4]);
         taskSet.add(tasksInOrder[1]);
 		taskSet.add(tasksInOrder[6]);
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
-		
+
 		taskSet.clear();
 		taskSet.add(tasksInOrder[4]);
 		taskSet.add(tasksInOrder[5]);
@@ -116,11 +116,11 @@ public class TaskOrderingTest {
 		taskSet.add(tasksInOrder[2]);
 		taskSet.add(tasksInOrder[3]);
         taskSet.add(tasksInOrder[1]);
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
-	
-	@org.junit.Test 
+
+	@org.junit.Test
 	public void testMultipleConfigAndBundles() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
@@ -129,23 +129,23 @@ public class TaskOrderingTest {
 			new SynchronousRefreshPackagesTask(),
 			new BundleStartTask(0),
 		};
-	
+
 		taskSet.clear();
 		for(int i = tasksInOrder.length -1 ; i >= 0; i--) {
 			taskSet.add(tasksInOrder[i]);
 		}
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
-		
+
         taskSet.clear();
         for(int i = 0 ; i < tasksInOrder.length; i++) {
             taskSet.add(tasksInOrder[i]);
         }
-        
+
         assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
-	
-	@org.junit.Test 
+
+	@org.junit.Test
 	public void testMultipleRefreshAndStart() throws Exception {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
@@ -154,7 +154,7 @@ public class TaskOrderingTest {
 			new BundleStartTask(0),
 			new BundleStartTask(1),
 		};
-		
+
 		taskSet.clear();
 		taskSet.add(tasksInOrder[3]);
 		taskSet.add(tasksInOrder[3]);
@@ -175,11 +175,11 @@ public class TaskOrderingTest {
 		taskSet.add(new SynchronousRefreshPackagesTask());
 		taskSet.add(tasksInOrder[1]);
 		taskSet.add(new SynchronousRefreshPackagesTask());
-		
+
 		assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
-	
-	@org.junit.Test 
+
+	@org.junit.Test
 	public void testBundleStartOrder() {
 		int testIndex = 1;
 		final OsgiInstallerTask [] tasksInOrder = {
@@ -189,18 +189,18 @@ public class TaskOrderingTest {
 			new BundleStartTask(11),
 			new BundleStartTask(51)
 		};
-		
+
 		taskSet.clear();
 		for(int i = tasksInOrder.length -1 ; i >= 0; i--) {
 			taskSet.add(tasksInOrder[i]);
 		}
 		assertOrder(testIndex++, taskSet, tasksInOrder);
-		
+
         taskSet.clear();
         for(int i = 0 ; i < tasksInOrder.length; i++) {
             taskSet.add(tasksInOrder[i]);
         }
-        
+
         assertOrder(testIndex++, taskSet, tasksInOrder);
 	}
 }



Mime
View raw message