Author: cziegeler
Date: Thu Feb 9 20:07:43 2012
New Revision: 1242500
URL: http://svn.apache.org/viewvc?rev=1242500&view=rev
Log:
SLING-2405 : Startup synchronization problems
Modified:
sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
Modified:
sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
URL:
http://svn.apache.org/viewvc/sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java?rev=1242500&r1=1242499&r2=1242500&view=diff
==============================================================================
---
sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
(original)
+++
sling/trunk/launchpad/installer/src/main/java/org/apache/sling/launchpad/installer/impl/LaunchpadConfigInstaller.java
Thu Feb 9 20:07:43 2012
@@ -20,9 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Comparator;
import java.util.Dictionary;
import java.util.HashSet;
import java.util.Hashtable;
@@ -76,6 +74,7 @@ public class LaunchpadConfigInstaller {
path = path.substring(0, path.length() - 1);
}
if ( !checkPath(resourceProvider, installables, path,
resourceType) ) {
+ logger.info("Launchpad {} will be installed: {}",
resourceType, path);
final URL url = resourceProvider.getResource(path);
Dictionary<String, Object> dict = null;
if ( InstallableResource.TYPE_FILE.equals(resourceType) ) {
@@ -121,46 +120,7 @@ public class LaunchpadConfigInstaller {
checkPath(resourceProvider, installables, ROOT_INSTALL_PATH,
InstallableResource.TYPE_FILE);
final InstallableResource [] toInstall = installables.toArray(new
InstallableResource []{});
- // sort by url to have lower start levels first
- Arrays.sort(toInstall, new ResourceComparator());
- for(final InstallableResource rsrc : toInstall ) {
- logger.info("Launchpad {} will be installed: {}", rsrc.getType(),
rsrc.getId());
- }
installer.registerResources("launchpad", (toInstall));
logger.info("{} resources registered with OsgiInstaller",
toInstall.length);
}
-
- /**
- * Resource comparator
- */
- private static final class ResourceComparator implements
Comparator<InstallableResource> {
-
- private Integer getStartLevel(final InstallableResource ir) {
- try {
- final Integer level =
Integer.valueOf((String)ir.getDictionary().get(InstallableResource.INSTALLATION_HINT));
- if ( level == 0 ) {
- return 100;
- }
- return level;
- } catch ( final NumberFormatException ignore) {
- return 1000;
- }
- }
-
- /**
- * @see java.util.Comparator#compare(java.lang.Object,
java.lang.Object)
- */
- public int compare(final InstallableResource o1,
- final InstallableResource o2) {
- int result = o2.getType().compareTo(o1.getType());
- if ( result == 0 ) {
- if ( o1.getType() == InstallableResource.TYPE_PROPERTIES ) {
- result = o1.getId().compareTo(o2.getId());
- } else {
- result = getStartLevel(o1).compareTo(getStartLevel(o2));
- }
- }
- return result;
- }
- }
}
\ No newline at end of file