incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r792140 - in /sling/trunk/contrib/extensions/jcrinstall/osgi: ./ src/main/java/org/apache/sling/osgi/installer/impl/ src/main/java/org/apache/sling/osgi/installer/impl/tasks/ src/test/java/org/apache/sling/osgi/installer/impl/
Date Wed, 08 Jul 2009 13:52:45 GMT
Author: bdelacretaz
Date: Wed Jul  8 13:52:44 2009
New Revision: 792140

URL: http://svn.apache.org/viewvc?rev=792140&view=rev
Log:
SLING-904 - remove dependency on org.slf4j logging

Modified:
    sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
    sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml (original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml Wed Jul  8 13:52:44 2009
@@ -74,10 +74,6 @@
       <artifactId>org.osgi.compendium</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.testing</artifactId>
       <version>2.0.4-incubator</version>

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java
Wed Jul  8 13:52:44 2009
@@ -78,7 +78,7 @@
         this.bundleContext = bc;
         this.packageAdmin = pa;
         this.logServiceTracker = logServiceTracker;
-        storage = new Storage(bc.getDataFile(STORAGE_FILENAME));
+        storage = new Storage(bc.getDataFile(STORAGE_FILENAME), this);
     }
 
     public void deactivate() {

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java
Wed Jul  8 13:52:44 2009
@@ -30,8 +30,8 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.osgi.service.log.LogService;
 
 /** Storage for the OSGi controller, stores Maps for the resources
  *  managed by the controller.
@@ -39,8 +39,7 @@
 public class Storage {
     private final File dataFile;
     private final Map<String, Map<String, Object>> data;
-    
-    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    private final OsgiControllerServices ocs;
     
     /** {@link Storage} key for the bundle ID */
     public static final String KEY_BUNDLE_ID = "bundle.id";
@@ -48,8 +47,9 @@
     /** Create Storage that uses dataFile for persistence, and
      *  read the current status from that file */
     @SuppressWarnings("unchecked")
-    Storage(File dataFile) throws IOException {
+    Storage(File dataFile, OsgiControllerServices ocs) throws IOException {
         this.dataFile = dataFile;
+        this.ocs = ocs;
         ObjectInputStream ois = null;
         Map<String, Map<String, Object>> loadedData = null;
         Throwable loadException = null;
@@ -59,7 +59,9 @@
                 ois = new ObjectInputStream(new FileInputStream(dataFile));
                 loadedData = (Map<String, Map<String, Object>>)ois.readObject();
             } else {
-                log.debug("Data file does not exist, will use empty data");
+            	if(ocs.getLogService() != null) {
+            		ocs.getLogService().log(LogService.LOG_DEBUG, "Data file does not exist, will
use empty data");
+            	}
             }
         } catch(EOFException eof) {
             loadException = eof;
@@ -72,7 +74,10 @@
         }
         
         if(loadException != null) {
-            log.debug("Unable to retrieve data from data file, will use empty data", loadException);
+        	if(ocs.getLogService() != null) {
+        		ocs.getLogService().log(LogService.LOG_DEBUG,
+        				"Unable to retrieve data from data file, will use empty data", loadException);
+        	}
         }
         if(loadedData == null) {
             loadedData = new HashMap<String, Map<String, Object>>();

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
Wed Jul  8 13:52:44 2009
@@ -40,14 +40,12 @@
 public class BundleInstallRemoveTask extends InstallRemoveTask {
 
 	private final BundleContext bundleContext;
-	private final OsgiControllerServices ocs;
 	
     public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT";
 
     public BundleInstallRemoveTask(String uri, InstallableData data, BundleContext ctx, OsgiControllerServices
ocs) {
-    	super(uri, data);
+    	super(uri, data, ocs);
     	this.bundleContext = ctx;
-    	this.ocs = ocs;
     }
     
 	@Override

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java
Wed Jul  8 13:52:44 2009
@@ -40,11 +40,9 @@
     static final String CONFIG_EXTENSION = ".cfg";
     
     private final DictionaryReader reader = new DictionaryReader();
-    private final OsgiControllerServices ocs;
     
 	public ConfigInstallRemoveTask(String uri, InstallableData data, OsgiControllerServices
ocs) {
-		super(uri, data);
-		this.ocs = ocs;
+		super(uri, data, ocs);
 	}
 	
 	@Override

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java
Wed Jul  8 13:52:44 2009
@@ -24,12 +24,12 @@
 
 import org.apache.sling.osgi.installer.InstallResultCode;
 import org.apache.sling.osgi.installer.InstallableData;
+import org.apache.sling.osgi.installer.OsgiControllerServices;
 import org.apache.sling.osgi.installer.impl.InstallableDataWrapper;
 import org.apache.sling.osgi.installer.impl.OsgiControllerImpl;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTask;
 import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.osgi.service.log.LogService;
 
 /** Base class for OsgiControllerTasks that install or
  * 	remove OSGi bundles or configs (or deployment packages, etc.)
@@ -38,12 +38,12 @@
 
 	protected final String uri;
 	protected final InstallableData data;
+	protected final OsgiControllerServices ocs;
 
-    private final Logger log = LoggerFactory.getLogger(getClass());
-    
-    protected InstallRemoveTask(String uri, InstallableData data) {
+    protected InstallRemoveTask(String uri, InstallableData data, OsgiControllerServices
ocs) {
     	this.uri = uri;
     	this.data = data;
+    	this.ocs = ocs;
     }
     
 	@Override
@@ -82,8 +82,10 @@
         if(context.getResourceOverrideRules() != null) {
             for(String r : context.getResourceOverrideRules().getHigherPriorityResources(uri))
{
                 if(context.getStorage().contains(r)) {
-                    log.info("Resource {} ignored, overridden by {} which has higher priority",
-                            uri, r);
+                	if(ocs.getLogService() != null) {
+                		ocs.getLogService().log(LogService.LOG_INFO, 
+                				"Resource " + uri + " ignored, overridden by " + r + " which has higher
priority");
+                	}
                     return;
                 }
             }
@@ -93,8 +95,10 @@
         if(context.getResourceOverrideRules() != null) {
             for(String r : context.getResourceOverrideRules().getLowerPriorityResources(uri))
{
                 if(context.getStorage().contains(r)) {
-                    log.info("Resource {} overrides {}, uninstalling the latter",
-                            uri, r);
+                	if(ocs.getLogService() != null) {
+                		ocs.getLogService().log(LogService.LOG_INFO, 
+                				"Resource " + uri + " overrides " + r + ", uninstalling the latter");
+                	}
                     executeUninstall(context);
                 }
             }
@@ -109,13 +113,14 @@
 	}
 	
 	protected final void executeUninstall(OsgiControllerTaskContext context) throws Exception
{
-	    log.info("Execute uninstall " + this);
         // If a corresponding higher priority resource is installed, ignore this request
         if(context.getResourceOverrideRules() != null) {
             for(String r : context.getResourceOverrideRules().getHigherPriorityResources(uri))
{
                 if(context.getStorage().contains(r)) {
-                    log.info("Resource {} won't be uninstalled, overridden by {} which has
higher priority",
-                            uri, r);
+                	if(ocs.getLogService() != null) {
+                		ocs.getLogService().log(LogService.LOG_INFO,
+                				"Resource " + uri + " won't be uninstalled, overridden by " + r + " which
has higher priority");
+                	}
                     return;
                 }
             }

Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java?rev=792140&r1=792139&r2=792140&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
(original)
+++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java
Wed Jul  8 13:52:44 2009
@@ -21,13 +21,28 @@
 import java.io.File;
 import java.util.Map;
 
+import org.apache.sling.osgi.installer.OsgiControllerServices;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
+
 import static org.junit.Assert.*;
 
 /** Test the Storage class */
 public class StorageTest {
 
+	private final OsgiControllerServices ocs = new OsgiControllerServices() {
+		
+		public LogService getLogService() {
+			return null;
+		}
+		
+		public ConfigurationAdmin getConfigurationAdmin() {
+			return null;
+		}
+	};
+	
     @org.junit.Test public void testEmptyDataFile() throws Exception {
-        final Storage s = new Storage(Utilities.getTestFile());
+        final Storage s = new Storage(Utilities.getTestFile(), ocs);
         assertEquals("Storage is initially empty", 0, s.getKeys().size());
     }
     
@@ -39,13 +54,13 @@
         f.delete();
         
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             s.getMap("one").put("two", "twodata");
             s.saveToFile();
         }
         
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             assertTrue("Retrieved Map contains 'two'", s.getMap("one").containsKey("two"));
         }
     }
@@ -56,7 +71,7 @@
         final String [] keys = { "one", "two" };
         
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             
             for(String key : keys) {
                 final Map<String, Object> m = s.getMap(key);
@@ -67,7 +82,7 @@
         }
         
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             assertEquals("After retrieving, number of keys in storage matches", keys.length,
s.getKeys().size());
             for(String key : keys) {
                 final Map<String, Object> m = s.getMap(key);
@@ -81,7 +96,7 @@
     }
     
     @org.junit.Test public void testContains() throws Exception {
-        final Storage s = new Storage(Utilities.getTestFile());
+        final Storage s = new Storage(Utilities.getTestFile(), ocs);
         final String uri = "TEST_URI";
         assertFalse("Storage must initially be empty", s.contains(uri));
         s.contains(uri);
@@ -93,7 +108,7 @@
     @org.junit.Test public void testRemove() throws Exception {
         final File f = Utilities.getTestFile();
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             s.getMap("one");
             assertEquals("After adding one entry, size is 1", 1, s.getKeys().size());
             s.remove("one");
@@ -102,7 +117,7 @@
         }
         
         {
-            final Storage s = new Storage(f);
+            final Storage s = new Storage(f, ocs);
             assertEquals("After save/restore, size is 0", 0, s.getKeys().size());
         }
     }



Mime
View raw message