Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. --- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/EquinoxUtils.java
  2. +++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/EquinoxUtils.java
  3. @@ -8,6 +8,7 @@
  4.   ******************************************************************************/
  5.  package org.eclipse.equinox.internal.simpleconfigurator.utils;
  6.  
  7. +import java.io.File;
  8.  import java.net.*;
  9.  import org.eclipse.equinox.internal.simpleconfigurator.console.ConfiguratorCommandProvider;
  10.  import org.eclipse.osgi.framework.console.CommandProvider;
  11. @@ -24,10 +25,20 @@ public class EquinoxUtils {
  12.  
  13.                 URL baseURL = configLocation.getURL();
  14.                 if (configLocation.getParentLocation() != null && configLocation.getURL() != null) {
  15. -                       if (baseURL == null)
  16. +                       if (baseURL == null) {
  17.                                 return new URL[] {configLocation.getParentLocation().getURL()};
  18. -                       else
  19. -                               return new URL[] {baseURL, configLocation.getParentLocation().getURL()};
  20. +                       } else {
  21. +                               File scatteredBundlesInfos = getScatteredBundleInfos();
  22. +                               if (scatteredBundlesInfos == null) {
  23. +                                       return new URL[] {baseURL, configLocation.getParentLocation().getURL()};
  24. +                               } else {
  25. +                                       try {
  26. +                                               return new URL[] {baseURL, configLocation.getParentLocation().getURL(), scatteredBundlesInfos.toURL()};
  27. +                                       } catch (MalformedURLException e) {
  28. +                                               return new URL[] {baseURL, configLocation.getParentLocation().getURL()};
  29. +                                       }
  30. +                               }
  31. +                       }
  32.                 }
  33.                 if (baseURL != null)
  34.                         return new URL[] {baseURL};
  35. @@ -35,6 +46,17 @@ public class EquinoxUtils {
  36.                 return null;
  37.         }
  38.  
  39. +       private static File getScatteredBundleInfos() {
  40. +               String scatteredBundlesInfoLocation = System.getProperty("org.eclipse.p2.bundlesinfofolder");
  41. +               if (scatteredBundlesInfoLocation == null)
  42. +                       return null;
  43. +               File f = new File(scatteredBundlesInfoLocation);
  44. +               //various *.info folders will be located in that directory
  45. +               if (f.exists() && f.isDirectory())
  46. +                       return f;
  47. +               return null;
  48. +       }
  49. +
  50.         public static Location getConfigLocation(BundleContext context) {
  51.                 Filter filter = null;
  52.                 try {
  53. diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java b/bundles/org.eclipse
  54. index aa0235a..69981f7 100644
  55. --- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
  56. +++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
  57. @@ -27,6 +27,24 @@ public class SimpleConfiguratorUtils {
  58.         private static final String ENCODED_COMMA = "%2C";
  59.  
  60.         public static List readConfiguration(URL url, URI base) throws IOException {
  61. +               File f = new File(url.getFile());
  62. +               if (f.isFile()) {
  63. +                       return readConfigurationFromFile(url, base);
  64. +               } else {
  65. +                       ArrayList result = new ArrayList();
  66. +                       File[] listFiles = f.listFiles();
  67. +                       for (File file : listFiles) {
  68. +                               if (file.getName().endsWith(".info")) {
  69. +                                       System.out.println("Reading configuration from file " + file.getName());
  70. +                                       List list = readConfiguration(file.toURL(), base);
  71. +                                       result.addAll(list);
  72. +                               }
  73. +                       }
  74. +                       return result;
  75. +               }
  76. +       }
  77. +
  78. +       private static List readConfigurationFromFile(URL url, URI base) throws IOException {
  79.                 InputStream stream = null;
  80.                 try {
  81.                         stream = url.openStream();