incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1125283 - /sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
Date Fri, 20 May 2011 08:53:03 GMT
Author: cziegeler
Date: Fri May 20 08:53:03 2011
New Revision: 1125283

URL: http://svn.apache.org/viewvc?rev=1125283&view=rev
Log:
Only invoke installer if really something changed

Modified:
    sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java

Modified: sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java?rev=1125283&r1=1125282&r2=1125283&view=diff
==============================================================================
--- sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
(original)
+++ sling/trunk/installer/providers/jcr/src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrInstaller.java
Fri May 20 08:53:03 2011
@@ -482,7 +482,7 @@ public class JcrInstaller implements Eve
 
             // Rescan WatchedFolders if needed
             final boolean scanWf = WatchedFolder.getRescanTimer().expired();
-            if(scanWf) {
+            if (scanWf) {
                 session.refresh(false);
                 didRefresh = true;
                 for(WatchedFolder wf : watchedFolders) {
@@ -492,16 +492,25 @@ public class JcrInstaller implements Eve
                     WatchedFolder.getRescanTimer().reset();
                     counters[SCAN_FOLDERS_COUNTER]++;
                     final WatchedFolder.ScanResult sr = wf.scan();
-                    logger.info("Registering resource with OSGi installer: {}",sr.toAdd);
-                    logger.info("Removing resource from OSGi installer: {}", sr.toRemove);
-                    installer.updateResources(URL_SCHEME, sr.toAdd.toArray(new InstallableResource[sr.toAdd.size()]),
+                    boolean toDo = false;
+                    if ( sr.toAdd.size() > 0 ) {
+                        logger.info("Registering resource with OSGi installer: {}",sr.toAdd);
+                        toDo = true;
+                    }
+                    if ( sr.toRemove.size() > 0 ) {
+                        logger.info("Removing resource from OSGi installer: {}", sr.toRemove);
+                        toDo = true;
+                    }
+                    if ( toDo ) {
+                        installer.updateResources(URL_SCHEME, sr.toAdd.toArray(new InstallableResource[sr.toAdd.size()]),
                             sr.toRemove.toArray(new String[sr.toRemove.size()]));
+                    }
                 }
             }
 
             // Update list of WatchedFolder if we got any relevant events,
             // or if there were any WatchedFolder events
-            if(scanWf || updateFoldersListTimer.expired()) {
+            if (scanWf || updateFoldersListTimer.expired()) {
                 if (!didRefresh) {
                     session.refresh(false);
                     didRefresh = true;
@@ -509,14 +518,17 @@ public class JcrInstaller implements Eve
                 updateFoldersListTimer.reset();
                 counters[UPDATE_FOLDERS_LIST_COUNTER]++;
                 final List<String> toRemove = updateFoldersList();
-                logger.info("Removing resource from OSGi installer (folder deleted): {}",
toRemove);
-                installer.updateResources(URL_SCHEME, null,
-                        toRemove.toArray(new String[toRemove.size()]));
+                if ( toRemove.size() > 0 ) {
+                    logger.info("Removing resource from OSGi installer (folder deleted):
{}", toRemove);
+                    installer.updateResources(URL_SCHEME, null,
+                            toRemove.toArray(new String[toRemove.size()]));
+                }
             }
 
             try {
                 Thread.sleep(RUN_LOOP_DELAY_MSEC);
             } catch(InterruptedException ignore) {
+                // ignore
             }
 
         } catch(Exception e) {



Mime
View raw message