incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r984500 - 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 Wed, 11 Aug 2010 18:09:24 GMT
Author: cziegeler
Date: Wed Aug 11 18:09:23 2010
New Revision: 984500

URL: http://svn.apache.org/viewvc?rev=984500&view=rev
Log:
SLING-1560 : Convert installable resource back to a class and remove the need for an additional factory

Removed:
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DigestUtil.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java
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/main/java/org/apache/sling/osgi/installer/impl/Activator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.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/MockBundleTaskCreator.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/MockInstallableResource.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -30,7 +30,6 @@ 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;
 
@@ -44,14 +43,13 @@ class ConfigNodeConverter implements Jcr
 	 * 	if we don't know how to convert it.
 	 */
 	public InstallableResource convertNode(final Node n,
-	        final int priority,
-	        final InstallableResourceFactory factory)
+	        final int priority)
 	throws Exception {
 		InstallableResource result = null;
 
 		// We only consider CONFIG_NODE_TYPE nodes
 		if(n.isNodeType(CONFIG_NODE_TYPE)) {
-			result = factory.create(n.getPath(), null, load(n), null, null, priority);
+			result = new InstallableResource(n.getPath(), null, 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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -24,7 +24,6 @@ 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;
 
@@ -46,14 +45,13 @@ import org.slf4j.LoggerFactory;
 	 */
 	public InstallableResource convertNode(
 	        final Node n,
-	        final int priority,
-	        final InstallableResourceFactory factory)
+	        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(n, n.getPath(), priority, factory);
+					result = convert(n, n.getPath(), priority);
 				} catch(IOException ioe) {
 					log.info("Conversion failed, node {} ignored ({})", n.getPath(), ioe);
 				}
@@ -70,8 +68,7 @@ import org.slf4j.LoggerFactory;
 	private InstallableResource convert(
 	        final Node n,
 	        final String path,
-	        final int priority,
-	        final InstallableResourceFactory factory)
+	        final int priority)
     throws IOException, RepositoryException {
 		String digest = null;
         if (n.hasProperty(JCR_CONTENT_LAST_MODIFIED)) {
@@ -87,7 +84,7 @@ import org.slf4j.LoggerFactory;
         	throw new IOException("Missing " + JCR_CONTENT_DATA + " property");
         }
 
-        return factory.create(path, is, null, digest, null, priority);
+        return new InstallableResource(path, is, null, digest, InstallableResource.TYPE_BUNDLE, 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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -36,7 +36,6 @@ 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,11 +88,6 @@ 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$";
 
@@ -136,7 +130,7 @@ public class JcrInstaller implements Eve
 
     /** Convert Nodes to InstallableResources */
     static interface NodeConverter {
-    	InstallableResource convertNode(Node n, int priority, InstallableResourceFactory factory)
+    	InstallableResource convertNode(Node n, int priority)
     	throws Exception;
     }
 
@@ -318,7 +312,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, converters, installableResourceFactory));
+            result.add(new WatchedFolder(session, path, priority, converters));
         }
         final int depth = path.split("/").length;
         if(depth > maxWatchedFolderDepth) {
@@ -378,7 +372,7 @@ public class JcrInstaller implements Eve
                     // Deletions are handled below
                     if(folderNameFilter.getPriority(path) > 0  && session.itemExists(path)) {
                         addWatchedFolder(new WatchedFolder(session, path,
-                                folderNameFilter.getPriority(path), converters, installableResourceFactory));
+                                folderNameFilter.getPriority(path), converters));
                     }
                 }
             }

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -36,7 +36,6 @@ 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;
 
@@ -54,10 +53,6 @@ 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>();
@@ -69,8 +64,7 @@ class WatchedFolder implements EventList
     WatchedFolder(final Session session,
             final String path,
             final int priority,
-    		final Collection<JcrInstaller.NodeConverter> converters,
-    		final InstallableResourceFactory factory)
+    		final Collection<JcrInstaller.NodeConverter> converters)
     throws RepositoryException {
         if(priority < 1) {
             throw new IllegalArgumentException("Cannot watch folder with priority 0:" + path);
@@ -91,8 +85,6 @@ 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);
     }
 
@@ -154,7 +146,7 @@ class WatchedFolder implements EventList
             while(it.hasNext()) {
             	final Node n = it.nextNode();
             	for(JcrInstaller.NodeConverter nc : converters) {
-            		final InstallableResource r = nc.convertNode(n, priority, factory);
+            		final InstallableResource r = nc.convertNode(n, priority);
             		if(r != null) {
             			resourcesSeen.add(r.getId());
             		    final String oldDigest = digests.get(r.getId());

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -49,7 +49,7 @@ public class FindPathsToWatchTest extend
         contentHelper.cleanupContent();
         contentHelper.setupContent();
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller, new MockInstallableResourceFactory());
+        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller);
     }
 
     @Override

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -46,7 +46,7 @@ abstract class JcrInstallTestBase extend
             contentHelper.setupContent();
         }
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller, new MockInstallableResourceFactory());
+        installer = MiscUtil.getJcrInstaller(repo, osgiInstaller);
     }
 
     @Override

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -30,7 +30,6 @@ 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;
@@ -119,12 +118,11 @@ class MiscUtil {
     }
 
     /** Return a JcrInstaller setup for testing */
-    static synchronized JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller,
-            InstallableResourceFactory factory) 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);
-        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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -19,100 +19,38 @@
 package org.apache.sling.jcr.jcrinstall.impl;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.math.BigInteger;
-import java.security.MessageDigest;
 import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.SortedSet;
-import java.util.TreeSet;
 
 import org.apache.sling.osgi.installer.InstallableResource;
-import org.apache.sling.osgi.installer.InstallableResourceFactory;
 
-public class MockInstallableResource implements InstallableResource {
+public class MockInstallableResource extends InstallableResource {
 
     private static int counter;
 
-    private final String uri;
-    private final InputStream is;
-    private final String digest;
-    private final String 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) {
-        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;
+        super(uri, new ByteArrayInputStream(data.getBytes()), null, getNextDigest(digest),
+                InstallableResource.TYPE_BUNDLE, InstallableResource.DEFAULT_PRIORITY);
     }
 
     public MockInstallableResource(String uri, InputStream is, Dictionary<String, Object> d, String digest, String type, Integer priority) {
-        this.uri = uri;
-        this.is = is;
-        if ( type != null ) {
-            this.type = type;
-        } else {
-            this.type = (is != null ? InstallableResource.TYPE_BUNDLE : InstallableResource.TYPE_CONFIG);
-        }
-        if ( this.type.equals(InstallableResource.TYPE_CONFIG) && digest == null ) {
-            this.digest = computeDigest(d);
-        } else {
-            this.digest = digest;
-        }
-        if ( priority != null ) {
-            this.priority = priority;
-        } else {
-            this.priority = InstallableResourceFactory.DEFAULT_PRIORITY;
-        }
-        this.d = d;
+        super(uri, is, d,
+                digest,
+                type != null ? type : (is != null ? InstallableResource.TYPE_BUNDLE : InstallableResource.TYPE_CONFIG),
+                priority != null ? priority : InstallableResource.DEFAULT_PRIORITY);
     }
 
     public MockInstallableResource(String uri, InputStream is, String digest, String 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;
+        super(uri, is, null, digest, type != null ? type : InstallableResource.TYPE_BUNDLE, priority);
     }
 
     public MockInstallableResource(String uri, Dictionary<String, Object> d, String digest, String 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 {
-            this.digest = computeDigest(d);
-        }
-        this.d = d;
+        super(uri, null, d, digest,
+                type != null ? type : InstallableResource.TYPE_CONFIG, priority);
     }
 
     static String getNextDigest(String digest) {
@@ -123,64 +61,4 @@ public class MockInstallableResource imp
             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 String getType() {
-        return this.type;
-    }
-
-    public String getId() {
-        return this.uri;
-    }
-
-    /** The digest to be used. */
-    private static final String DIGEST_TYPE = "MD5";
-
-    /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
-    private static String digestToString(MessageDigest d) {
-        final BigInteger bigInt = new BigInteger(1, d.digest());
-        return new String(bigInt.toString(16));
-    }
-
-    /** Compute digest on all keys of supplied data */
-    private static String computeDigest(Dictionary<String, Object> data) {
-        try {
-            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();
-                    sortedKeys.add(key);
-                }
-            }
-            for(String key : sortedKeys) {
-                oos.writeObject(key);
-                oos.writeObject(data.get(key));
-            }
-
-            bos.flush();
-            d.update(bos.toByteArray());
-            return digestToString(d);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
 }

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -40,7 +40,7 @@ public class ScanningLoopTest extends Re
         super.setUp();
         repository = getRepository();
         osgiInstaller = new MockOsgiInstaller();
-        installer = MiscUtil.getJcrInstaller(repository, osgiInstaller, new MockInstallableResourceFactory());
+        installer = MiscUtil.getJcrInstaller(repository, osgiInstaller);
         session = repository.loginAdministrative(repository.getDefaultWorkspace());
         eventHelper = new EventHelper(session);
         contentHelper = new ContentHelper(session);

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -18,73 +18,203 @@
  */
 package org.apache.sling.osgi.installer;
 
-import java.io.IOException;
+import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
 import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
 
 /**
  * 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 interface InstallableResource {
+public class InstallableResource {
 
     /**
      * The type for a bundle - in this case {@link #getInputStream} must
      * return an input stream to the bundle. {@link #getDictionary()} might
      * return additional information.
      */
-    String TYPE_BUNDLE = "bundle";
+    public static final String TYPE_BUNDLE = "bundle";
 
     /**
      * The type for a configuration - in this case {@link #getDictionary()}
      * must return a dictionary with the configuration.
      */
-    String TYPE_CONFIG = "config";
+    public static final String TYPE_CONFIG = "config";
+
+    /** Default resource priority */
+    public static final int DEFAULT_PRIORITY = 100;
+
+    private final String id;
+    private final String digest;
+    private final InputStream inputStream;
+    private final Dictionary<String, Object> dictionary;
+    private final int priority;
+    private final String resourceType;
+
+    /**
+     * Create a data object - this is a simple constructor just using the
+     * values as they are provided.
+     * @throws IllegalArgumentException if something is wrong
+     */
+    public InstallableResource(final String id,
+            final InputStream is,
+            final Dictionary<String, Object> dict,
+            String digest,
+            String type,
+            final Integer priority) {
+        if ( id == null ) {
+            throw new IllegalArgumentException("id must not be null.");
+        }
+        if ( is == null ) {
+            // if input stream is null, config through dictionary is expected!
+            if ( dict == null ) {
+                throw new IllegalArgumentException("dictionary must not be null (or input stream must not be null).");
+            }
+            digest = (digest != null ? digest : id + ":" + computeDigest(dict));
+            type = (type != null ? type : InstallableResource.TYPE_CONFIG);
+        }
+        // TODO - compute digest if digest is null - for now we throw
+        if ( digest == null ) {
+            throw new IllegalArgumentException("digest must not be null");
+        }
+
+        final String resourceType = (type != null ? type : computeResourceType(getExtension(id)));
+        if ( is != null && resourceType.equals(InstallableResource.TYPE_CONFIG ) ) {
+            throw new IllegalArgumentException("Resource type config not supported for input streams: " + id);
+        }
+        if ( resourceType == null ) {
+            throw new IllegalArgumentException("Resource type must not be null");
+        }
+
+        this.id = id;
+        this.inputStream = is;
+        this.dictionary = dict;
+        this.digest = digest;
+        this.priority = (priority != null ? priority : DEFAULT_PRIORITY);
+        this.resourceType = resourceType;
+    }
 
     /**
      * Return this data's id. It is opaque for the {@link OsgiInstaller}
-	 * but should uniquely identify the resource within the namespace of
-	 * the used installation mechanism.
-	 */
-    String getId();
-
-	/**
-	 * Return the type of this resource.
-	 * @return The resource type.
-	 */
-    String getType();
-
-	/**
-	 * Return an input stream with the data of this resource.
-	 * Null if resource contains a configuration instead. Caller is responsible for
-	 * closing the stream.
-	 * If this resource is of type CONFIG it must not return an input stream and
-	 * if this resource is of type BUNDLE it must return an input stream!
-	 * @return The input stream or null.
-	 */
-    InputStream getInputStream() throws IOException;
-
-	/**
-	 * Return this resource's dictionary.
-	 * Null if resource contains an InputStream instead. If this resource is of
-	 * type CONFIG it must return a dictionary and if this resource is of type BUNDLE
-	 * it might return a dictionary!
-	 * @return The resource's dictionary or null.
-	 */
-	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.
-	 */
-    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.)
-	 */
-    int getPriority();
+     * but should uniquely identify the resource within the namespace of
+     * the used installation mechanism.
+     */
+    public String getId() {
+        return this.id;
+    }
+
+    /**
+     * Return the type of this resource.
+     * @return The resource type.
+     */
+    public String getType() {
+        return this.resourceType;
+    }
+
+    /**
+     * Return an input stream with the data of this resource.
+     * Null if resource contains a configuration instead. Caller is responsible for
+     * closing the stream.
+     * If this resource is of type CONFIG it must not return an input stream and
+     * if this resource is of type BUNDLE it must return an input stream!
+     * @return The input stream or null.
+     */
+    public InputStream getInputStream() {
+        return this.inputStream;
+    }
+
+    /**
+     * Return this resource's dictionary.
+     * Null if resource contains an InputStream instead. If this resource is of
+     * type CONFIG it must return a dictionary and if this resource is of type BUNDLE
+     * it might return a dictionary!
+     * @return The resource's dictionary or null.
+     */
+    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;
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + ", priority=" + priority + ", id=" + id;
+    }
+
+    /**
+     * Compute the extension
+     */
+    private static String getExtension(String url) {
+        final int pos = url.lastIndexOf('.');
+        return (pos < 0 ? "" : url.substring(pos+1));
+    }
+
+    /**
+     * Compute the resource type
+     */
+    private static String computeResourceType(String extension) {
+        if (extension.equals("jar")) {
+            return InstallableResource.TYPE_BUNDLE;
+        }
+        if ( extension.equals("cfg") || extension.equals("config") || extension.equals("xml") ) {
+            return InstallableResource.TYPE_CONFIG;
+        }
+        return extension;
+    }
+
+    /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
+    private static String digestToString(MessageDigest d) {
+        final BigInteger bigInt = new BigInteger(1, d.digest());
+        return new String(bigInt.toString(16));
+    }
+
+    /** Digest is needed to detect changes in data, and must not depend on dictionary ordering */
+    private static String computeDigest(Dictionary<String, Object> data) {
+        try {
+            final MessageDigest d = MessageDigest.getInstance("MD5");
+            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();
+                    sortedKeys.add(key);
+                }
+            }
+            for(String key : sortedKeys) {
+                oos.writeObject(key);
+                oos.writeObject(data.get(key));
+            }
+
+            bos.flush();
+            d.update(bos.toByteArray());
+            return digestToString(d);
+        } catch (Exception ignore) {
+            return data.toString();
+        }
+    }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Wed Aug 11 18:09:23 2010
@@ -20,7 +20,6 @@ package org.apache.sling.osgi.installer.
 
 import java.util.Hashtable;
 
-import org.apache.sling.osgi.installer.InstallableResourceFactory;
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 import org.osgi.framework.BundleActivator;
@@ -43,7 +42,6 @@ public class Activator implements Bundle
 
     private OsgiInstallerImpl osgiControllerService;
     private ServiceRegistration osgiControllerServiceReg;
-    private ServiceRegistration factoryServiceReg;
 
     /** Tracker for the log service. */
     private ServiceTracker logServiceTracker;
@@ -74,16 +72,6 @@ public class Activator implements Bundle
             };
             osgiControllerServiceReg = context.registerService(serviceInterfaces, osgiControllerService, props);
         }
-
-        // register installable resource factory service
-        {
-            final Hashtable<String, String> props = new Hashtable<String, String>();
-            props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Installable Resource Factory");
-            props.put(Constants.SERVICE_VENDOR,VENDOR);
-
-            factoryServiceReg = context.registerService(InstallableResourceFactory.class.getName(),
-                    new InstallableResourceFactoryImpl(), props);
-        }
     }
 
     /**
@@ -97,10 +85,6 @@ public class Activator implements Bundle
             this.osgiControllerService.deactivate();
             this.osgiControllerService = null;
         }
-        if ( this.factoryServiceReg != null ) {
-            this.factoryServiceReg.unregister();
-            this.factoryServiceReg = null;
-        }
         if ( this.osgiControllerServiceReg != null ) {
             this.osgiControllerServiceReg.unregister();
             this.osgiControllerServiceReg = null;

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Wed Aug 11 18:09:23 2010
@@ -18,16 +18,19 @@
  */
 package org.apache.sling.osgi.installer.impl;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Dictionary;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.InstallableResource;
+import org.apache.sling.osgi.installer.OsgiInstaller;
 
 /** A resource that's been registered in the OSGi controller.
  * 	Data can be either an InputStream or a Dictionary, and we store
  *  it locally to avoid holding up to classes or data from our
  *  clients, in case those disappear while we're installing stuff.
  */
-public interface RegisteredResource extends InstallableResource {
+public interface RegisteredResource {
 
 	String DIGEST_TYPE = "MD5";
     String ENTITY_JAR_PREFIX = "jar:";
@@ -37,7 +40,49 @@ public interface RegisteredResource exte
     /** Attribute key: configuration pid */
     String CONFIG_PID_ATTRIBUTE = "config.pid";
 
+    /**
+     * Return this data's id. It is opaque for the {@link OsgiInstaller}
+     * but should uniquely identify the resource within the namespace of
+     * the used installation mechanism.
+     */
+    String getId();
+
+    /**
+     * Return the type of this resource.
+     * @return The resource type.
+     */
+    String getType();
+
+    /**
+     * Return an input stream with the data of this resource.
+     * Null if resource contains a configuration instead. Caller is responsible for
+     * closing the stream.
+     * If this resource is of type CONFIG it must not return an input stream and
+     * if this resource is of type BUNDLE it must return an input stream!
+     * @return The input stream or null.
+     */
+    InputStream getInputStream() throws IOException;
 
+    /**
+     * Return this resource's dictionary.
+     * Null if resource contains an InputStream instead. If this resource is of
+     * type CONFIG it must return a dictionary and if this resource is of type BUNDLE
+     * it might return a dictionary!
+     * @return The resource's dictionary or null.
+     */
+    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.
+     */
+    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.)
+     */
+    int getPriority();
     void cleanup();
 	String getURL();
 

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -18,13 +18,11 @@
  */
 package org.apache.sling.osgi.installer.impl.tasks;
 
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
 import java.util.Dictionary;
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.sling.osgi.installer.impl.DigestUtil;
 import org.apache.sling.osgi.installer.impl.Logger;
 import org.apache.sling.osgi.installer.impl.OsgiInstallerContext;
 import org.apache.sling.osgi.installer.impl.RegisteredResource;
@@ -42,7 +40,7 @@ public class ConfigInstallTask extends A
     public static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" };
 
     /** Configuration properties to ignore when comparing configs */
-    public static Set<String> ignoredProperties = new HashSet<String>();
+    public static final Set<String> ignoredProperties = new HashSet<String>();
     static {
     	ignoredProperties.add("service.pid");
     	ignoredProperties.add(CONFIG_PATH_KEY);
@@ -117,13 +115,32 @@ public class ConfigInstallTask extends A
         return Result.NOTHING;
     }
 
+    private Set<String> collectKeys(final Dictionary<String, Object>a) {
+        final Set<String> keys = new HashSet<String>();
+        final Enumeration<String> aI = a.keys();
+        while (aI.hasMoreElements() ) {
+            final String key = aI.nextElement();
+            if ( !ignoredProperties.contains(key) ) {
+                keys.add(key);
+            }
+        }
+        return keys;
+    }
+
     /** True if a and b represent the same config data, ignoring "non-configuration" keys in the dictionaries */
-    boolean isSameData(Dictionary<String, Object>a, Dictionary<String, Object>b) throws NoSuchAlgorithmException, IOException {
+    boolean isSameData(Dictionary<String, Object>a, Dictionary<String, Object>b) {
     	boolean result = false;
-    	if(a != null && b != null) {
-    		final String da = DigestUtil.computeDigest(a, ignoredProperties);
-    		final String db = DigestUtil.computeDigest(b, ignoredProperties);
-    		result = da.equals(db);
+    	if (a != null && b != null) {
+    	    final Set<String> keysA = collectKeys(a);
+            final Set<String> keysB = collectKeys(b);
+            if ( keysA.size() == keysB.size() && keysA.containsAll(keysB) ) {
+                for(final String key : keysA ) {
+                    if ( !a.get(key).equals(b.get(key)) ) {
+                        return result;
+                    }
+                }
+                result = true;
+            }
     	}
     	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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertTru
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.apache.sling.osgi.installer.InstallableResource;
+
 
 public class DictionaryDigestTest {
 	private void setTestData(Hashtable<String, Object> d) {
@@ -34,7 +36,7 @@ public class DictionaryDigestTest {
 
 	private String testDigestChanged(Dictionary<String, Object> d,
 			String oldDigest, int step, boolean shouldChange) throws Exception {
-		final String newDigest = DigestUtil.computeDigest(d);
+		final String newDigest = new InstallableResource("a", null, d, null, null, null).getDigest();
 		if(shouldChange) {
 			assertTrue("Digest (" + newDigest + ") should have changed at step " + step, !newDigest.equals(oldDigest));
 		} else {
@@ -52,8 +54,8 @@ public class DictionaryDigestTest {
 
 		assertEquals(
 				"Two dictionary with same values have the same key",
-				DigestUtil.computeDigest(d1),
-				DigestUtil.computeDigest(d2)
+		        new InstallableResource("a", null, d1, null, null, null).getDigest(),
+                new InstallableResource("a", null, d2, null, null, null).getDigest()
 		);
 	}
 
@@ -101,8 +103,8 @@ public class DictionaryDigestTest {
 		b.put("three", "C");
 
 		assertEquals("Same data in different order must have same digest",
-		        DigestUtil.computeDigest(a),
-		        DigestUtil.computeDigest(b)
+                new InstallableResource("a", null, a, null, null, null).getDigest(),
+                new InstallableResource("a", null, b, null, null, null).getDigest()
 		);
 	}
 }
\ 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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -26,17 +26,14 @@ 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() throws IOException {
         final Dictionary<String, Object> d = new Hashtable<String, Object>();
-        final InstallableResource r = factory.create("x:url", null, d, null, null, null);
+        final InstallableResource r = new InstallableResource("x:url", null, d, null, null, null);
         assertNotNull("Expected InstallableResource to compute its own digest", r.getDigest());
     }
 
@@ -52,8 +49,8 @@ public class InstallableResourceTest {
             d2.put(keys[i], keys[i] + "." + keys[i]);
         }
 
-        final InstallableResource r1 = factory.create("test:url1", null, d1, null, null, null);
-        final InstallableResource r2 = factory.create("test:url1", null, d2, null, null, null);
+        final InstallableResource r1 = new InstallableResource("test:url1", null, d1, null, null, null);
+        final InstallableResource r2 = new InstallableResource("test:url1", null, 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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -26,7 +26,6 @@ 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.Constants;
 
 /** Mock RegisteredResource that simulates a bundle */
@@ -41,7 +40,7 @@ public class MockBundleResource implemen
 	private static long serialNumberCounter = System.currentTimeMillis();
 
     MockBundleResource(String symbolicName, String version) {
-        this(symbolicName, version, InstallableResourceFactory.DEFAULT_PRIORITY);
+        this(symbolicName, version, InstallableResource.DEFAULT_PRIORITY);
     }
 
 	MockBundleResource(String symbolicName, String version, int priority) {

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleTaskCreator.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleTaskCreator.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleTaskCreator.java Wed Aug 11 18:09:23 2010
@@ -65,12 +65,14 @@ class MockBundleTaskCreator extends Bund
 
             }
 
+            @SuppressWarnings("unchecked")
             public ServiceRegistration registerService(String clazz, Object service,
                     Dictionary properties) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @SuppressWarnings("unchecked")
             public ServiceRegistration registerService(String[] clazzes,
                     Object service, Dictionary properties) {
                 // TODO Auto-generated method stub

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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -29,13 +29,10 @@ 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;
@@ -51,7 +48,7 @@ public class RegisteredResourceComparato
             data = new Hashtable<String, Object>();
             data.put("foo", "bar");
         }
-        final InstallableResource r = factory.create(url, null, data, null, null, priority);
+        final InstallableResource r = new InstallableResource(url, null, data, null, null, priority);
         return new RegisteredResourceImpl(null, r, "test");
     }
 
@@ -176,7 +173,7 @@ public class RegisteredResourceComparato
 
     @Test
     public void testConfigAndBundle() throws IOException {
-    	final RegisteredResource cfg = getConfig("pid", null, InstallableResourceFactory.DEFAULT_PRIORITY);
+    	final RegisteredResource cfg = getConfig("pid", null, InstallableResource.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=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -33,13 +33,10 @@ 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) {
@@ -50,7 +47,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(factory.create("test:1.jar", s, null, "some digest", null, null));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, null, "some digest", null, null));
             assertEquals(".jar URL creates a BUNDLE resource",
                     InstallableResource.TYPE_BUNDLE, r.getType());
             final InputStream rs = r.getInputStream();
@@ -64,7 +61,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(factory.create("test:1", null, data, null, null, null));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1", null, data, null, null, null));
             assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
                     InstallableResource.TYPE_CONFIG, r.getType());
             final InputStream rs = r.getInputStream();
@@ -79,7 +76,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(factory.create("test:1.jar", s, null, "somedigest", null, null));
+		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, null, "somedigest", null, null));
 		assertTrue("Local file exists", r.getDataFile().exists());
 
 		assertEquals("Local file length matches our data", f.length(), r.getDataFile().length());
@@ -90,7 +87,7 @@ public class RegisteredResourceTest {
         final InputStream in = new ByteArrayInputStream(data.getBytes());
 
         try {
-            new LocalFileRegisteredResource(factory.create("test:1.jar", in, null, null, null, null));
+            new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, null, null, null, null));
             fail("With jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
@@ -98,14 +95,14 @@ public class RegisteredResourceTest {
 
     @org.junit.Test public void testBundleManifest() throws Exception {
         final File f = getTestBundle("testbundle-1.0.jar");
-        final InstallableResource i = factory.create("test:" + f.getAbsolutePath(), new FileInputStream(f), null, f.getName(), null, null);
+        final InstallableResource i = new InstallableResource("test:" + f.getAbsolutePath(), new FileInputStream(f), null, 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 = factory.create("test:/foo/someconfig", null, new Hashtable<String, Object>(), null, null, null);
+        final InstallableResource i = new InstallableResource("test:/foo/someconfig", null, 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());
@@ -113,8 +110,8 @@ public class RegisteredResourceTest {
 
     @org.junit.Test public void testConfigDigestIncludesUrl() throws Exception {
         final Dictionary<String, Object> data = new Hashtable<String, Object>();
-        final InstallableResource rA = factory.create("test:urlA", null, data, null, null, null);
-        final InstallableResource rB = factory.create("test:urlB", null, data, null, null, null);
+        final InstallableResource rA = new InstallableResource("test:urlA", null, data, null, null, null);
+        final InstallableResource rB = new InstallableResource("test:urlB", null, data, null, null, null);
         assertFalse(
                 "Expecting configs with same data but different URLs to have different digests",
                 rA.getDigest().equals(rB.getDigest()));
@@ -129,7 +126,7 @@ public class RegisteredResourceTest {
         for(String url : badOnes) {
             try {
                 new RegisteredResourceImpl(null,
-                        factory.create("test", null, new Hashtable<String, Object>(), null, null, null),
+                        new InstallableResource("test", null, new Hashtable<String, Object>(), null, null, null),
                         url);
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
             } catch(IllegalArgumentException asExpected) {
@@ -142,7 +139,7 @@ public class RegisteredResourceTest {
 
         for(String url : goodOnes) {
             final RegisteredResource r = new RegisteredResourceImpl(null,
-                    factory.create("test", null, new Hashtable<String, Object>(), "digest1", null, null),
+                    new InstallableResource("test", null, new Hashtable<String, Object>(), "digest1", null, null),
                     url);
             assertEquals("Expected scheme '" + url + "' for URL " + url, url, r.getUrlScheme());
         }

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=984500&r1=984499&r2=984500&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 Wed Aug 11 18:09:23 2010
@@ -26,7 +26,7 @@ import java.util.Hashtable;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.sling.osgi.installer.InstallableResourceFactory;
+import org.apache.sling.osgi.installer.InstallableResource;
 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,8 +40,6 @@ import org.apache.sling.osgi.installer.i
  */
 public class TaskOrderingTest {
 
-    private static InstallableResourceFactory factory = new InstallableResourceFactoryImpl();
-
     private Set<OsgiInstallerTask> taskSet;
 
 	@org.junit.Before public void setUp() {
@@ -52,7 +50,7 @@ public class TaskOrderingTest {
 
 	private static RegisteredResource getRegisteredResource(String url) throws IOException {
 		return new RegisteredResourceImpl(null,
-		        factory.create(url, null, new Hashtable<String, Object>(), null, null, null),
+		        new InstallableResource(url, null, new Hashtable<String, Object>(), null, null, null),
 		        "test");
 	}
 

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java Wed Aug 11 18:09:23 2010
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertNul
 
 import java.io.IOException;
 
-import org.apache.sling.osgi.installer.InstallableResourceFactory;
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 import org.junit.After;
 import org.junit.Before;
@@ -54,8 +54,8 @@ public class BundlePrioritiesTest extend
         final String symbolicName = "osgi-installer-snapshot-test";
         assertNull("Snapshot test bundle must be absent before installing", findBundle(symbolicName));
 
-        final int lowPriority = InstallableResourceFactory.DEFAULT_PRIORITY - 1;
-        final int highPriority = InstallableResourceFactory.DEFAULT_PRIORITY + 1;
+        final int lowPriority = InstallableResource.DEFAULT_PRIORITY - 1;
+        final int highPriority = InstallableResource.DEFAULT_PRIORITY + 1;
 
         {
             resetCounters();

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java Wed Aug 11 18:09:23 2010
@@ -22,7 +22,6 @@ 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.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -72,11 +71,11 @@ public class ConfigPrioritiesTest extend
         final Dictionary<String, Object> data = new Hashtable<String, Object>();
 
         data.put("foo", "a");
-        final InstallableResource a = getInstallableResource(pid, data, InstallableResourceFactory.DEFAULT_PRIORITY - 1);
+        final InstallableResource a = getInstallableResource(pid, data, InstallableResource.DEFAULT_PRIORITY - 1);
         data.put("foo", "b");
-        final InstallableResource b = getInstallableResource(pid, data, InstallableResourceFactory.DEFAULT_PRIORITY);
+        final InstallableResource b = getInstallableResource(pid, data, InstallableResource.DEFAULT_PRIORITY);
         data.put("foo", "c");
-        final InstallableResource c = getInstallableResource(pid, data, InstallableResourceFactory.DEFAULT_PRIORITY + 1);
+        final InstallableResource c = getInstallableResource(pid, data, InstallableResource.DEFAULT_PRIORITY + 1);
 
         installer.addResource(URL_SCHEME, b);
         assertConfigValue(pid, "foo", "b", TIMEOUT);

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/MockInstallableResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/MockInstallableResource.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/MockInstallableResource.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/MockInstallableResource.java Wed Aug 11 18:09:23 2010
@@ -30,68 +30,31 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.apache.sling.osgi.installer.InstallableResource;
-import org.apache.sling.osgi.installer.InstallableResourceFactory;
 
-public class MockInstallableResource implements InstallableResource {
+public class MockInstallableResource extends InstallableResource {
 
     private static int counter;
 
-    private final String uri;
-    private final InputStream is;
-    private final String digest;
-    private final String 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) {
-        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;
+        super(uri, new ByteArrayInputStream(data.getBytes()),
+                null, getNextDigest(digest),
+                InstallableResource.TYPE_BUNDLE, null);
     }
 
     public MockInstallableResource(String uri, InputStream is, String digest, String 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;
+        super(uri, is,
+                null, digest,
+                type != null ? type : InstallableResource.TYPE_BUNDLE, priority);
     }
 
     public MockInstallableResource(String uri, Dictionary<String, Object> d, String digest,String 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 {
-            this.digest = computeDigest(d);
-        }
-        this.d = d;
+        super(uri, null,
+                d, digest != null ? digest : computeDigest(d),
+                type != null ? type : InstallableResource.TYPE_CONFIG, priority);
     }
 
     static String getNextDigest(String digest) {
@@ -103,30 +66,6 @@ public class MockInstallableResource imp
         }
     }
 
-    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 String getType() {
-        return this.type;
-    }
-
-    public String getId() {
-        return this.uri;
-    }
-
     /** The digest to be used. */
     private static final String DIGEST_TYPE = "MD5";
 

Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java?rev=984500&r1=984499&r2=984500&view=diff
==============================================================================
--- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java (original)
+++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Wed Aug 11 18:09:23 2010
@@ -35,7 +35,6 @@ 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.OsgiInstaller;
 import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 import org.ops4j.pax.exam.Inject;
@@ -272,7 +271,7 @@ class OsgiInstallerTestBase implements F
     }
 
     protected InstallableResource getInstallableResource(File testBundle, String digest) throws IOException {
-        return getInstallableResource(testBundle, digest, InstallableResourceFactory.DEFAULT_PRIORITY);
+        return getInstallableResource(testBundle, digest, InstallableResource.DEFAULT_PRIORITY);
     }
 
     protected InstallableResource getInstallableResource(File testBundle, String digest, int priority) throws IOException {
@@ -285,7 +284,7 @@ class OsgiInstallerTestBase implements F
     }
 
     protected InstallableResource getInstallableResource(String configPid, Dictionary<String, Object> data) {
-        return getInstallableResource(configPid, data, InstallableResourceFactory.DEFAULT_PRIORITY);
+        return getInstallableResource(configPid, data, InstallableResource.DEFAULT_PRIORITY);
     }
 
     protected InstallableResource getInstallableResource(String configPid, Dictionary<String, Object> data, int priority) {



Mime
View raw message