You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2012/01/13 08:19:22 UTC
svn commit: r1230908 - in
/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl:
EntityResourceList.java OsgiInstallerImpl.java PersistentResourceList.java
Author: cziegeler
Date: Fri Jan 13 07:19:21 2012
New Revision: 1230908
URL: http://svn.apache.org/viewvc?rev=1230908&view=rev
Log:
SLING-2362 : Artifact is not downgraded
Modified:
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java?rev=1230908&r1=1230907&r2=1230908&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java (original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/EntityResourceList.java Fri Jan 13 07:19:21 2012
@@ -327,9 +327,10 @@ public class EntityResourceList implemen
/**
* Compact the resource group by removing uninstalled entries
+ * @return <code>true</code> if another cycle should be started.
*/
public boolean compact() {
- boolean changed = false;
+ boolean startNewCycle = false;
final List<TaskResource> toDelete = new ArrayList<TaskResource>();
boolean first = true;
for(final TaskResource r : resources) {
@@ -339,11 +340,13 @@ public class EntityResourceList implemen
first = false;
}
for(final RegisteredResource r : toDelete) {
- changed = true;
resources.remove(r);
+ if ( !this.isEmpty() ) {
+ startNewCycle = true;
+ }
this.cleanup(r);
LOGGER.debug("Removing uninstalled from list: {}", r);
}
- return changed;
+ return startNewCycle;
}
}
Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java?rev=1230908&r1=1230907&r2=1230908&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java (original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/OsgiInstallerImpl.java Fri Jan 13 07:19:21 2012
@@ -211,7 +211,8 @@ public class OsgiInstallerImpl
synchronized ( this.resourcesLock ) {
this.retryDuringTaskExecution = false;
}
- if ( this.executeTasks(tasks) ) {
+ final ACTION action = this.executeTasks(tasks);
+ if ( action == ACTION.SLEEP ) {
synchronized ( this.resourcesLock ) {
// before we go to sleep, check if new resources arrived in the meantime
if ( !this.hasNewResources() && this.active && !this.retryDuringTaskExecution) {
@@ -228,7 +229,7 @@ public class OsgiInstallerImpl
}
}
}
- } else {
+ } else if ( action == ACTION.SHUTDOWN ) {
// stop processing
this.active = false;
}
@@ -575,10 +576,16 @@ public class OsgiInstallerImpl
return result;
}
+ private enum ACTION {
+ SLEEP,
+ SHUTDOWN,
+ CYCLE
+ };
+
/**
* Execute all tasks
*/
- private boolean executeTasks(final SortedSet<InstallTask> tasks) {
+ private ACTION executeTasks(final SortedSet<InstallTask> tasks) {
if ( !tasks.isEmpty() ) {
final List<InstallTask> asyncTasks = new ArrayList<InstallTask>();
@@ -623,7 +630,7 @@ public class OsgiInstallerImpl
}
}
// save new state
- this.cleanupInstallableResources();
+ final boolean newCycle = this.cleanupInstallableResources();
// let's check if we have async tasks and no other tasks
if ( this.active && !asyncTasks.isEmpty() ) {
@@ -642,20 +649,25 @@ public class OsgiInstallerImpl
}
};
t.start();
- return false;
+ return ACTION.SHUTDOWN;
+ }
+ if ( newCycle ) {
+ return ACTION.CYCLE;
}
}
- return true;
+ return ACTION.SLEEP;
}
/**
- * Clean up and compact
+ * Clean up and compact.
+ * @return <code>true</code> if another cycle should be started.
*/
- private void cleanupInstallableResources() {
- this.persistentList.compact();
+ private boolean cleanupInstallableResources() {
+ final boolean result = this.persistentList.compact();
this.persistentList.save();
printResources("Compacted");
+ return result;
}
/**
Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java?rev=1230908&r1=1230907&r2=1230908&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java (original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/PersistentResourceList.java Fri Jan 13 07:19:21 2012
@@ -270,20 +270,20 @@ public class PersistentResourceList {
/**
* Compact the internal state and remove empty groups.
+ * @return <code>true</code> if another cycle should be started.
*/
public boolean compact() {
- boolean changed = false;
+ boolean startNewCycle = false;
final Iterator<Map.Entry<String, EntityResourceList>> i = this.data.entrySet().iterator();
while ( i.hasNext() ) {
final Map.Entry<String, EntityResourceList> entry = i.next();
- changed |= entry.getValue().compact();
+ startNewCycle |= entry.getValue().compact();
if ( entry.getValue().isEmpty() ) {
- changed = true;
i.remove();
}
}
- return changed;
+ return startNewCycle;
}
/**