incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r955865 - 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 Fri, 18 Jun 2010 07:22:19 GMT
Author: cziegeler
Date: Fri Jun 18 07:22:18 2010
New Revision: 955865

URL: http://svn.apache.org/viewvc?rev=955865&view=rev
Log:
SLING-1560 : Improve and clean up code
Make InstallableResource an interface again and create a factory service

Added:
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.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/FindPathsToWatchTest.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstallTestBase.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/ScanningLoopTest.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -30,6 +30,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,15 +43,16 @@ class ConfigNodeConverter implements Jcr
 	/** Convert n to an InstallableData, or return null
 	 * 	if we don't know how to convert it.
 	 */
-	/**
-	 * @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 {
+	public InstallableResource convertNode(final String urlScheme,
+	        final Node n,
+	        final int priority,
+	        final InstallableResourceFactory factory)
+	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), priority);
+			result = factory.create(urlScheme + ":" + n.getPath(), load(n), null, null, priority);
 			log.debug("Converted node {} to {}", n.getPath(), result);
 		} else {
 			log.debug("Node is not a {} node, ignored:{}", CONFIG_NODE_TYPE, n.getPath());

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -24,6 +24,7 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,14 +42,18 @@ import org.slf4j.LoggerFactory;
     private final Logger log = LoggerFactory.getLogger(getClass());
 
 	/**
-	 * @see org.apache.sling.jcr.jcrinstall.impl.JcrInstaller.NodeConverter#convertNode(java.lang.String, javax.jcr.Node, int)
+	 * @see org.apache.sling.jcr.jcrinstall.impl.JcrInstaller.NodeConverter#convertNode(java.lang.String, javax.jcr.Node, int, org.apache.sling.osgi.installer.InstallableResourceFactory)
 	 */
-	public InstallableResource convertNode(String urlScheme, Node n, final int priority) throws RepositoryException {
+	public InstallableResource convertNode(final String urlScheme,
+	        final Node n,
+	        final int priority,
+	        final InstallableResourceFactory factory)
+	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(), priority);
+					result = convert(urlScheme, n, n.getPath(), priority, factory);
 				} catch(IOException ioe) {
 					log.info("Conversion failed, node {} ignored ({})", n.getPath(), ioe);
 				}
@@ -62,7 +67,12 @@ import org.slf4j.LoggerFactory;
 		return null;
 	}
 
-	private InstallableResource convert(String urlScheme, Node n, String path, final int priority) throws IOException, RepositoryException {
+	private InstallableResource convert(final String urlScheme,
+	        final Node n,
+	        final String path,
+	        final int priority,
+	        final InstallableResourceFactory factory)
+    throws IOException, RepositoryException {
 		String digest = null;
         if (n.hasProperty(JCR_CONTENT_LAST_MODIFIED)) {
         	digest = String.valueOf(n.getProperty(JCR_CONTENT_LAST_MODIFIED).getDate().getTimeInMillis());
@@ -77,7 +87,7 @@ import org.slf4j.LoggerFactory;
         	throw new IOException("Missing " + JCR_CONTENT_DATA + " property");
         }
 
-        return new InstallableResource(urlScheme + ":" + path, is, digest, priority);
+        return factory.create(urlScheme + ":" + path, is, digest, null, priority);
 	}
 
 	boolean acceptNodeName(String name) {

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -36,6 +36,7 @@ import javax.jcr.observation.EventListen
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.apache.sling.runmode.RunMode;
 import org.osgi.service.component.ComponentContext;
@@ -89,6 +90,11 @@ public class JcrInstaller implements Eve
      */
     private OsgiInstaller installer;
 
+    /** The installable resource factory
+     *  @scr.reference
+     */
+    private InstallableResourceFactory installableResourceFactory;
+
     /** Default regexp for watched folders */
     public static final String DEFAULT_FOLDER_NAME_REGEXP = ".*/install$";
 
@@ -131,7 +137,8 @@ public class JcrInstaller implements Eve
 
     /** Convert Nodes to InstallableResources */
     static interface NodeConverter {
-    	InstallableResource convertNode(String urlScheme, Node n, int priority) throws Exception;
+    	InstallableResource convertNode(String urlScheme, Node n, int priority, InstallableResourceFactory factory)
+    	throws Exception;
     }
 
     /** Our NodeConverters*/
@@ -328,7 +335,7 @@ public class JcrInstaller implements Eve
         final String path = n.getPath();
         final int priority = folderNameFilter.getPriority(path);
         if (priority > 0) {
-            result.add(new WatchedFolder(session, path, priority, URL_SCHEME, converters));
+            result.add(new WatchedFolder(session, path, priority, URL_SCHEME, converters, installableResourceFactory));
         }
         final int depth = path.split("/").length;
         if(depth > maxWatchedFolderDepth) {
@@ -397,7 +404,8 @@ public class JcrInstaller implements Eve
                 for(String path : changedPaths) {
                     // Deletions are handled below
                     if(folderNameFilter.getPriority(path) > 0  && session.itemExists(path)) {
-                        addWatchedFolder(new WatchedFolder(session, path, folderNameFilter.getPriority(path), URL_SCHEME, converters));
+                        addWatchedFolder(new WatchedFolder(session, path,
+                                folderNameFilter.getPriority(path), URL_SCHEME, converters, installableResourceFactory));
                     }
                 }
             }

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -36,6 +36,7 @@ import javax.jcr.observation.EventIterat
 import javax.jcr.observation.EventListener;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,6 +44,7 @@ import org.slf4j.LoggerFactory;
  *  to it and providing InstallableData for its contents.
  */
 class WatchedFolder implements EventListener{
+
     private final String path;
     private final int priority;
     private final Session session;
@@ -53,6 +55,10 @@ class WatchedFolder implements EventList
     private final Set<String> existingResourceUrls = new HashSet<String>();
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
+    /** Installable resource factory. */
+    private final InstallableResourceFactory factory;
+
+
     static class ScanResult {
         List<InstallableResource> toAdd = new ArrayList<InstallableResource>();
         List<String> toRemove = new ArrayList<String>();
@@ -61,8 +67,13 @@ class WatchedFolder implements EventList
     /** 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,
-    		String urlScheme, Collection<JcrInstaller.NodeConverter> converters) throws RepositoryException {
+    WatchedFolder(final Session session,
+            final String path,
+            final int priority,
+    		final String urlScheme,
+    		final Collection<JcrInstaller.NodeConverter> converters,
+    		final InstallableResourceFactory factory)
+    throws RepositoryException {
         if(priority < 1) {
             throw new IllegalArgumentException("Cannot watch folder with priority 0:" + path);
         }
@@ -83,6 +94,8 @@ class WatchedFolder implements EventList
         session.getWorkspace().getObservationManager().addEventListener(this, eventTypes, path,
                 isDeep, null, null, noLocal);
 
+        this.factory = factory;
+
         log.info("Watching folder {} (priority {})", path, priority);
     }
 
@@ -144,7 +157,7 @@ class WatchedFolder implements EventList
             while(it.hasNext()) {
             	final Node n = it.nextNode();
             	for(JcrInstaller.NodeConverter nc : converters) {
-            		final InstallableResource r = nc.convertNode(urlScheme, n, priority);
+            		final InstallableResource r = nc.convertNode(urlScheme, n, priority, factory);
             		if(r != null) {
             			resourcesSeen.add(r.getUrl());
             		    final String oldDigest = digests.get(r.getUrl());

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java?rev=955865&r1=955864&r2=955865&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java Fri Jun 18 07:22:18 2010
@@ -26,15 +26,15 @@ import org.apache.sling.commons.testing.
 import org.apache.sling.jcr.api.SlingRepository;
 
 /** Verify that the JcrInstaller finds all folders that must
- *  be watched, including those created after it starts  
+ *  be watched, including those created after it starts
  */
 public class FindPathsToWatchTest extends RepositoryTestBase {
-    
+
     public static final long TIMEOUT = 5000L;
-    
+
     SlingRepository repo;
     Session session;
-    private EventHelper eventHelper; 
+    private EventHelper eventHelper;
     private ContentHelper contentHelper;
     private JcrInstaller installer;
     private MockOsgiInstaller osgiInstaller;
@@ -49,9 +49,9 @@ public class FindPathsToWatchTest extend
         contentHelper.cleanupContent();
         contentHelper.setupContent();
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller);
+        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller, new MockInstallableResourceFactory());
     }
-    
+
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
@@ -75,52 +75,52 @@ public class FindPathsToWatchTest extend
     public void testInitialFind() throws Exception {
         final Collection<WatchedFolder> wf = MiscUtil.getWatchedFolders(installer);
         assertEquals("activate() must find all watched folders", contentHelper.WATCHED_FOLDERS.length, wf.size());
-        
+
         for(String folder : contentHelper.WATCHED_FOLDERS) {
-            assertTrue("Folder " + folder + " must be watched (watched=" + wf + ")", 
+            assertTrue("Folder " + folder + " must be watched (watched=" + wf + ")",
                     isWatched(folder, wf));
         }
     }
-    
+
     public void testNewWatchedFolderDetection() throws Exception {
-        final String newPaths [] = { 
-                "/libs/tnwf/install", 
-                "/libs/tnwf/install.dev", 
-                "/apps/tnwf/install", 
-                "/apps/tnwf/install.staging", 
-                "/apps/tnwf/install.staging.dev", 
+        final String newPaths [] = {
+                "/libs/tnwf/install",
+                "/libs/tnwf/install.dev",
+                "/apps/tnwf/install",
+                "/apps/tnwf/install.staging",
+                "/apps/tnwf/install.staging.dev",
                 "/NOT/foo/nothing"
         };
         for(String newPath : newPaths) {
-            assertFalse(newPath + " must not be watched before test", isWatched(newPath, 
+            assertFalse(newPath + " must not be watched before test", isWatched(newPath,
                     MiscUtil.getWatchedFolders(installer)));
-            
+
             // Create folder, wait for observation event and check that
             // it is detected
             contentHelper.createFolder(newPath);
             MiscUtil.waitAfterContentChanges(eventHelper, installer);
-            
+
             if(newPath.contains("NOT")) {
-                assertFalse(newPath + " must not be watched after test", isWatched(newPath, 
+                assertFalse(newPath + " must not be watched after test", isWatched(newPath,
                         MiscUtil.getWatchedFolders(installer)));
             } else {
-                assertTrue(newPath + " must be watched after calling addNewWatchedFolders()", isWatched(newPath, 
+                assertTrue(newPath + " must be watched after calling addNewWatchedFolders()", isWatched(newPath,
                         MiscUtil.getWatchedFolders(installer)));
             }
         }
-        
+
         // Delete a single folder and verify that it's gone
         final String folder = newPaths[1];
         final int nBefore = MiscUtil.getWatchedFolders(installer).size();
         contentHelper.delete(folder);
         eventHelper.waitForEvents(5000L);
         MiscUtil.waitAfterContentChanges(eventHelper, installer);
-        assertFalse(folder + " must not be watched anymore after deleting", isWatched(folder, 
+        assertFalse(folder + " must not be watched anymore after deleting", isWatched(folder,
                 MiscUtil.getWatchedFolders(installer)));
         assertEquals("Expecting only one WatchedFolder to be deleted", nBefore - 1,
                MiscUtil.getWatchedFolders(installer).size());
     }
-    
+
     public void testDeleteWatchedFolders() throws Exception {
         final Collection<WatchedFolder> wf = MiscUtil.getWatchedFolders(installer);
         assertEquals("activate() must find all watched folders", contentHelper.WATCHED_FOLDERS.length, wf.size());

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstallTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstallTestBase.java?rev=955865&r1=955864&r2=955865&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstallTestBase.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstallTestBase.java Fri Jun 18 07:22:18 2010
@@ -29,7 +29,7 @@ abstract class JcrInstallTestBase extend
 
     SlingRepository repo;
     Session session;
-    protected EventHelper eventHelper; 
+    protected EventHelper eventHelper;
     protected ContentHelper contentHelper;
     protected JcrInstaller installer;
     protected MockOsgiInstaller osgiInstaller;
@@ -46,7 +46,7 @@ abstract class JcrInstallTestBase extend
             contentHelper.setupContent();
         }
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller);
+        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller, new MockInstallableResourceFactory());
     }
 
     @Override
@@ -59,26 +59,26 @@ abstract class JcrInstallTestBase extend
         installer.deactivate(MiscUtil.getMockComponentContext());
         MiscUtil.waitForInstallerThread(installer, TIMEOUT);
     }
-    
+
     protected abstract boolean needsTestContent();
-    
+
     protected void assertRegisteredPaths(String [] paths) {
         for(String path : paths) {
             assertRegistered(path, !path.contains("NOT"));
         }
     }
-    
+
     protected void assertRegistered(String path, boolean registered) {
         assertRegistered(null, path, registered);
     }
-    
+
     protected void assertRegistered(String info, String path, boolean registered) {
         if(info == null) {
             info = "";
         } else {
             info += ": ";
         }
-        
+
         if(registered) {
             assertTrue(info + "Expected " + path + " to be registered",
                     osgiInstaller.isRegistered(JcrInstaller.URL_SCHEME, path));
@@ -87,7 +87,7 @@ abstract class JcrInstallTestBase extend
                     osgiInstaller.isRegistered(JcrInstaller.URL_SCHEME, path));
         }
     }
-    
+
     protected void assertRecordedCall(String action, String path) {
         final String callStr = action + ":" + JcrInstaller.URL_SCHEME + ":" + path;
         boolean found = false;

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletReq
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -114,10 +115,12 @@ class MiscUtil {
     }
 
     /** Return a JcrInstaller setup for testing */
-    static synchronized JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller) throws Exception {
+    static synchronized JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller,
+            InstallableResourceFactory factory) throws Exception {
         final JcrInstaller installer = new JcrInstaller();
         setField(installer, "repository", repository);
         setField(installer, "installer", osgiInstaller);
+        setField(installer, "installableResourceFactory", factory);
         setField(installer, "runMode", new MockRunMode(RUN_MODES));
 
         installer.activate(getMockComponentContext());

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -19,19 +19,81 @@
 package org.apache.sling.jcr.jcrinstall.impl;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.util.Dictionary;
 
+import org.apache.sling.osgi.installer.DigestUtil;
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 
-public class MockInstallableResource extends InstallableResource {
+public class MockInstallableResource implements InstallableResource {
 
     private static int counter;
 
+    private final String uri;
+    private final InputStream is;
+    private final String digest;
+    private final InstallableResource.Type type;
+    private final int priority;
+    private final Dictionary<String, Object> d;
+
     public MockInstallableResource(String uri) {
         this(uri, "", null);
     }
 
     public MockInstallableResource(String uri, String data, String digest) {
-        super(uri, new ByteArrayInputStream(data.getBytes()), getNextDigest(digest));
+        this.uri = uri;
+        this.is = new ByteArrayInputStream(data.getBytes());
+        this.digest = getNextDigest(digest);
+        this.type = InstallableResource.Type.BUNDLE;
+        this.priority = InstallableResourceFactory.DEFAULT_PRIORITY;
+        this.d = null;
+    }
+
+    public MockInstallableResource(String uri, InputStream is, String digest, InstallableResource.Type type, Integer priority) {
+        this.uri = uri;
+        this.is = is;
+        this.digest = digest;
+        if ( type != null ) {
+            this.type = type;
+        } else {
+            this.type = InstallableResource.Type.BUNDLE;
+        }
+        if ( priority != null ) {
+            this.priority = priority;
+        } else {
+            this.priority = InstallableResourceFactory.DEFAULT_PRIORITY;
+        }
+        this.d = null;
+    }
+
+    public MockInstallableResource(String uri, Dictionary<String, Object> d, String digest, InstallableResource.Type type, Integer priority) {
+        this.uri = uri;
+        this.is = null;
+        if ( type != null ) {
+            this.type = type;
+        } else {
+            this.type = InstallableResource.Type.CONFIG;
+        }
+        if ( priority != null ) {
+            this.priority = priority;
+        } else {
+            this.priority = InstallableResourceFactory.DEFAULT_PRIORITY;
+        }
+        if ( digest != null ) {
+            this.digest = digest;
+        } else {
+            try {
+                this.digest = DigestUtil.computeDigest(d);
+            } catch (NoSuchAlgorithmException e) {
+                throw new RuntimeException(e);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        this.d = d;
     }
 
     static String getNextDigest(String digest) {
@@ -42,4 +104,28 @@ public class MockInstallableResource ext
             return String.valueOf(System.currentTimeMillis() + (counter++));
         }
     }
+
+    public Dictionary<String, Object> getDictionary() {
+        return this.d;
+    }
+
+    public String getDigest() {
+        return digest;
+    }
+
+    public InputStream getInputStream() {
+        return is;
+    }
+
+    public int getPriority() {
+        return this.priority;
+    }
+
+    public Type getType() {
+        return this.type;
+    }
+
+    public String getUrl() {
+        return this.uri;
+    }
 }

Added: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java?rev=955865&view=auto
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java (added)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java Fri Jun 18 07:22:18 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.jcr.jcrinstall.impl;
+
+import java.io.InputStream;
+import java.util.Dictionary;
+
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
+import org.apache.sling.osgi.installer.InstallableResource.Type;
+
+
+class MockInstallableResourceFactory implements InstallableResourceFactory {
+
+    public InstallableResource create(String url, Dictionary<String, Object> d,
+            String digest, Type type, Integer priority) {
+        return new MockInstallableResource(url, d, digest, type, priority);
+    }
+
+    public InstallableResource create(String url, InputStream is,
+            String digest, Type type, Integer priority) {
+        return new MockInstallableResource(url, is, digest, type, priority);
+    }
+}

Propchange: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ScanningLoopTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ScanningLoopTest.java?rev=955865&r1=955864&r2=955865&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ScanningLoopTest.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ScanningLoopTest.java Fri Jun 18 07:22:18 2010
@@ -27,26 +27,26 @@ import org.junit.Test;
 /** Verify that JcrInstaller scans folders only when needed */
 public class ScanningLoopTest extends RepositoryTestBase {
     public static final long TIMEOUT = 5000L;
-    
+
     private JcrInstaller installer;
     private SlingRepository repository;
     private MockOsgiInstaller osgiInstaller;
     private ContentHelper contentHelper;
     private Session session;
-    private EventHelper eventHelper; 
-    
+    private EventHelper eventHelper;
+
     @Override
     public void setUp() throws Exception {
         super.setUp();
         repository = getRepository();
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repository, osgiInstaller);
+        installer = MiscUtil.getJcrInstaller(repository, osgiInstaller, new MockInstallableResourceFactory());
         session = repository.loginAdministrative(repository.getDefaultWorkspace());
         eventHelper = new EventHelper(session);
         contentHelper = new ContentHelper(session);
         contentHelper.setupFolders();
     }
-    
+
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
@@ -59,11 +59,11 @@ public class ScanningLoopTest extends Re
             session = null;
         }
     }
-    
+
     private void assertCounter(int index, long value) {
         assertEquals("Counter " + index, value, installer.getCounters()[index]);
     }
-    
+
     private void assertIdle() throws Exception {
         final long sf = installer.getCounters()[JcrInstaller.SCAN_FOLDERS_COUNTER];
         final long uc = installer.getCounters()[JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER];
@@ -71,7 +71,7 @@ public class ScanningLoopTest extends Re
         assertCounter(JcrInstaller.SCAN_FOLDERS_COUNTER, sf);
         assertCounter(JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER, uc);
     }
-    
+
     private void assertEvents(String info, long oldCount, int counterIndex) {
         final long newCount = installer.getCounters()[counterIndex];
         assertTrue(info + " (old=" + oldCount + ", new=" + newCount + ")", newCount > oldCount);
@@ -82,7 +82,7 @@ public class ScanningLoopTest extends Re
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 4);
         assertIdle();
     }
-    
+
     @Test
     public void testAddBundle() throws Exception {
         contentHelper.createOrUpdateFile(contentHelper.FAKE_RESOURCES[0]);
@@ -90,49 +90,49 @@ public class ScanningLoopTest extends Re
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
         assertIdle();
     }
-    
+
     public void testAddContentOutside() throws Exception {
         final long sf = installer.getCounters()[JcrInstaller.SCAN_FOLDERS_COUNTER];
         final long uc = installer.getCounters()[JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER];
-        
+
         contentHelper.createOrUpdateFile("/" + System.currentTimeMillis());
         eventHelper.waitForEvents(TIMEOUT);
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
-        
+
         // Adding a file outside /libs or /apps must not "wake up" the scan loop
         assertCounter(JcrInstaller.SCAN_FOLDERS_COUNTER, sf);
         assertCounter(JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER, uc);
     }
-    
+
     public void testDeleteFile() throws Exception {
         contentHelper.setupContent();
         eventHelper.waitForEvents(TIMEOUT);
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
         assertIdle();
-        
+
         final long sf = installer.getCounters()[JcrInstaller.SCAN_FOLDERS_COUNTER];
         contentHelper.delete(contentHelper.FAKE_RESOURCES[0]);
         eventHelper.waitForEvents(TIMEOUT);
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
-        assertEvents("Expected at least one folder scan event", 
+        assertEvents("Expected at least one folder scan event",
                 sf,  JcrInstaller.SCAN_FOLDERS_COUNTER);
-        
+
         assertIdle();
     }
-    
+
     public void testDeleteLibsFolder() throws Exception {
         contentHelper.setupContent();
         eventHelper.waitForEvents(TIMEOUT);
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
         assertIdle();
-        
+
         final long uc = installer.getCounters()[JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER];
         contentHelper.delete("/libs");
         eventHelper.waitForEvents(TIMEOUT);
         Thread.sleep(JcrInstaller.RUN_LOOP_DELAY_MSEC * 2);
-        assertEvents("Expected at least one folders list update event", 
+        assertEvents("Expected at least one folders list update event",
                 uc,  JcrInstaller.UPDATE_FOLDERS_LIST_COUNTER);
-        
+
         assertIdle();
     }
 }
\ No newline at end of file

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -24,151 +24,44 @@ import java.util.Dictionary;
 /**
  * A piece of data that can be installed by the {@link OsgiInstaller}
  * Currently the OSGi installer supports bundles and configurations.
+ *
+ * A client can either use the {@link InstallableResourceFactory} to create
+ * new data objects or implement this interface.
  */
-public class InstallableResource {
+public interface InstallableResource {
 
     /** The supported resource types. */
     public static enum Type {
-        BUNDLE,
-        CONFIG
+        BUNDLE,  // in this case getInputStream must return an input stream
+        CONFIG   // in this case getDictionary must return the dictionary
     };
 
-    /** 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.
+    /**
+     * 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 this.url;
-    }
+    String getUrl();
 
 	/** Return the type of this resource. */
-    public Type getType() {
-        return this.resourceType;
-    }
+    Type getType();
 
 	/** 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 this.inputStream;
-    }
+    InputStream getInputStream();
 
 	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
-	public Dictionary<String, Object> getDictionary() {
-	    return this.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 this.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 this.priority;
-    }
-
-    private final String url;
-    private final String digest;
-    private final InputStream inputStream;
-    private final Dictionary<String, Object> dictionary;
-    private final int priority;
-    private final Type resourceType;
-
-    /** 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 InstallableResource(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 InstallableResource(String url, InputStream is, String digest, final int priority) {
-        this.url = url;
-        this.digest = digest;
-        this.priority = priority;
-        // detect resource type by checking the extension
-        final String extension = getExtension(this.url);
-        this.resourceType = computeResourceType(extension);
-//        if ( this.resourceType == Type.CONFIG ) {
-//            this.dictionary = null;
-//            this.inputStream = null;
-//        } else {
-            this.inputStream = is;
-            this.dictionary = null;
-//        }
-    }
-
-    /** 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(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 InstallableResource(final String url, final Dictionary<String, Object> d, final int priority) {
-        this.url = url;
-        this.inputStream = null;
-        this.resourceType = Type.CONFIG;
-        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));
-    }
-
-    private static Type computeResourceType(String extension) {
-        if(extension.equals("jar")) {
-            return Type.BUNDLE;
-        }
-        return Type.CONFIG;
-    }
+    int getPriority();
 }

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java?rev=955865&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java Fri Jun 18 07:22:18 2010
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+/**
+ * This is a factory for installable resources. It should be used
+ * if the client of the OSGi installer does not detect the resource
+ * type itself and just handles this task over to the OSGi installer.
+ */
+public interface InstallableResourceFactory {
+
+    /** Default resource priority */
+    int DEFAULT_PRIORITY = 100;
+
+    /**
+     * Create a data object based on an input stream.
+     * The data object is derived from the supplied input stream. If no resource type
+     * is specified, the type is detected.
+     *
+     * @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. If no digest is provided a digest
+     *     will be calculated
+     * @param optional resource type - if the client knows the resource type it should
+     *     be specified - if not, the factory detects the type
+     * @param optional priority - if not specified {@link #DEFAULT_PRIORITY} will be used.
+     */
+    InstallableResource create(String url,
+                               InputStream is,
+                               String digest,
+                               InstallableResource.Type type,
+                               Integer priority);
+
+    /**
+     * Create a data object based on a dictionary.
+     * The data object is derived from the supplied dictionary. If no resource type
+     * is specified, the type is detected.
+     * Currently if a dictionary is provided, the resource is always assumed to be
+     * a configuration - specifying a different resource type with a dictionary
+     * results in an exception.
+     *
+     * @param url unique URL of the supplied data, must start with the scheme used
+     *     {@link OsgiInstaller#registerResources} call
+     * @param d the dictionary
+     * @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. If no digest is provided a digest
+     *     will be calculated
+     * @param optional resource type - if the client knows the resource type it should
+     *     be specified - if not, the factory detects the type
+     * @param optional priority - if not specified {@link #DEFAULT_PRIORITY} will be used.
+     */
+    InstallableResource create(String url,
+                               Dictionary<String, Object> d,
+                               String digest,
+                               InstallableResource.Type type,
+                               Integer priority);
+}

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

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

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

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java?rev=955865&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java Fri Jun 18 07:22:18 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.InputStream;
+import java.util.Dictionary;
+
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
+
+/**
+ * Default implementation of the installable resource factory.
+ */
+public class InstallableResourceFactoryImpl implements InstallableResourceFactory {
+
+    /**
+     * @see org.apache.sling.osgi.installer.InstallableResourceFactory#create(java.lang.String, java.io.InputStream, java.lang.String, org.apache.sling.osgi.installer.InstallableResource.Type, java.lang.Integer)
+     */
+    public InstallableResource create(final String url,
+                               final InputStream is,
+                               final String digest,
+                               final InstallableResource.Type type,
+                               final Integer priority) {
+        if ( url == null ) {
+            throw new IllegalArgumentException("url must not be null.");
+        }
+        if ( is == null ) {
+            throw new IllegalArgumentException("input stream must not be null.");
+        }
+        if ( priority == null ) {
+            return new InstallableResourceImpl(url, is, digest);
+        }
+        return new InstallableResourceImpl(url, is, digest, priority);
+    }
+
+    /**
+     * @see org.apache.sling.osgi.installer.InstallableResourceFactory#create(java.lang.String, java.util.Dictionary, java.lang.String, org.apache.sling.osgi.installer.InstallableResource.Type, java.lang.Integer)
+     */
+    public InstallableResource create(final String url,
+                               final Dictionary<String, Object> d,
+                               final String digest,
+                               final InstallableResource.Type type,
+                               final Integer priority) {
+        if ( url == null ) {
+            throw new IllegalArgumentException("url must not be null.");
+        }
+        if ( d == null ) {
+            throw new IllegalArgumentException("dictionary must not be null.");
+        }
+        if ( priority == null ) {
+            return new InstallableResourceImpl(url, d);
+        }
+        return new InstallableResourceImpl(url, d, priority);
+    }
+}

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

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

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

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java?rev=955865&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java Fri Jun 18 07:22:18 2010
@@ -0,0 +1,172 @@
+/*
+ * 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.InputStream;
+import java.util.Dictionary;
+
+import org.apache.sling.osgi.installer.DigestUtil;
+import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.OsgiInstaller;
+
+/**
+ * A piece of data that can be installed by the {@link OsgiInstaller}
+ * Currently the OSGi installer supports bundles and configurations.
+ */
+public class InstallableResourceImpl implements 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 this.url;
+    }
+
+	/** Return the type of this resource. */
+    public Type getType() {
+        return this.resourceType;
+    }
+
+	/** 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 this.inputStream;
+    }
+
+	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
+	public Dictionary<String, Object> getDictionary() {
+	    return this.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 this.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 this.priority;
+    }
+
+    private final String url;
+    private final String digest;
+    private final InputStream inputStream;
+    private final Dictionary<String, Object> dictionary;
+    private final int priority;
+    private final Type resourceType;
+
+    /** 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 InstallableResourceImpl(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 InstallableResourceImpl(String url, InputStream is, String digest, final int priority) {
+        this.url = url;
+        this.digest = digest;
+        this.priority = priority;
+        // detect resource type by checking the extension
+        final String extension = getExtension(this.url);
+        this.resourceType = computeResourceType(extension);
+//        if ( this.resourceType == Type.CONFIG ) {
+//            this.dictionary = null;
+//            this.inputStream = null;
+//        } else {
+            this.inputStream = is;
+            this.dictionary = null;
+//        }
+    }
+
+    /** 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 InstallableResourceImpl(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 InstallableResourceImpl(final String url, final Dictionary<String, Object> d, final int priority) {
+        this.url = url;
+        this.inputStream = null;
+        this.resourceType = Type.CONFIG;
+        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));
+    }
+
+    private static Type computeResourceType(String extension) {
+        if(extension.equals("jar")) {
+            return Type.BUNDLE;
+        }
+        return Type.CONFIG;
+    }
+}

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

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

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

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -25,14 +25,17 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.junit.Test;
 
 public class InstallableResourceTest {
 
+    private InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
+
     @Test
     public void testDictionaryDigest() {
         final Dictionary<String, Object> d = new Hashtable<String, Object>();
-        final InstallableResource r = new InstallableResource("x:url", d);
+        final InstallableResource r = factory.create("x:url", d, null, null, null);
         assertNotNull("Expected InstallableResource to compute its own digest", r.getDigest());
     }
 
@@ -48,8 +51,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 = factory.create("test:url1", d1, null, null, null);
+        final InstallableResource r2 = factory.create("test:url1", d2, null, null, null);
 
         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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
@@ -41,7 +42,7 @@ public class MockBundleResource implemen
 	private static long serialNumberCounter = System.currentTimeMillis();
 
     MockBundleResource(String symbolicName, String version) {
-        this(symbolicName, version, InstallableResource.DEFAULT_PRIORITY);
+        this(symbolicName, version, InstallableResourceFactory.DEFAULT_PRIORITY);
     }
 
 	MockBundleResource(String symbolicName, String version, int priority) {

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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -29,10 +29,13 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.junit.Test;
 
 public class RegisteredResourceComparatorTest {
 
+    private InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
+
     private void assertOrder(Set<RegisteredResource> toTest, RegisteredResource[] inOrder) {
         assertEquals("Expected sizes to match", toTest.size(), inOrder.length);
         int i = 0;
@@ -48,7 +51,7 @@ public class RegisteredResourceComparato
             data = new Hashtable<String, Object>();
             data.put("foo", "bar");
         }
-        final InstallableResource r = new InstallableResource("test:" + url, data, priority);
+        final InstallableResource r = factory.create("test:" + url, data, null, null, priority);
         return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r);
     }
 
@@ -173,7 +176,7 @@ public class RegisteredResourceComparato
 
     @Test
     public void testConfigAndBundle() throws IOException {
-    	final RegisteredResource cfg = getConfig("pid", null, InstallableResource.DEFAULT_PRIORITY);
+    	final RegisteredResource cfg = getConfig("pid", null, InstallableResourceFactory.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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 2010
@@ -35,10 +35,13 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.osgi.framework.Constants;
 
 public class RegisteredResourceTest {
 
+    private InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
+
     public static final String TEST_URL = "test:url";
 
     static File getTestBundle(String name) {
@@ -65,7 +68,7 @@ public class RegisteredResourceTest {
 		}
 
 		final TestInputStream t = new TestInputStream(new ByteArrayInputStream(data.getBytes()));
-		final InstallableResource ir = new InstallableResource(TEST_URL, t, "somedigest");
+		final InstallableResource ir = factory.create(TEST_URL, t, "somedigest", null, null);
 		assertEquals("TestInputStream must not be closed before test", 0, t.closeCount);
 		new LocalFileRegisteredResource(ir);
 		assertEquals("TestInputStream must be closed by RegisteredResource", 1, t.closeCount);
@@ -74,7 +77,7 @@ public class RegisteredResourceTest {
     @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"));
+            final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.jar", s, "some digest", null, null));
             assertEquals(".jar URL creates a BUNDLE resource",
                     InstallableResource.Type.BUNDLE, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
@@ -86,7 +89,7 @@ public class RegisteredResourceTest {
 
         {
             final InputStream s = new ByteArrayInputStream("foo=bar\nother=2".getBytes());
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.properties", s, "digest1"));
+            final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1.properties", s, "digest1", null, null));
             assertEquals(".properties URL creates a CONFIG resource",
                     InstallableResource.Type.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
@@ -101,7 +104,7 @@ public class RegisteredResourceTest {
             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));
+            final RegisteredResource r = new LocalFileRegisteredResource(factory.create("test:1", data, null, null, null));
             assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
                     InstallableResource.Type.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
@@ -116,7 +119,7 @@ public class RegisteredResourceTest {
 	@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(factory.create("test:1.jar", s, "somedigest", null, null));
 		assertTrue("Local file exists", r.getDataFile(null).exists());
 
 		assertEquals("Local file length matches our data", f.length(), r.getDataFile(null).length());
@@ -127,13 +130,13 @@ public class RegisteredResourceTest {
         final InputStream in = new ByteArrayInputStream(data.getBytes());
 
         try {
-            new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, null));
+            new LocalFileRegisteredResource(factory.create("test:1.jar", in, null, null, 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(factory.create("test:1.foo", in, null, null, null));
             fail("With non-jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
@@ -141,14 +144,14 @@ public class RegisteredResourceTest {
 
     @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 = factory.create("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName(), null, null);
         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 = factory.create("test:/foo/someconfig", new Hashtable<String, Object>(), null, null, null);
         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());
@@ -156,8 +159,8 @@ public class RegisteredResourceTest {
 
     @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 = factory.create("test:urlA", data, null, null, null);
+        final InstallableResource rB = factory.create("test:urlB", data, null, null, null);
         assertFalse(
                 "Expecting configs with same data but different URLs to have different digests",
                 rA.getDigest().equals(rB.getDigest()));
@@ -175,7 +178,7 @@ public class RegisteredResourceTest {
         };
         for(String url : badOnes) {
             try {
-                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, s, null));
+                new RegisteredResourceImpl(new MockOsgiInstallerContext(),factory.create(url, s, null, null, null));
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
             } catch(IllegalArgumentException asExpected) {
             }
@@ -190,7 +193,7 @@ public class RegisteredResourceTest {
 
         for(String url : goodOnes) {
             final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),
-                    new InstallableResource(url, s, "digest1"));
+                    factory.create(url, s, "digest1", null, null));
             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=955865&r1=955864&r2=955865&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 Fri Jun 18 07:22:18 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.InstallableResourceFactory;
 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;
@@ -40,7 +40,9 @@ import org.apache.sling.osgi.installer.i
  */
 public class TaskOrderingTest {
 
-	private Set<OsgiInstallerTask> taskSet;
+    private static InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
+
+    private Set<OsgiInstallerTask> taskSet;
 
 	@org.junit.Before public void setUp() {
 	    // The data type must be consistent with the "tasks" member
@@ -49,7 +51,7 @@ public class TaskOrderingTest {
 	}
 
 	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(), factory.create(url, new Hashtable<String, Object>(), null, null, null));
 	}
 
 	private void assertOrder(int testId, Collection<OsgiInstallerTask> actual, OsgiInstallerTask [] expected) {



Mime
View raw message