incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r983998 [1/3] - 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/ o...
Date Tue, 10 Aug 2010 13:38:01 GMT
Author: cziegeler
Date: Tue Aug 10 13:37:59 2010
New Revision: 983998

URL: http://svn.apache.org/viewvc?rev=983998&view=rev
Log:
SLING-1560 : Improve and clean up code
Removed the input stream support for dictionaries from the osgi installer - reading configurations is up to the providers like jcr install. By removing this we can reduce the complexity of the installer.
Moved logging to a Logger class to avoid passing around the installer context just for logging
Moved statistics methods to own interface as this is just used for testing and should not be part of the public api
Cleaned up installable resource factory
Changed type of installable resource from enum to String in order to provide pluggable installers in the future

Added:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstallerStatistics.java   (with props)
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Logger.java   (with props)
Removed:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/propertyconverter/
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryConversionTest.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/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.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
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.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/PersistentBundleInfo.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.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/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.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/MockOsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfoTest.java
    sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/PersistentResourceListTest.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/BundleDependenciesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallStressTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.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/BundleSnapshotUpdateTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ContextBundleUpdateTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.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
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RemovedResourceDetectionTest.java
    sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/WorkerThreadIdleTest.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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -52,7 +52,7 @@ class ConfigNodeConverter implements Jcr
 
 		// We only consider CONFIG_NODE_TYPE nodes
 		if(n.isNodeType(CONFIG_NODE_TYPE)) {
-			result = factory.create(urlScheme + ":" + n.getPath(), load(n), null, null, priority);
+			result = factory.create(urlScheme + ":" + 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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -87,7 +87,7 @@ import org.slf4j.LoggerFactory;
         	throw new IOException("Missing " + JCR_CONTENT_DATA + " property");
         }
 
-        return factory.create(urlScheme + ":" + path, is, digest, null, priority);
+        return factory.create(urlScheme + ":" + path, is, null, digest, null, 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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -39,7 +39,7 @@ public class MockInstallableResource imp
     private final String uri;
     private final InputStream is;
     private final String digest;
-    private final InstallableResource.Type type;
+    private final String type;
     private final int priority;
     private final Dictionary<String, Object> d;
 
@@ -51,19 +51,19 @@ public class MockInstallableResource imp
         this.uri = uri;
         this.is = new ByteArrayInputStream(data.getBytes());
         this.digest = getNextDigest(digest);
-        this.type = InstallableResource.Type.BUNDLE;
+        this.type = InstallableResource.TYPE_BUNDLE;
         this.priority = InstallableResourceFactory.DEFAULT_PRIORITY;
         this.d = null;
     }
 
-    public MockInstallableResource(String uri, InputStream is, String digest, InstallableResource.Type type, Integer priority) {
+    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;
+            this.type = InstallableResource.TYPE_BUNDLE;
         }
         if ( priority != null ) {
             this.priority = priority;
@@ -73,13 +73,13 @@ public class MockInstallableResource imp
         this.d = null;
     }
 
-    public MockInstallableResource(String uri, Dictionary<String, Object> d, String digest, InstallableResource.Type type, Integer 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;
+            this.type = InstallableResource.TYPE_CONFIG;
         }
         if ( priority != null ) {
             this.priority = priority;
@@ -119,7 +119,7 @@ public class MockInstallableResource imp
         return this.priority;
     }
 
-    public Type getType() {
+    public String getType() {
         return this.type;
     }
 

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResourceFactory.java Tue Aug 10 13:37:59 2010
@@ -23,18 +23,24 @@ import java.util.Dictionary;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.InstallableResourceFactory;
-import org.apache.sling.osgi.installer.InstallableResource.Type;
 
 
 class MockInstallableResourceFactory implements InstallableResourceFactory {
 
     public InstallableResource create(String url, Dictionary<String, Object> d,
-            String digest, Type type, Integer priority) {
+            String digest, String type, Integer priority) {
         return new MockInstallableResource(url, d, digest, type, priority);
     }
 
     public InstallableResource create(String url, InputStream is,
-            String digest, Type type, Integer priority) {
+            String digest, String type, Integer priority) {
         return new MockInstallableResource(url, is, digest, type, priority);
     }
+
+    public InstallableResource create(String url, InputStream is,
+            Dictionary<String, Object> d, String digest, String type,
+            Integer priority) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java (original)
+++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java Tue Aug 10 13:37:59 2010
@@ -28,11 +28,12 @@ import java.util.Set;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 
 
-class MockOsgiInstaller implements OsgiInstaller {
+class MockOsgiInstaller implements OsgiInstaller, OsgiInstallerStatistics {
 
-    private final long [] counters = new long[OsgiInstaller.COUNTERS_SIZE];
+    private final long [] counters = new long[OsgiInstallerStatistics.COUNTERS_SIZE];
 
     static class InstallableResourceComparator implements Comparator<InstallableResource> {
         public int compare(InstallableResource a, InstallableResource b) {

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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -30,11 +30,16 @@ import java.util.Dictionary;
  */
 public interface InstallableResource {
 
-    /** The supported resource types. */
-    public static enum Type {
-        BUNDLE,  // in this case getInputStream must return an input stream
-        CONFIG   // in this case getDictionary must return the dictionary
-    };
+    /** 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";
+
+    /** The type for a configuration - in this case {@link #getDictionary()}
+     * must return a dictionary with the configuration.
+     */
+    String TYPE_CONFIG = "config";
 
     /**
      * Return this data's URL. It is opaque for the {@link OsgiInstaller}
@@ -47,11 +52,11 @@ public interface InstallableResource {
 	 * Return the type of this resource.
 	 * @return The resource type.
 	 */
-    Type getType();
+    String getType();
 
 	/**
 	 * Return an input stream with the data of this resource.
-	 * Null if resource contains a dictionary instead. Caller is responsible for
+	 * 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!
@@ -63,7 +68,7 @@ public interface InstallableResource {
 	 * 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 must not return a dictionary!
+	 * it might return a dictionary!
 	 * @return The resource's dictionary or null.
 	 */
 	Dictionary<String, Object> getDictionary();

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResourceFactory.java Tue Aug 10 13:37:59 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.sling.osgi.installer;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Dictionary;
 
@@ -32,13 +33,16 @@ public interface InstallableResourceFact
     int DEFAULT_PRIORITY = 100;
 
     /**
-     * Create a data object based on an input stream.
-     * The data object is derived from the supplied input stream. If no resource type
-     * is specified, the type is detected.
+     * Create a data object.
+     * If no input stream is provided, the resource is of
+     * type {@link InstallableResource#TYPE_CONFIG}. If an input stream is
+     * provided, the data object is derived from the supplied input stream.
+     * In this case, if no resource type is specified, the type is detected.
      *
      * @param url unique URL of the supplied data, must start with the scheme used
      *     {@link OsgiInstaller#registerResources} call
-     * @param is the resource contents
+     * @param is the resource contents or
+     * @param d the config dictionary
      * @param digest must be supplied by client. Does not need to be an actual digest
      *     of the contents, but must change if the contents change. Having this supplied
      *     by the client avoids having to compute real digests to find out if a resource
@@ -47,38 +51,15 @@ public interface InstallableResourceFact
      * @param optional resource type - if the client knows the resource type it should
      *     be specified - if not, the factory detects the type
      * @param optional priority - if not specified {@link #DEFAULT_PRIORITY} will be used.
-     * @return A new installable resource or null if something goes wrong
+     * @return A new installable resource
+     * @throws IOException If the type can't be detected or something else is wrong...
+     * @throws IllegalArgumentException If required parameters are missing
      */
     InstallableResource create(String url,
                                InputStream is,
-                               String digest,
-                               InstallableResource.Type type,
-                               Integer priority);
-
-    /**
-     * Create a data object based on a dictionary.
-     * The data object is derived from the supplied dictionary. If no resource type
-     * is specified, the type is detected.
-     * Currently if a dictionary is provided, the resource is always assumed to be
-     * a configuration - specifying a different resource type with a dictionary
-     * results in an exception.
-     *
-     * @param url unique URL of the supplied data, must start with the scheme used
-     *     {@link OsgiInstaller#registerResources} call
-     * @param d the dictionary
-     * @param digest must be supplied by client. Does not need to be an actual digest
-     *     of the contents, but must change if the contents change. Having this supplied
-     *     by the client avoids having to compute real digests to find out if a resource
-     *     has changed, which can be expensive. If no digest is provided a digest
-     *     will be calculated
-     * @param optional resource type - if the client knows the resource type it should
-     *     be specified - if not, the factory detects the type
-     * @param optional priority - if not specified {@link #DEFAULT_PRIORITY} will be used.
-     * @return A new installable resource or null if something goes wrong
-     */
-    InstallableResource create(String url,
                                Dictionary<String, Object> d,
                                String digest,
-                               InstallableResource.Type type,
-                               Integer priority);
+                               String type,
+                               Integer priority)
+    throws IOException;
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Tue Aug 10 13:37:59 2010
@@ -57,29 +57,4 @@ public interface OsgiInstaller {
 	/** Inform the installer that a resource is no longer available
 	 * 	@param r an empty InstallableResource, isEmpty() must return true */
 	void removeResource(String url);
-
-	/** Return counters used for statistics, console display, testing, etc. */
-	long [] getCounters();
-
-	/** Counter index: number of OSGi tasks executed */
-	int OSGI_TASKS_COUNTER = 0;
-
-    /** Counter index: number of installer cycles */
-    int INSTALLER_CYCLES_COUNTER = 1;
-
-    /** Counter index: number of currently registered resources */
-    int REGISTERED_RESOURCES_COUNTER = 2;
-
-    /** Counter index: number of currently registered resource groups
-     *  of resources having the same OSGi entity ID */
-    int REGISTERED_GROUPS_COUNTER = 3;
-
-    /** Counter index: is worker thread idle? (not really a counter: 1 means true) */
-    int WORKER_THREAD_IS_IDLE_COUNTER = 4;
-
-    /** Counter index: how many times did worker thread become idle */
-    int WORKER_THREAD_BECOMES_IDLE_COUNTER = 5;
-
-	/** Size of the counters array */
-	int COUNTERS_SIZE = 6;
 }
\ No newline at end of file

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstallerStatistics.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstallerStatistics.java?rev=983998&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstallerStatistics.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstallerStatistics.java Tue Aug 10 13:37:59 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.osgi.installer;
+
+
+/**
+ * Statistics about the OSGi installer.
+ *
+ * TODO Remove this interface - it's just used for testing!!
+ */
+public interface OsgiInstallerStatistics {
+
+	/** Return counters used for statistics, console display, testing, etc. */
+	long [] getCounters();
+
+	/** Counter index: number of OSGi tasks executed */
+	int OSGI_TASKS_COUNTER = 0;
+
+    /** Counter index: number of installer cycles */
+    int INSTALLER_CYCLES_COUNTER = 1;
+
+    /** Counter index: number of currently registered resources */
+    int REGISTERED_RESOURCES_COUNTER = 2;
+
+    /** Counter index: number of currently registered resource groups
+     *  of resources having the same OSGi entity ID */
+    int REGISTERED_GROUPS_COUNTER = 3;
+
+    /** Counter index: is worker thread idle? (not really a counter: 1 means true) */
+    int WORKER_THREAD_IS_IDLE_COUNTER = 4;
+
+    /** Counter index: how many times did worker thread become idle */
+    int WORKER_THREAD_BECOMES_IDLE_COUNTER = 5;
+
+	/** Size of the counters array */
+	int COUNTERS_SIZE = 6;
+}
\ No newline at end of file

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

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

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

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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -22,6 +22,7 @@ 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;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -30,25 +31,36 @@ import org.osgi.framework.Constants;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
 
 public class Activator implements BundleActivator, FrameworkListener, BundleListener {
 
+    /** Interface of the log service */
+    private static String LOG_SERVICE_NAME = "org.osgi.service.log.LogService";
+
+    /** Vendor of all registered services. */
     private static final String VENDOR = "The Apache Software Foundation";
 
     private OsgiInstallerImpl osgiControllerService;
     private ServiceRegistration osgiControllerServiceReg;
     private ServiceRegistration factoryServiceReg;
 
+    /** Tracker for the log service. */
+    private ServiceTracker logServiceTracker;
+
     private static long eventsCount;
 
     /**
      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
      */
-    public void start(BundleContext context) throws Exception {
+    public void start(final BundleContext context) throws Exception {
         // listen to framework and bundle events
         context.addFrameworkListener(this);
         context.addBundleListener(this);
 
+        this.logServiceTracker = new ServiceTracker(context, LOG_SERVICE_NAME, null);
+        this.logServiceTracker.open();
+        Logger.setTracker(this.logServiceTracker);
         // register OsgiController service
         {
             final Hashtable<String, String> props = new Hashtable<String, String>();
@@ -57,7 +69,8 @@ public class Activator implements Bundle
 
             this.osgiControllerService = new OsgiInstallerImpl(context);
             final String [] serviceInterfaces = {
-                    OsgiInstaller.class.getName()
+                    OsgiInstaller.class.getName(),
+                    OsgiInstallerStatistics.class.getName()
             };
             osgiControllerServiceReg = context.registerService(serviceInterfaces, osgiControllerService, props);
         }
@@ -71,13 +84,6 @@ public class Activator implements Bundle
             factoryServiceReg = context.registerService(InstallableResourceFactory.class.getName(),
                     new InstallableResourceFactoryImpl(), props);
         }
-
-        // register EventsCounter service
-        {
-            final Hashtable<String, String> props = new Hashtable<String, String>();
-            props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling EventsCounter Service");
-            props.put(Constants.SERVICE_VENDOR, VENDOR);
-        }
     }
 
     /**
@@ -87,18 +93,23 @@ public class Activator implements Bundle
     	context.removeBundleListener(this);
     	context.removeFrameworkListener(this);
 
-    	if ( this.factoryServiceReg != null ) {
-    	    this.factoryServiceReg.unregister();
-    	    this.factoryServiceReg = null;
-    	}
-        if ( this.osgiControllerServiceReg != null ) {
-            this.osgiControllerServiceReg.unregister();
-            this.osgiControllerServiceReg = null;
-        }
         if ( this.osgiControllerService != null ) {
             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;
+        }
+        Logger.setTracker(null);
+    	if ( this.logServiceTracker != null ) {
+    	    this.logServiceTracker.close();
+    	    this.logServiceTracker = null;
+    	}
     }
 
     /** Used for tasks that wait for a framework or bundle event before retrying their operations */
@@ -106,11 +117,14 @@ public class Activator implements Bundle
         return eventsCount;
     }
 
-    public void frameworkEvent(FrameworkEvent arg0) {
+    /**
+     * @see org.osgi.framework.FrameworkListener#frameworkEvent(org.osgi.framework.FrameworkEvent)
+     */
+    public void frameworkEvent(final FrameworkEvent event) {
         eventsCount++;
     }
 
-    public void bundleChanged(BundleEvent arg0) {
+    public void bundleChanged(final BundleEvent event) {
         eventsCount++;
     }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Tue Aug 10 13:37:59 2010
@@ -76,7 +76,6 @@ class BundleTaskCreator {
 			}
 		}
 
-		RegisteredResource toUpdate = null;
 		String digestToSave = null;
 		final RegisteredResource firstResource = resources.first();
 		final String symbolicName = firstResource == null ? null :
@@ -87,7 +86,7 @@ class BundleTaskCreator {
 		    // and if we installed it
 		    if(getBundleInfo(ctx, resources.first()) != null) {
 		        if(ctx.getInstalledBundleVersion(symbolicName) == null) {
-		            ctx.logInfo("Bundle " + symbolicName
+		            Logger.logInfo("Bundle " + symbolicName
                                 + " was not installed by this module, not removed");
 		        } else {
 		            tasks.add(new BundleRemoveTask(resources.first()));
@@ -97,7 +96,8 @@ class BundleTaskCreator {
 		} else {
 			final BundleInfo info = getBundleInfo(ctx, toActivate);
 			final Version newVersion = new Version((String)toActivate.getAttributes().get(Constants.BUNDLE_VERSION));
-			if(info == null) {
+	        RegisteredResource toUpdate = null;
+			if (info == null) {
 			    // bundle is not installed yet: install and save digest to avoid
 			    // unnecessary updates
 				tasks.add(new BundleInstallTask(toActivate));
@@ -113,10 +113,10 @@ class BundleTaskCreator {
                     final String installedVersion = ctx.getInstalledBundleVersion(info.symbolicName);
                     if(info.version.toString().equals(installedVersion)) {
                         toUpdate = toActivate;
-                        ctx.logInfo("Bundle " + info.symbolicName + " " + installedVersion
+                        Logger.logInfo("Bundle " + info.symbolicName + " " + installedVersion
                                     + " was installed by this module, downgrading to " + newVersion);
                     } else {
-                        ctx.logInfo("Bundle " + info.symbolicName + " " + installedVersion
+                        Logger.logInfo("Bundle " + info.symbolicName + " " + installedVersion
                                     + " was not installed by this module, not downgraded");
                     }
 			    } else if(compare == 0 && ctx.isSnapshot(newVersion)){
@@ -127,13 +127,13 @@ class BundleTaskCreator {
 
 			// Save the digest of installed and updated resources, keyed by
 			// bundle symbolic name, to avoid unnecessary updates
-			if(toUpdate != null) {
+			if (toUpdate != null) {
 			    final String previousDigest = digests.get(symbolicName);
 			    if(toUpdate.getDigest().equals(previousDigest)) {
-			        ctx.logDebug("Ignoring update of " + toUpdate + ", digest didn't change");
+			        Logger.logDebug("Ignoring update of " + toUpdate + ", digest didn't change");
                     digestToSave = previousDigest;
 			    } else {
-			        ctx.logDebug("Scheduling update of " + toUpdate + ", digest has changed");
+			        Logger.logDebug("Scheduling update of " + toUpdate + ", digest has changed");
 			        tasks.add(new BundleUpdateTask(toUpdate));
 			        digestToSave = toUpdate.getDigest();
 			    }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java Tue Aug 10 13:37:59 2010
@@ -55,11 +55,11 @@ class ConfigTaskCreator {
 		    final String key = getDigestKey(toActivate);
 		    final String previousDigest = digests.get(key);
 		    if(toActivate.getDigest().equals(previousDigest)) {
-		        ctx.logDebug("Configuration (" + key+ ") already installed, ignored: " + toActivate);
+		        Logger.logDebug("Configuration (" + key+ ") already installed, ignored: " + toActivate);
 		    } else {
 		        tasks.add(new ConfigInstallTask(toActivate));
 		        digests.put(key, toActivate.getDigest());
-                ctx.logDebug("Scheduling update/install of config " + toActivate + ", digest has changed or was absent");
+		        Logger.logDebug("Scheduling update/install of config " + toActivate + ", digest has changed or was absent");
 		    }
 		}
 	}

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DigestUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DigestUtil.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DigestUtil.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DigestUtil.java Tue Aug 10 13:37:59 2010
@@ -39,7 +39,7 @@ public abstract class DigestUtil {
     public static final String DIGEST_TYPE = "MD5";
 
     /** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */
-    public static String digestToString(MessageDigest d) {
+    private static String digestToString(MessageDigest d) {
         final BigInteger bigInt = new BigInteger(1, d.digest());
         return new String(bigInt.toString(16));
     }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceFactoryImpl.java Tue Aug 10 13:37:59 2010
@@ -20,16 +20,11 @@ package org.apache.sling.osgi.installer.
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
 import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Properties;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.InstallableResourceFactory;
-import org.apache.sling.osgi.installer.InstallableResource.Type;
-import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyConverter;
-import org.apache.sling.osgi.installer.impl.propertyconverter.PropertyValue;
 
 /**
  * Default implementation of the installable resource factory.
@@ -37,85 +32,45 @@ import org.apache.sling.osgi.installer.i
 public class InstallableResourceFactoryImpl implements InstallableResourceFactory {
 
     /**
-     * @see org.apache.sling.osgi.installer.InstallableResourceFactory#create(java.lang.String, java.io.InputStream, java.lang.String, org.apache.sling.osgi.installer.InstallableResource.Type, java.lang.Integer)
+     * @see org.apache.sling.osgi.installer.InstallableResourceFactory#create(java.lang.String, java.io.InputStream, java.util.Dictionary, java.lang.String, java.lang.String, java.lang.Integer)
      */
     public InstallableResource create(final String url,
                                final InputStream is,
+                               final Dictionary<String, Object> d,
                                final String digest,
-                               final InstallableResource.Type type,
-                               final Integer priority) {
+                               final String type,
+                               final Integer priority)
+    throws IOException {
         if ( url == null ) {
             throw new IllegalArgumentException("url must not be null.");
         }
         if ( is == null ) {
-            throw new IllegalArgumentException("input stream must not be null.");
-        }
-        final InstallableResource.Type resourceType = (type != null ? type : computeResourceType(getExtension(url)));
-        if ( resourceType == InstallableResource.Type.CONFIG ) {
+            // if input stream is null, config through dictionary is expected!
+            if ( d == null ) {
+                throw new IllegalArgumentException("dictionary must not be null.");
+            }
             try {
-                return this.create(url, readDictionary(is), digest, resourceType, priority);
-            } catch (IOException ignore) {
-                // TODO - log this
-                return null;
+                return new InstallableResourceImpl(url, null, d,
+                        (digest != null ? digest : url + ":" + DigestUtil.computeDigest(d)),
+                        (type != null ? type : InstallableResource.TYPE_CONFIG),
+                        (priority != null ? priority : DEFAULT_PRIORITY));
+            } catch ( final NoSuchAlgorithmException nsae) {
+                throw (IOException)new IOException("Digest not found.").initCause(nsae);
             }
         }
-
         // TODO - compute digest for bundle if digest is null - for now we throw
         if ( digest == null ) {
             throw new IllegalArgumentException("digest must not be null for a bundle.");
         }
 
-        return new InstallableResourceImpl(url, is, digest,
-                resourceType,
-                (priority != null ? priority : DEFAULT_PRIORITY));
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.InstallableResourceFactory#create(java.lang.String, java.util.Dictionary, java.lang.String, org.apache.sling.osgi.installer.InstallableResource.Type, java.lang.Integer)
-     */
-    public InstallableResource create(final String url,
-                               final Dictionary<String, Object> d,
-                               final String digest,
-                               final InstallableResource.Type type,
-                               final Integer priority) {
-        if ( url == null ) {
-            throw new IllegalArgumentException("url must not be null.");
-        }
-        if ( d == null ) {
-            throw new IllegalArgumentException("dictionary must not be null.");
+        final String resourceType = (type != null ? type : computeResourceType(getExtension(url)));
+        if ( resourceType.equals(InstallableResource.TYPE_CONFIG ) ) {
+            throw new IOException("Resource type config not supported for input streams: " + url);
         }
-        try {
-            return new InstallableResourceImpl(url, d,
-                    (digest != null ? digest : url + ":" + DigestUtil.computeDigest(d)),
-                    (type != null ? type : Type.CONFIG),
-                    (priority != null ? priority : DEFAULT_PRIORITY));
-        } catch (Exception ignore) {
-            // TODO - log this
-            return null;
-        }
-    }
 
-    /** Convert InputStream to Dictionary using our extended properties format,
-     *  which supports multi-value properties
-     */
-    private static Dictionary<String, Object> readDictionary(InputStream is) throws IOException {
-        try {
-            final Dictionary<String, Object> result = new Hashtable<String, Object>();
-            final PropertyConverter converter = new PropertyConverter();
-            final Properties p = new Properties();
-            p.load(is);
-            for(Map.Entry<Object, Object> e : p.entrySet()) {
-                final PropertyValue v = converter.convert((String)e.getKey(), (String)e.getValue());
-                result.put(v.getKey(), v.getValue());
-            }
-            return result;
-        } finally {
-            try {
-                is.close();
-            } catch (IOException ignore ) {
-                // we ignore this
-            }
-        }
+        return new InstallableResourceImpl(url, is, d, digest,
+                resourceType,
+                (priority != null ? priority : DEFAULT_PRIORITY));
     }
 
     /** Compute the extension */
@@ -124,10 +79,10 @@ public class InstallableResourceFactoryI
         return (pos < 0 ? "" : url.substring(pos+1));
     }
 
-    private static Type computeResourceType(String extension) {
-        if(extension.equals("jar")) {
-            return Type.BUNDLE;
+    private static String computeResourceType(String extension) {
+        if (extension.equals("jar")) {
+            return InstallableResource.TYPE_BUNDLE;
         }
-        return Type.CONFIG;
+        return InstallableResource.TYPE_CONFIG;
     }
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/InstallableResourceImpl.java Tue Aug 10 13:37:59 2010
@@ -35,51 +35,23 @@ public class InstallableResourceImpl imp
     private final InputStream inputStream;
     private final Dictionary<String, Object> dictionary;
     private final int priority;
-    private final Type resourceType;
+    private final String resourceType;
 
-    /** 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.
+    /**
+     * Create a data object.
      */
-    public InstallableResourceImpl(String url, InputStream is, String digest,
-            final Type type,
+    public InstallableResourceImpl(final String url,
+            final InputStream is,
+            final Dictionary<String, Object> dict,
+            String digest,
+            final String type,
             final int priority) {
         this.url = url;
         this.digest = digest;
         this.priority = priority;
         this.resourceType = type;
-//        if ( this.resourceType == Type.CONFIG ) {
-//            this.dictionary = null;
-//            this.inputStream = null;
-//        } else {
-            this.inputStream = is;
-            this.dictionary = null;
-//        }
-    }
-
-    /** Create a data object that wraps a Dictionary. Digest will be computed
-     *  by the installer in this case, as configuration dictionaries are
-     *  usually small so computing a real digest to find out if they changed
-     *  is ok.
-     *
-     *  @param url unique URL of the supplied data, must start with the scheme used
-     *     {@link OsgiInstaller#registerResources} call
-     */
-    public InstallableResourceImpl(final String url, final Dictionary<String, Object> d,
-            final String digest,
-            final Type type,
-            final int priority) {
-        this.url = url;
-        this.inputStream = null;
-        this.resourceType = type;
-        this.dictionary = d;
-        this.digest = digest;
-        this.priority = priority;
+        this.inputStream = is;
+        this.dictionary = dict;
     }
 
     /**
@@ -92,7 +64,7 @@ public class InstallableResourceImpl imp
     /**
      * @see org.apache.sling.osgi.installer.InstallableResource#getType()
      */
-    public Type getType() {
+    public String getType() {
         return this.resourceType;
     }
 

Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Logger.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Logger.java?rev=983998&view=auto
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Logger.java (added)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Logger.java Tue Aug 10 13:37:59 2010
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.osgi.installer.impl;
+
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+/**
+ * Logger support
+ */
+public class Logger {
+
+    /**
+     * Log a debug message.
+     */
+    public static void logDebug(final String message) {
+        log(LogService.LOG_DEBUG, message, null);
+    }
+
+    /**
+     * Log a debug message with exception.
+     */
+    public static void logDebug(final String message, final Throwable t) {
+        log(LogService.LOG_DEBUG, message, t);
+    }
+
+    /**
+     * Log a info message.
+     */
+    public static void logInfo(final String message) {
+        log(LogService.LOG_INFO, message, null);
+
+    }
+
+    /**
+     * Log a info message with exception.
+     */
+    public static void logInfo(final String message, final Throwable t) {
+        log(LogService.LOG_INFO, message, t);
+
+    }
+
+    /**
+     * Log a warning message.
+     */
+    public static void logWarn(final String message) {
+        log(LogService.LOG_WARNING, message, null);
+
+    }
+
+    /**
+     * Log a warning message with exception.
+     */
+    public static void logWarn(final String message, final Throwable t) {
+        log(LogService.LOG_WARNING, message, t);
+    }
+
+    /**
+     * Internal method for logging.
+     * This method checks if the LogService is available and only then logs
+     */
+    private static void log(final int level, final String message, final Throwable t) {
+        final ServiceTracker tracker = LOGGER_TRACKER;
+        if ( tracker != null ) {
+            final LogService ls = (LogService) tracker.getService();
+            if ( ls != null ) {
+                if ( t != null ) {
+                    ls.log(level, message, t);
+                } else {
+                    ls.log(level, message);
+                }
+            }
+        }
+    }
+
+    private static ServiceTracker LOGGER_TRACKER;
+
+    /** Set the logger tracker. */
+    static void setTracker(final ServiceTracker tracker) {
+        LOGGER_TRACKER = tracker;
+    }
+}
+

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

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

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

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java Tue Aug 10 13:37:59 2010
@@ -48,6 +48,9 @@ public interface OsgiInstallerContext {
 
     void incrementCounter(int index);
     void setCounter(int index, long value);
+    /**
+     * Finds the bundle with given symbolic name in our BundleContext.
+     */
     Bundle getMatchingBundle(String bundleSymbolicName);
     boolean isSnapshot(Version v);
 
@@ -71,34 +74,4 @@ public interface OsgiInstallerContext {
      *  @return null if no version was stored
      * */
     String getInstalledBundleVersion(String symbolicName) throws IOException;
-
-    /**
-     * Log a debug message.
-     */
-    void logDebug(final String message);
-
-    /**
-     * Log a debug message with exception.
-     */
-    void logDebug(final String message, final Throwable t);
-
-    /**
-     * Log a info message.
-     */
-    void logInfo(final String message);
-
-    /**
-     * Log a info message with exception.
-     */
-    void logInfo(final String message, final Throwable t);
-
-    /**
-     * Log a warning message.
-     */
-    void logWarn(final String message);
-
-    /**
-     * Log a warning message with exception.
-     */
-    void logWarn(final String message, final Throwable t);
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Tue Aug 10 13:37:59 2010
@@ -24,21 +24,20 @@ import java.util.TreeSet;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
 /** OsgiInstaller service implementation */
-public class OsgiInstallerImpl implements OsgiInstaller, OsgiInstallerContext {
+public class OsgiInstallerImpl implements OsgiInstaller, OsgiInstallerStatistics, OsgiInstallerContext {
 
     /** Interface of the package admin */
     private static String PACKAGE_ADMIN_NAME = PackageAdmin.class.getName();
-    /** Interface of the log service */
-    private static String LOG_SERVICE_NAME = LogService.class.getName();
+
     /** Interface of the config admin */
     private static String CONFIG_ADMIN_SERVICE_NAME = ConfigurationAdmin.class.getName();
 
@@ -55,8 +54,7 @@ public class OsgiInstallerImpl implement
 
     /** Tracker for the package admin. */
     private final ServiceTracker packageAdminTracker;
-    /** Tracker for the log service. */
-    private final ServiceTracker logServiceTracker;
+
     /** Tracker for the configuration admin. */
     private final ServiceTracker configAdminServiceTracker;
 
@@ -68,13 +66,11 @@ public class OsgiInstallerImpl implement
         this.bundleContext = bc;
         // create and start tracker
         this.packageAdminTracker = new ServiceTracker(bc, PACKAGE_ADMIN_NAME, null);
-        this.logServiceTracker = new ServiceTracker(bc, LOG_SERVICE_NAME, null);
         this.configAdminServiceTracker = new ServiceTracker(bc, CONFIG_ADMIN_SERVICE_NAME, null);
         this.packageAdminTracker.open();
-        this.logServiceTracker.open();
         this.configAdminServiceTracker.open();
 
-        bundleDigestsStorage = new PersistentBundleInfo(this, bc.getDataFile("bundle-digests.properties"));
+        bundleDigestsStorage = new PersistentBundleInfo(bc.getDataFile("bundle-digests.properties"));
 
         installerThread = new OsgiInstallerThread(this);
         installerThread.setDaemon(true);
@@ -88,16 +84,20 @@ public class OsgiInstallerImpl implement
         installerThread.deactivate();
 
         final TreeSet<String> installedBundlesSymbolicNames = new TreeSet<String>();
+        // do we really want to iterate here? Over all bundles? TODO
         for(Bundle b : bundleContext.getBundles()) {
-            installedBundlesSymbolicNames.add(b.getSymbolicName());
+            final String name = b.getSymbolicName();
+            if ( name != null ) {
+                installedBundlesSymbolicNames.add(b.getSymbolicName());
+            }
         }
         try {
             bundleDigestsStorage.purgeAndSave(installedBundlesSymbolicNames);
         } catch (IOException e) {
-            logWarn(OsgiInstaller.class.getName() + " service failed to save state.", e);
+            Logger.logWarn(OsgiInstaller.class.getName() + " service failed to save state.", e);
         }
 
-        this.logInfo("Waiting for installer thread to stop");
+        Logger.logInfo("Waiting for installer thread to stop");
         try {
             installerThread.join();
         } catch (InterruptedException e) {
@@ -105,11 +105,10 @@ public class OsgiInstallerImpl implement
         }
 
         this.packageAdminTracker.close();
-        this.logServiceTracker.close();
         this.configAdminServiceTracker.close();
 
-        this.logWarn(OsgiInstaller.class.getName()
-                    + " service deactivated - this warning can be ignored if system is shutting down");
+        Logger.logWarn(OsgiInstaller.class.getName()
+                + " service deactivated - this warning can be ignored if system is shutting down");
     }
 
 	/**
@@ -119,12 +118,18 @@ public class OsgiInstallerImpl implement
 	    return (ConfigurationAdmin)this.configAdminServiceTracker.getService();
 	}
 
+	/**
+	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#addTaskToCurrentCycle(org.apache.sling.osgi.installer.impl.OsgiInstallerTask)
+	 */
 	public void addTaskToCurrentCycle(OsgiInstallerTask t) {
 		installerThread.addTaskToCurrentCycle(t);
 	}
 
+	/**
+	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#addTaskToNextCycle(org.apache.sling.osgi.installer.impl.OsgiInstallerTask)
+	 */
 	public void addTaskToNextCycle(OsgiInstallerTask t) {
-		this.logDebug("adding task to next cycle:" + t);
+	    Logger.logDebug("adding task to next cycle:" + t);
 		installerThread.addTaskToNextCycle(t);
 	}
 
@@ -142,6 +147,9 @@ public class OsgiInstallerImpl implement
 		return (PackageAdmin)this.packageAdminTracker.getService();
 	}
 
+	/**
+	 * @see org.apache.sling.osgi.installer.OsgiInstallerStatistics#getCounters()
+	 */
 	public long [] getCounters() {
 		return counters;
 	}
@@ -167,16 +175,22 @@ public class OsgiInstallerImpl implement
         installerThread.removeResource(url);
 	}
 
+	/**
+	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#incrementCounter(int)
+	 */
 	public void incrementCounter(int index) {
 	    counters[index]++;
 	}
 
+    /**
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#setCounter(int, long)
+     */
     public void setCounter(int index, long value) {
         counters[index] = value;
     }
 
     /**
-     * Finds the bundle with given symbolic name in our BundleContext.
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#getMatchingBundle(java.lang.String)
      */
     public Bundle getMatchingBundle(String bundleSymbolicName) {
         if (bundleSymbolicName != null) {
@@ -190,10 +204,16 @@ public class OsgiInstallerImpl implement
         return null;
     }
 
+	/**
+	 * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#isSnapshot(org.osgi.framework.Version)
+	 */
 	public boolean isSnapshot(Version v) {
 		return v.toString().indexOf(MAVEN_SNAPSHOT_MARKER) >= 0;
 	}
 
+    /**
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#getInstalledBundleDigest(org.osgi.framework.Bundle)
+     */
     public String getInstalledBundleDigest(Bundle b) throws IOException {
         if(bundleDigestsStorage == null) {
             return null;
@@ -201,6 +221,9 @@ public class OsgiInstallerImpl implement
         return bundleDigestsStorage.getDigest(b.getSymbolicName());
     }
 
+    /**
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#getInstalledBundleVersion(java.lang.String)
+     */
     public String getInstalledBundleVersion(String symbolicName) throws IOException {
         if(bundleDigestsStorage == null) {
             return null;
@@ -208,64 +231,10 @@ public class OsgiInstallerImpl implement
         return bundleDigestsStorage.getInstalledVersion(symbolicName);
     }
 
-    public void saveInstalledBundleInfo(Bundle b, String digest, String version) throws IOException {
-        bundleDigestsStorage.putInfo(b.getSymbolicName(), digest, version);
-    }
-
     /**
-     * Internal method for logging.
-     * This method checks if the LogService is available and only then logs
+     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#saveInstalledBundleInfo(org.osgi.framework.Bundle, java.lang.String, java.lang.String)
      */
-    private void log(final int level, final String message, final Throwable t) {
-        final LogService ls = (LogService) this.logServiceTracker.getService();
-        if ( ls != null ) {
-            if ( t != null ) {
-                ls.log(level, message, t);
-            } else {
-                ls.log(level, message);
-            }
-        }
-    }
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logDebug(java.lang.String, java.lang.Throwable)
-     */
-    public void logDebug(String message, Throwable t) {
-        log(LogService.LOG_DEBUG, message, t);
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logDebug(java.lang.String)
-     */
-    public void logDebug(String message) {
-        log(LogService.LOG_DEBUG, message, null);
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logInfo(java.lang.String, java.lang.Throwable)
-     */
-    public void logInfo(String message, Throwable t) {
-        log(LogService.LOG_INFO, message, t);
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logInfo(java.lang.String)
-     */
-    public void logInfo(String message) {
-        log(LogService.LOG_INFO, message, null);
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logWarn(java.lang.String, java.lang.Throwable)
-     */
-    public void logWarn(String message, Throwable t) {
-        log(LogService.LOG_WARNING, message, t);
-    }
-
-    /**
-     * @see org.apache.sling.osgi.installer.impl.OsgiInstallerContext#logWarn(java.lang.String)
-     */
-    public void logWarn(String message) {
-        log(LogService.LOG_WARNING, message, null);
+    public void saveInstalledBundleInfo(Bundle b, String digest, String version) throws IOException {
+        bundleDigestsStorage.putInfo(b.getSymbolicName(), digest, version);
     }
-
 }
\ No newline at end of file

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java Tue Aug 10 13:37:59 2010
@@ -21,10 +21,11 @@ package org.apache.sling.osgi.installer.
 
 /** Base class for tasks that can be executed by the {@link OsgiInstallerImpl} */
 public abstract class OsgiInstallerTask implements Comparable<OsgiInstallerTask> {
+
     public abstract void execute(OsgiInstallerContext ctx) throws Exception;
 
-	protected void logExecution(OsgiInstallerContext ctx) {
-	    ctx.logInfo("OsgiInstallerTask: executing  " + this);
+	protected void logExecution() {
+	    Logger.logInfo("OsgiInstallerTask: executing  " + this);
 	}
 
 	/** Tasks are sorted according to this key */

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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -32,6 +32,7 @@ import java.util.TreeSet;
 
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
+import org.apache.sling.osgi.installer.OsgiInstallerStatistics;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
@@ -67,7 +68,7 @@ class OsgiInstallerThread extends Thread
         setName(getClass().getSimpleName());
         this.ctx = ctx;
         final File f = ctx.getBundleContext().getDataFile("RegisteredResourceList.ser");
-        persistentList = new PersistentResourceList(ctx,f);
+        persistentList = new PersistentResourceList(f);
         registeredResources = persistentList.getData();
     }
 
@@ -92,21 +93,21 @@ class OsgiInstallerThread extends Thread
             	    // No tasks to execute - wait until new resources are
             	    // registered
             	    cleanupInstallableResources();
-            	    ctx.logDebug("No tasks to process, going idle");
+            	    Logger.logDebug("No tasks to process, going idle");
 
-            	    ctx.setCounter(OsgiInstaller.WORKER_THREAD_IS_IDLE_COUNTER, 1);
-                    ctx.incrementCounter(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER);
+            	    ctx.setCounter(OsgiInstallerStatistics.WORKER_THREAD_IS_IDLE_COUNTER, 1);
+                    ctx.incrementCounter(OsgiInstallerStatistics.WORKER_THREAD_BECOMES_IDLE_COUNTER);
             	    synchronized (newResources) {
                         newResources.wait();
                     }
-            	    ctx.logDebug("Notified of new resources, back to work");
-                    ctx.setCounter(OsgiInstaller.WORKER_THREAD_IS_IDLE_COUNTER, 0);
+            	    Logger.logDebug("Notified of new resources, back to work");
+                    ctx.setCounter(OsgiInstallerStatistics.WORKER_THREAD_IS_IDLE_COUNTER, 0);
             	    continue;
             	}
 
             	retriesScheduled = false;
                 if(executeTasks() > 0) {
-                    ctx.logDebug("Tasks have been executed, saving persistentList");
+                    Logger.logDebug("Tasks have been executed, saving persistentList");
                     persistentList.save();
                 }
 
@@ -115,18 +116,18 @@ class OsgiInstallerThread extends Thread
                 Thread.sleep(250);
                 cleanupInstallableResources();
             } catch(Exception e) {
-                ctx.logWarn(e.toString(), e);
+                Logger.logWarn(e.toString(), e);
                 try {
                     Thread.sleep(1000);
                 } catch(InterruptedException ignored) {
                 }
             }
         }
-        ctx.logInfo("Deactivated, exiting");
+        Logger.logInfo("Deactivated, exiting");
     }
 
     void addTaskToCurrentCycle(OsgiInstallerTask t) {
-        ctx.logDebug("adding task to current cycle:" + t);
+        Logger.logDebug("adding task to current cycle:" + t);
         synchronized (tasks) {
             tasks.add(t);
         }
@@ -135,7 +136,7 @@ class OsgiInstallerThread extends Thread
     /** Register a resource for removal, or ignore if we don't have that URL */
     void removeResource(String url) {
 		// Will mark all resources which have r's URL as uninstallable
-		ctx.logDebug("Adding URL " + url + " to urlsToRemove");
+        Logger.logDebug("Adding URL " + url + " to urlsToRemove");
 
         synchronized (newResources) {
             urlsToRemove.add(url);
@@ -149,12 +150,12 @@ class OsgiInstallerThread extends Thread
         try {
             rr = new RegisteredResourceImpl(ctx, r);
         } catch(IOException ioe) {
-            ctx.logWarn("Cannot create RegisteredResource (resource will be ignored):" + r, ioe);
+            Logger.logWarn("Cannot create RegisteredResource (resource will be ignored):" + r, ioe);
             return;
         }
 
         synchronized (newResources) {
-            ctx.logDebug("Adding new resource " + r);
+            Logger.logDebug("Adding new resource " + r);
             newResources.add(rr);
             newResources.notify();
         }
@@ -171,7 +172,7 @@ class OsgiInstallerThread extends Thread
             try {
                 rr = new RegisteredResourceImpl(ctx, r);
             } catch(IOException ioe) {
-                ctx.logWarn("Cannot create RegisteredResource (resource will be ignored):" + r, ioe);
+                Logger.logWarn("Cannot create RegisteredResource (resource will be ignored):" + r, ioe);
                 continue;
             }
 
@@ -180,7 +181,7 @@ class OsgiInstallerThread extends Thread
                         "URL of all supplied InstallableResource must start with supplied scheme"
                         + ", scheme is not '" + urlScheme + "' for URL " + r.getUrl());
             }
-            ctx.logDebug("Adding new resource " + r);
+            Logger.logDebug("Adding new resource " + r);
             toAdd.add(rr);
         }
 
@@ -190,7 +191,7 @@ class OsgiInstallerThread extends Thread
             }
             // Need to manage schemes separately: in case toAdd is empty we
             // want to mark all such resources as non-installable
-            ctx.logDebug("Adding to newResourcesSchemes: " + urlScheme);
+            Logger.logDebug("Adding to newResourcesSchemes: " + urlScheme);
             newResourcesSchemes.add(urlScheme);
             newResources.notify();
         }
@@ -203,25 +204,25 @@ class OsgiInstallerThread extends Thread
             // all resources with the same scheme in newResources, and existing
             // registeredResources, as not installable
         	for(String scheme : newResourcesSchemes) {
-        	    ctx.logDebug("Processing set of new resources with scheme " + scheme);
+        	    Logger.logDebug("Processing set of new resources with scheme " + scheme);
                 for(RegisteredResource r : newResources) {
                     if(r.getUrlScheme().equals(scheme)) {
                         r.setInstallable(false);
-                        ctx.logDebug("New resource set to non-installable: " + r);
+                        Logger.logDebug("New resource set to non-installable: " + r);
                     }
                  }
                 for(SortedSet<RegisteredResource> ss : registeredResources.values()) {
                     for(RegisteredResource r : ss) {
                         if(r.getUrlScheme().equals(scheme)) {
                             r.setInstallable(false);
-                            ctx.logDebug("Existing resource set to non-installable: " + r);
+                            Logger.logDebug("Existing resource set to non-installable: " + r);
                         }
                     }
                 }
         	}
             for(SortedSet<RegisteredResource> s : newResourcesSets) {
                 newResources.addAll(s);
-                ctx.logDebug("Added set of " + s.size() + " new resources with scheme "
+                Logger.logDebug("Added set of " + s.size() + " new resources with scheme "
                             + s.first().getUrlScheme() + ": " + s);
             }
             newResourcesSets.clear();
@@ -239,7 +240,7 @@ class OsgiInstallerThread extends Thread
                 if(t.contains(r)) {
                 	for(RegisteredResource rr : t) {
                 		if(t.comparator().compare(rr, r) == 0) {
-                		    ctx.logDebug("Cleanup obsolete " + rr);
+                		    Logger.logDebug("Cleanup obsolete " + rr);
                 			rr.cleanup(ctx);
                 		}
                 	}
@@ -254,7 +255,7 @@ class OsgiInstallerThread extends Thread
                 for(SortedSet<RegisteredResource> group : registeredResources.values()) {
                 	for(RegisteredResource r : group) {
                 		if(urlsToRemove.contains(r.getUrl())) {
-                		    ctx.logDebug("Marking " + r + " uninistallable, URL is included in urlsToRemove");
+                		    Logger.logDebug("Marking " + r + " uninistallable, URL is included in urlsToRemove");
                 			r.setInstallable(false);
                 		}
                 	}
@@ -296,15 +297,14 @@ class OsgiInstallerThread extends Thread
         // TODO do nothing for a group that's "stable" - i.e. one where no tasks were
         // created in the last cycle??
         for(SortedSet<RegisteredResource> group : registeredResources.values()) {
-            if(group.isEmpty()) {
+            if (group.isEmpty()) {
                 continue;
             }
-            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;
+            final String rt = group.first().getResourceType();
+            if ( InstallableResource.TYPE_BUNDLE.equals(rt) ) {
+                bundleTaskCreator.createTasks(ctx, group, tasks);
+            } else if ( InstallableResource.TYPE_CONFIG.equals(rt) ) {
+                configTaskCreator.createTasks(ctx, group, tasks);
             }
         }
     }
@@ -322,7 +322,7 @@ class OsgiInstallerThread extends Thread
                 counter++;
             } catch(Exception e) {
             	if(!t.canRetry(ctx)) {
-            		ctx.logInfo("Task cannot be retried, removing from list:" + t);
+            	    Logger.logInfo("Task cannot be retried, removing from list:" + t);
                     removeTask(t);
             	}
             	throw e;
@@ -356,7 +356,7 @@ class OsgiInstallerThread extends Thread
             for(RegisteredResource r : toDelete) {
                 group.remove(r);
                 r.cleanup(ctx);
-                ctx.logDebug("Removing RegisteredResource from list, not installable and has been processed: " + r);
+                Logger.logDebug("Removing RegisteredResource from list, not installable and has been processed: " + r);
             }
             if(group.isEmpty() && key != null) {
                 groupKeysToRemove.add(key);
@@ -367,9 +367,9 @@ class OsgiInstallerThread extends Thread
             registeredResources.remove(key);
         }
 
-        ctx.setCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, resourceCount);
-        ctx.setCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, registeredResources.size());
-        ctx.incrementCounter(OsgiInstaller.INSTALLER_CYCLES_COUNTER);
+        ctx.setCounter(OsgiInstallerStatistics.REGISTERED_RESOURCES_COUNTER, resourceCount);
+        ctx.setCounter(OsgiInstallerStatistics.REGISTERED_GROUPS_COUNTER, registeredResources.size());
+        ctx.incrementCounter(OsgiInstallerStatistics.INSTALLER_CYCLES_COUNTER);
 
         // List of resources might have changed
         persistentList.save();
@@ -379,7 +379,7 @@ class OsgiInstallerThread extends Thread
     private void scheduleRetries() {
     	final int toRetry = tasksForNextCycle.size();
     	if(toRetry > 0) {
-    	    ctx.logDebug(toRetry + " tasks scheduled for retrying");
+    	    Logger.logDebug(toRetry + " tasks scheduled for retrying");
             synchronized (newResources) {
                 newResources.notify();
                 retriesScheduled = true;
@@ -390,7 +390,7 @@ class OsgiInstallerThread extends Thread
     public void bundleChanged(BundleEvent e) {
     	final int t = e.getType();
     	if(t == BundleEvent.INSTALLED || t == BundleEvent.RESOLVED || t == BundleEvent.STARTED || t == BundleEvent.UPDATED) {
-    	    ctx.logDebug("Received BundleEvent that might allow installed bundles to start, scheduling retries if any");
+    	    Logger.logDebug("Received BundleEvent that might allow installed bundles to start, scheduling retries if any");
     		scheduleRetries();
     	}
     }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java Tue Aug 10 13:37:59 2010
@@ -37,23 +37,22 @@ class PersistentBundleInfo {
 
     private Properties digests = new Properties();
     private final File dataFile;
-    private final OsgiInstallerContext ctx;
+   // private final OsgiInstallerContext ctx;
     private static final String VERSION_PREFIX = "V:";
 
     /**
      * Load the list from supplied file, which is also
      * used by purgeAndSave to save our data.
      */
-    PersistentBundleInfo(OsgiInstallerContext ctx, File dataFile) {
-        this.ctx = ctx;
+    PersistentBundleInfo(final File dataFile) {
         this.dataFile = dataFile;
         InputStream is = null;
         try {
             is = new FileInputStream(dataFile);
             digests.load(is);
-            ctx.logInfo("Digests restored from data file " + dataFile.getName());
+            Logger.logInfo("Digests restored from data file " + dataFile.getName());
         } catch(IOException ioe) {
-            ctx.logInfo("No digests retrieved, cannot read properties file " + dataFile.getName());
+            Logger.logInfo("No digests retrieved, cannot read properties file " + dataFile.getName());
         } finally {
             if (is != null) {
                 try {is.close(); } catch (final IOException ignore) {}
@@ -88,7 +87,7 @@ class PersistentBundleInfo {
                 try {os.close(); } catch (final IOException ignore) {}
             }
         }
-        ctx.logInfo("Stored digests of " + digests.size() + " bundles in data file " + dataFile.getName());
+        Logger.logInfo("Stored digests of " + digests.size() + " bundles in data file " + dataFile.getName());
     }
 
     /**

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java?rev=983998&r1=983997&r2=983998&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java (original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentResourceList.java Tue Aug 10 13:37:59 2010
@@ -35,7 +35,7 @@ class PersistentResourceList {
     private final File dataFile;
 
     @SuppressWarnings("unchecked")
-    PersistentResourceList(OsgiInstallerContext ctx, File dataFile) {
+    PersistentResourceList(final File dataFile) {
         this.dataFile = dataFile;
 
         ObjectInputStream ois = null;
@@ -44,7 +44,7 @@ class PersistentResourceList {
             ois = new ObjectInputStream(new FileInputStream(dataFile));
             restoredData = (HashMap<String, SortedSet<RegisteredResource>>)ois.readObject();
         } catch(Exception e) {
-            ctx.logInfo("Unable to restore data, starting with empty list (" + e.toString());
+            Logger.logInfo("Unable to restore data, starting with empty list (" + e.toString());
         } finally {
             if(ois != null) {
                 try {

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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -23,7 +23,6 @@ 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.
@@ -46,7 +45,7 @@ public interface RegisteredResource {
 	String getUrl();
 	boolean isInstallable();
 	void setInstallable(boolean installable);
-	InstallableResource.Type getResourceType();
+	String getResourceType();
 	String getUrlScheme();
 	int getPriority();
 	long getSerialNumber();

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=983998&r1=983997&r2=983998&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 Tue Aug 10 13:37:59 2010
@@ -35,8 +35,8 @@ class RegisteredResourceComparator imple
     private static final long serialVersionUID = 1L;
 
     public int compare(RegisteredResource a, RegisteredResource b) {
-    	final boolean aBundle = a.getResourceType() == InstallableResource.Type.BUNDLE;
-    	final boolean bBundle = b.getResourceType() == InstallableResource.Type.BUNDLE;
+    	final boolean aBundle = a.getResourceType().equals(InstallableResource.TYPE_BUNDLE);
+    	final boolean bBundle = b.getResourceType().equals(InstallableResource.TYPE_BUNDLE);
 
         if(aBundle && bBundle) {
             return compareBundles(a, b);



Mime
View raw message