You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/06/17 21:16:22 UTC

svn commit: r955712 - 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...

Author: cziegeler
Date: Thu Jun 17 19:16:21 2010
New Revision: 955712

URL: http://svn.apache.org/viewvc?rev=955712&view=rev
Log:
SLING-1560 : Improve and clean up code
Make InstallableResource an implementation again and remove different sub classes.

Removed:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableBundleResource.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableConfigResource.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/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.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/OsgiInstallerThread.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/RegisteredResourceComparator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ConfigNodeConverter.java Thu Jun 17 19:16:21 2010
@@ -29,7 +29,6 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
-import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,7 +50,7 @@ class ConfigNodeConverter implements Jcr
 
 		// We only consider CONFIG_NODE_TYPE nodes
 		if(n.isNodeType(CONFIG_NODE_TYPE)) {
-			result = new InstallableConfigResource(urlScheme + ":" + n.getPath(), load(n), priority);
+			result = new InstallableResource(urlScheme + ":" + n.getPath(), load(n), priority);
 			log.debug("Converted node {} to {}", n.getPath(), result);
 		} else {
 			log.debug("Node is not a {} node, ignored:{}", CONFIG_NODE_TYPE, n.getPath());

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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FileNodeConverter.java Thu Jun 17 19:16:21 2010
@@ -23,7 +23,6 @@ import java.util.regex.Pattern;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
-import org.apache.sling.osgi.installer.InstallableBundleResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -78,7 +77,7 @@ import org.slf4j.LoggerFactory;
         	throw new IOException("Missing " + JCR_CONTENT_DATA + " property");
         }
 
-        return new InstallableBundleResource(urlScheme + ":" + path, is, digest, priority);
+        return new InstallableResource(urlScheme + ":" + path, is, digest, priority);
 	}
 
 	boolean acceptNodeName(String name) {

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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java Thu Jun 17 19:16:21 2010
@@ -20,9 +20,9 @@ package org.apache.sling.jcr.jcrinstall.
 
 import java.io.ByteArrayInputStream;
 
-import org.apache.sling.osgi.installer.InstallableBundleResource;
+import org.apache.sling.osgi.installer.InstallableResource;
 
-public class MockInstallableResource extends InstallableBundleResource {
+public class MockInstallableResource extends InstallableResource {
 
     private static int counter;
 

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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Thu Jun 17 19:16:21 2010
@@ -21,37 +21,154 @@ package org.apache.sling.osgi.installer;
 import java.io.InputStream;
 import java.util.Dictionary;
 
-/** A piece of data that can be installed by the OSGi controller.
- * 	Wraps either a Dictionary or an InputStream.
- *  Extension is used to decide which type of data (bundle, config, etc.).
+/**
+ * A piece of data that can be installed by the {@link OsgiInstaller}
+ * Currently the OSGi installer supports bundles and configurations.
  */
-public interface InstallableResource {
+public class InstallableResource {
 
-	/** Return this data's URL. It is opaque for the {@link OsgiInstaller}
+    /** The supported resource types. */
+    public static enum Type {
+        BUNDLE,
+        CONFIG
+    };
+
+    /** 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.
 	 */
-    String getUrl();
-
-	/** Return this resource's extension, based on its URL */
-    String getExtension();
+    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.
 	 */
-    InputStream getInputStream();
+    public InputStream getInputStream() {
+        return this.inputStream;
+    }
 
 	/** Return this resource's dictionary. Null if resource contains an InputStream instead */
-	Dictionary<String, Object> getDictionary();
+	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.
 	 */
-    String getDigest();
+    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.)
 	 */
-    int getPriority();
+    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;
+    }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Thu Jun 17 19:16:21 2010
@@ -299,13 +299,12 @@ class OsgiInstallerThread extends Thread
             if(group.isEmpty()) {
                 continue;
             }
-            final RegisteredResource.ResourceType rt = group.first().getResourceType();
-            if(rt.equals(RegisteredResource.ResourceType.BUNDLE)) {
-                bundleTaskCreator.createTasks(ctx, group, tasks);
-            } else if(rt.equals(RegisteredResource.ResourceType.CONFIG)) {
-                configTaskCreator.createTasks(ctx, group, tasks);
-            } else {
-                throw new IllegalArgumentException("No TaskCreator for resource type "+ group.first().getResourceType());
+            final InstallableResource.Type rt = group.first().getResourceType();
+            switch (rt) {
+                case BUNDLE:bundleTaskCreator.createTasks(ctx, group, tasks);
+                            break;
+                case CONFIG:configTaskCreator.createTasks(ctx, group, tasks);
+                            break;
             }
         }
     }

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=955712&r1=955711&r2=955712&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 Thu Jun 17 19:16:21 2010
@@ -23,25 +23,21 @@ import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Map;
 
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.osgi.framework.BundleContext;
 
 /** A resource that's been registered in the OSGi controller.
  * 	Data can be either an InputStream or a Dictionary, and we store
- *  it locally to avoid holding up to classes or data from our 
- *  clients, in case those disappear while we're installing stuff. 
+ *  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 {
 
-	static enum ResourceType {
-        BUNDLE,
-        CONFIG
-    }
-    
 	public static final String DIGEST_TYPE = "MD5";
     public static final String ENTITY_JAR_PREFIX = "jar:";
 	public static final String ENTITY_BUNDLE_PREFIX = "bundle:";
 	public static final String ENTITY_CONFIG_PREFIX = "config:";
-	
+
 	void cleanup(OsgiInstallerContext ctx);
 	String getURL();
 	InputStream getInputStream(BundleContext bc) throws IOException;
@@ -50,21 +46,21 @@ public interface RegisteredResource {
 	String getUrl();
 	boolean isInstallable();
 	void setInstallable(boolean installable);
-	ResourceType getResourceType();
+	InstallableResource.Type getResourceType();
 	String getUrlScheme();
 	int getPriority();
 	long getSerialNumber();
-	
+
 	/** Attributes include the bundle symbolic name, bundle version, etc. */
 	Map<String, Object> getAttributes();
-	
+
 	/** Return the identifier of the OSGi "entity" that this resource
      *  represents, for example "bundle:SID" where SID is the bundle's
-     *  symbolic ID, or "config:PID" where PID is config's PID. 
+     *  symbolic ID, or "config:PID" where PID is config's PID.
      */
     String getEntityId();
-    
+
     /** Attribute key: configuration pid */
     String CONFIG_PID_ATTRIBUTE = "config.pid";
-    
+
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java?rev=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java Thu Jun 17 19:16:21 2010
@@ -21,6 +21,7 @@ package org.apache.sling.osgi.installer.
 import java.io.Serializable;
 import java.util.Comparator;
 
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
@@ -34,8 +35,8 @@ class RegisteredResourceComparator imple
     private static final long serialVersionUID = 1L;
 
     public int compare(RegisteredResource a, RegisteredResource b) {
-    	final boolean aBundle = a.getResourceType() == RegisteredResource.ResourceType.BUNDLE;
-    	final boolean bBundle = b.getResourceType() == RegisteredResource.ResourceType.BUNDLE;
+    	final boolean aBundle = a.getResourceType() == InstallableResource.Type.BUNDLE;
+    	final boolean bBundle = b.getResourceType() == InstallableResource.Type.BUNDLE;
 
         if(aBundle && bBundle) {
             return compareBundles(a, b);

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java Thu Jun 17 19:16:21 2010
@@ -64,12 +64,7 @@ public class RegisteredResourceImpl impl
     private final long serialNumber;
     private static long serialNumberCounter = System.currentTimeMillis();
 
-    static enum ResourceType {
-        BUNDLE,
-        CONFIG
-    }
-
-    private final RegisteredResource.ResourceType resourceType;
+    private final InstallableResource.Type resourceType;
 
     public static final String ENTITY_JAR_PREFIX = "jar:";
 	public static final String ENTITY_BUNDLE_PREFIX = "bundle:";
@@ -85,7 +80,7 @@ public class RegisteredResourceImpl impl
 	    try {
     		url = input.getUrl();
     		urlScheme = getUrlScheme(url);
-    		resourceType = computeResourceType(input.getExtension());
+    		resourceType = input.getType();
     		priority = input.getPriority();
     		serialNumber = getNextSerialNumber();
 
@@ -93,7 +88,7 @@ public class RegisteredResourceImpl impl
                 throw new IllegalArgumentException("Missing digest: " + input);
             }
 
-    		if(resourceType == RegisteredResource.ResourceType.BUNDLE) {
+    		if(resourceType == InstallableResource.Type.BUNDLE) {
                 if(input.getInputStream() == null) {
                     throw new IllegalArgumentException("InputStream is required for BUNDLE resource type: " + input);
                 }
@@ -227,17 +222,10 @@ public class RegisteredResourceImpl impl
 	    return url;
 	}
 
-    public RegisteredResource.ResourceType getResourceType() {
+    public InstallableResource.Type getResourceType() {
         return resourceType;
     }
 
-    static RegisteredResource.ResourceType computeResourceType(String extension) {
-        if(extension.equals("jar")) {
-            return RegisteredResource.ResourceType.BUNDLE;
-        }
-        return RegisteredResource.ResourceType.CONFIG;
-    }
-
     /** Return the identifier of the OSGi "entity" that this resource
      *  represents, for example "bundle:SID" where SID is the bundle's
      *  symbolic ID, or "config:PID" where PID is config's PID.

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

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java?rev=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java Thu Jun 17 19:16:21 2010
@@ -25,7 +25,7 @@ import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.sling.osgi.installer.InstallableBundleResource;
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 
@@ -41,7 +41,7 @@ public class MockBundleResource implemen
 	private static long serialNumberCounter = System.currentTimeMillis();
 
     MockBundleResource(String symbolicName, String version) {
-        this(symbolicName, version, InstallableBundleResource.DEFAULT_PRIORITY);
+        this(symbolicName, version, InstallableResource.DEFAULT_PRIORITY);
     }
 
 	MockBundleResource(String symbolicName, String version, int priority) {
@@ -99,8 +99,8 @@ public class MockBundleResource implemen
 		return null;
 	}
 
-	public ResourceType getResourceType() {
-		return RegisteredResource.ResourceType.BUNDLE;
+	public InstallableResource.Type getResourceType() {
+		return InstallableResource.Type.BUNDLE;
 	}
 
 	public String getUrl() {

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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Thu Jun 17 19:16:21 2010
@@ -28,7 +28,7 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.sling.osgi.installer.InstallableConfigResource;
+import org.apache.sling.osgi.installer.InstallableResource;
 import org.junit.Test;
 
 public class RegisteredResourceComparatorTest {
@@ -48,7 +48,7 @@ public class RegisteredResourceComparato
             data = new Hashtable<String, Object>();
             data.put("foo", "bar");
         }
-        final InstallableConfigResource r = new InstallableConfigResource("test:" + url, data, priority);
+        final InstallableResource r = new InstallableResource("test:" + url, data, priority);
         return new RegisteredResourceImpl(new MockOsgiInstallerContext(), r);
     }
 
@@ -173,7 +173,7 @@ public class RegisteredResourceComparato
 
     @Test
     public void testConfigAndBundle() throws IOException {
-    	final RegisteredResource cfg = getConfig("pid", null, InstallableConfigResource.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=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Thu Jun 17 19:16:21 2010
@@ -34,8 +34,6 @@ import java.io.InputStream;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.sling.osgi.installer.InstallableBundleResource;
-import org.apache.sling.osgi.installer.InstallableConfigResource;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.osgi.framework.Constants;
 
@@ -67,7 +65,7 @@ public class RegisteredResourceTest {
 		}
 
 		final TestInputStream t = new TestInputStream(new ByteArrayInputStream(data.getBytes()));
-		final InstallableResource ir = new InstallableBundleResource(TEST_URL, t, "somedigest");
+		final InstallableResource ir = new InstallableResource(TEST_URL, t, "somedigest");
 		assertEquals("TestInputStream must not be closed before test", 0, t.closeCount);
 		new LocalFileRegisteredResource(ir);
 		assertEquals("TestInputStream must be closed by RegisteredResource", 1, t.closeCount);
@@ -76,9 +74,9 @@ 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 InstallableBundleResource("test:1.jar", s, "some digest"));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, "some digest"));
             assertEquals(".jar URL creates a BUNDLE resource",
-                    RegisteredResource.ResourceType.BUNDLE, r.getResourceType());
+                    InstallableResource.Type.BUNDLE, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNotNull("BUNDLE resource provides an InputStream", rs);
             rs.close();
@@ -88,9 +86,9 @@ public class RegisteredResourceTest {
 
         {
             final InputStream s = new ByteArrayInputStream("foo=bar\nother=2".getBytes());
-            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableBundleResource("test:1.properties", s, "digest1"));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.properties", s, "digest1"));
             assertEquals(".properties URL creates a CONFIG resource",
-                    RegisteredResource.ResourceType.CONFIG, r.getResourceType());
+                    InstallableResource.Type.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNull("CONFIG resource does not provide an InputStream", rs);
             final Dictionary<String, Object> d = r.getDictionary();
@@ -103,9 +101,9 @@ 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 InstallableConfigResource("test:1", data));
+            final RegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1", data));
             assertEquals("No-extension URL with Dictionary creates a CONFIG resource",
-                    RegisteredResource.ResourceType.CONFIG, r.getResourceType());
+                    InstallableResource.Type.CONFIG, r.getResourceType());
             final InputStream rs = r.getInputStream(null);
             assertNull("CONFIG resource does not provide an InputStream", rs);
             final Dictionary<String, Object> d = r.getDictionary();
@@ -118,7 +116,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 InstallableBundleResource("test:1.jar", s, "somedigest"));
+		final LocalFileRegisteredResource r = new LocalFileRegisteredResource(new InstallableResource("test:1.jar", s, "somedigest"));
 		assertTrue("Local file exists", r.getDataFile(null).exists());
 
 		assertEquals("Local file length matches our data", f.length(), r.getDataFile(null).length());
@@ -129,13 +127,13 @@ public class RegisteredResourceTest {
         final InputStream in = new ByteArrayInputStream(data.getBytes());
 
         try {
-            new LocalFileRegisteredResource(new InstallableBundleResource("test:1.jar", in, null));
+            new LocalFileRegisteredResource(new InstallableResource("test:1.jar", in, null));
             fail("With jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
 
         try {
-            new LocalFileRegisteredResource(new InstallableBundleResource("test:1.foo", in, null));
+            new LocalFileRegisteredResource(new InstallableResource("test:1.foo", in, null));
             fail("With non-jar extension, expected an IllegalArgumentException as digest is null");
         } catch(IllegalArgumentException asExpected) {
         }
@@ -143,14 +141,14 @@ public class RegisteredResourceTest {
 
     @org.junit.Test public void testBundleManifest() throws Exception {
         final File f = getTestBundle("testbundle-1.0.jar");
-        final InstallableResource i = new InstallableBundleResource("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName());
+        final InstallableResource i = new InstallableResource("test:" + f.getAbsolutePath(), new FileInputStream(f), f.getName());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNotNull("RegisteredResource must have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "bundle:osgi-installer-testbundle", r.getEntityId());
     }
 
     @org.junit.Test public void testConfigEntity() throws Exception {
-        final InstallableResource i = new InstallableConfigResource("test:/foo/someconfig", new Hashtable<String, Object>());
+        final InstallableResource i = new InstallableResource("test:/foo/someconfig", new Hashtable<String, Object>());
         final RegisteredResource r = new LocalFileRegisteredResource(i);
         assertNull("RegisteredResource must not have bundle symbolic name", r.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME));
         assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId());
@@ -158,8 +156,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 InstallableConfigResource("test:urlA", data);
-        final InstallableResource rB = new InstallableConfigResource("test:urlB", data);
+        final InstallableResource rA = new InstallableResource("test:urlA", data);
+        final InstallableResource rB = new InstallableResource("test:urlB", data);
         assertFalse(
                 "Expecting configs with same data but different URLs to have different digests",
                 rA.getDigest().equals(rB.getDigest()));
@@ -177,7 +175,7 @@ public class RegisteredResourceTest {
         };
         for(String url : badOnes) {
             try {
-                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableBundleResource(url, s, null));
+                new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, s, null));
                 fail("Expected bad URL '" + url + "' to throw IllegalArgumentException");
             } catch(IllegalArgumentException asExpected) {
             }
@@ -192,7 +190,7 @@ public class RegisteredResourceTest {
 
         for(String url : goodOnes) {
             final RegisteredResource r = new RegisteredResourceImpl(new MockOsgiInstallerContext(),
-                    new InstallableBundleResource(url, s, "digest1"));
+                    new InstallableResource(url, s, "digest1"));
             assertEquals("Expected scheme 'foo' for URL " + url, "foo", r.getUrlScheme());
         }
     }

Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=955712&r1=955711&r2=955712&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (original)
+++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Thu Jun 17 19:16:21 2010
@@ -26,7 +26,7 @@ import java.util.Hashtable;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.sling.osgi.installer.InstallableConfigResource;
+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;
@@ -49,7 +49,7 @@ public class TaskOrderingTest {
 	}
 
 	private static RegisteredResource getRegisteredResource(String url) throws IOException {
-		return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableConfigResource(url, new Hashtable<String, Object>()));
+		return new RegisteredResourceImpl(new MockOsgiInstallerContext(), new InstallableResource(url, new Hashtable<String, Object>()));
 	}
 
 	private void assertOrder(int testId, Collection<OsgiInstallerTask> actual, OsgiInstallerTask [] expected) {