Recognize explicit locations
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 1 Dec 2015 15:59:17 +0000 (15:59 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 1 Dec 2015 15:59:17 +0000 (15:59 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8668 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.osgi.boot/ext/test/org/argeo/osgi/boot/OsgiBootNoRuntimeTest.java
org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java

index 2a4d2195a2c022b18c1d1a6dd5d04ccb8a5d36a6..6a8ac168341954d2fbcc9e7a6d92d00971cb5935 100644 (file)
  */
 package org.argeo.osgi.boot;
 
-import java.io.File;
 import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.argeo.osgi.boot.OsgiBoot;
-
 /** Tests which do not require a runtime. */
 @SuppressWarnings("rawtypes")
 public class OsgiBootNoRuntimeTest extends TestCase {
@@ -29,18 +26,18 @@ public class OsgiBootNoRuntimeTest extends TestCase {
                        + "src/test/bundles/others;in=**/org.argeo.*";
 
        /** Tests that location lists are properly parsed. */
-       public void testLocations() {
-               String baseUrl = "file:";
-               String locations = "/mydir/myfile" + File.pathSeparator
-                               + "/myotherdir/myotherfile";
-
-               OsgiBoot osgiBoot = new OsgiBoot(null);
-               osgiBoot.setExcludeSvn(true);
-               List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
-               assertEquals(2, urls.size());
-               assertEquals("file:/mydir/myfile", urls.get(0));
-               assertEquals("file:/myotherdir/myotherfile", urls.get(1));
-       }
+       // public void testLocations() {
+       // String baseUrl = "file:";
+       // String locations = "/mydir/myfile" + File.pathSeparator
+       // + "/myotherdir/myotherfile";
+       //
+       // OsgiBoot osgiBoot = new OsgiBoot(null);
+       // osgiBoot.setExcludeSvn(true);
+       // List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
+       // assertEquals(2, urls.size());
+       // assertEquals("file:/mydir/myfile", urls.get(0));
+       // assertEquals("file:/myotherdir/myotherfile", urls.get(1));
+       // }
 
        /** Tests that bundle lists are properly parsed. */
        public void testBundles() {
index aa120b1f2ba82ac9e237960ae29e4771f6b481d6..a397e374768c84d2052384a580ad2922af05ba59 100644 (file)
@@ -67,7 +67,8 @@ public class OsgiBoot {
        // "argeo.osgi.boot.installInLexicographicOrder";
 
        public final static String PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT = "argeo.osgi.boot.defaultTimeout";
-//     public final static String PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR = "argeo.osgi.boot.modulesUrlSeparator";
+       // public final static String PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR =
+       // "argeo.osgi.boot.modulesUrlSeparator";
        public final static String PROP_ARGEO_OSGI_BOOT_SYSTEM_PROPERTIES_FILE = "argeo.osgi.boot.systemPropertiesFile";
        public final static String PROP_ARGEO_OSGI_BOOT_APPCLASS = "argeo.osgi.boot.appclass";
        public final static String PROP_ARGEO_OSGI_BOOT_APPARGS = "argeo.osgi.boot.appargs";
@@ -96,7 +97,7 @@ public class OsgiBoot {
        private long defaultTimeout;
 
        /** Default is ',' (set in constructor) */
-//     private String modulesUrlSeparator = ",";
+       // private String modulesUrlSeparator = ",";
 
        private final BundleContext bundleContext;
 
@@ -108,8 +109,8 @@ public class OsgiBoot {
                this.bundleContext = bundleContext;
                defaultTimeout = Long.parseLong(OsgiBootUtils.getProperty(
                                PROP_ARGEO_OSGI_BOOT_DEFAULT_TIMEOUT, "10000"));
-//             modulesUrlSeparator = OsgiBootUtils.getProperty(
-//                             PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR, ",");
+               // modulesUrlSeparator = OsgiBootUtils.getProperty(
+               // PROP_ARGEO_OSGI_BOOT_MODULES_URL_SEPARATOR, ",");
                initSystemProperties();
        }
 
@@ -539,23 +540,23 @@ public class OsgiBoot {
         * Gets a list of URLs based on explicit locations, resolving placeholder
         * ${...} containing system properties, e.g. ${user.home}.
         */
-       public List<String> getLocationsUrls(String baseUrl, String bundleLocations) {
-               List<String> urls = new ArrayList<String>();
-
-               if (bundleLocations == null)
-                       return urls;
-               bundleLocations = SystemPropertyUtils
-                               .resolvePlaceholders(bundleLocations);
-               // if (debug)
-               // debug(PROP_ARGEO_OSGI_LOCATIONS + "=" + bundleLocations);
-
-               StringTokenizer st = new StringTokenizer(bundleLocations,
-                               File.pathSeparator);
-               while (st.hasMoreTokens()) {
-                       urls.add(locationToUrl(baseUrl, st.nextToken().trim()));
-               }
-               return urls;
-       }
+//     public List<String> getLocationsUrls(String baseUrl, String bundleLocations) {
+//             List<String> urls = new ArrayList<String>();
+//
+//             if (bundleLocations == null)
+//                     return urls;
+//             bundleLocations = SystemPropertyUtils
+//                             .resolvePlaceholders(bundleLocations);
+//             // if (debug)
+//             // debug(PROP_ARGEO_OSGI_LOCATIONS + "=" + bundleLocations);
+//
+//             StringTokenizer st = new StringTokenizer(bundleLocations,
+//                             File.pathSeparator);
+//             while (st.hasMoreTokens()) {
+//                     urls.add(locationToUrl(baseUrl, st.nextToken().trim()));
+//             }
+//             return urls;
+//     }
 
        /*
         * BUNDLE PATTERNS INSTALLATION
@@ -599,7 +600,12 @@ public class OsgiBoot {
                StringTokenizer st = new StringTokenizer(bundlePatterns, ",");
                List<BundlesSet> bundlesSets = new ArrayList<BundlesSet>();
                while (st.hasMoreTokens()) {
-                       bundlesSets.add(new BundlesSet(st.nextToken()));
+                       String token = st.nextToken();
+                       if (new File(token).exists()) {
+                               String url = locationToUrl(baseUrl, token);
+                               urls.add(url);
+                       } else
+                               bundlesSets.add(new BundlesSet(token));
                }
 
                // find included
@@ -901,9 +907,9 @@ public class OsgiBoot {
                this.defaultTimeout = defaultTimeout;
        }
 
-//     public void setModulesUrlSeparator(String modulesUrlSeparator) {
-//             this.modulesUrlSeparator = modulesUrlSeparator;
-//     }
+       // public void setModulesUrlSeparator(String modulesUrlSeparator) {
+       // this.modulesUrlSeparator = modulesUrlSeparator;
+       // }
 
        public boolean isExcludeSvn() {
                return excludeSvn;