]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - base/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBoot.java
Disable OSGi boot debug
[lgpl/argeo-commons.git] / base / runtime / org.argeo.osgi.boot / src / main / java / org / argeo / osgi / boot / OsgiBoot.java
index 6b51038718bb28e35cd14b830c56ded2669e1506..465ba96812921b84ad9b97afedecc99612decfec 100644 (file)
@@ -58,8 +58,9 @@ public class OsgiBoot {
        public final static String PROP_ARGEO_OSGI_BUNDLES = "argeo.osgi.bundles";
        public final static String PROP_ARGEO_OSGI_LOCATIONS = "argeo.osgi.locations";
        public final static String PROP_ARGEO_OSGI_BASE_URL = "argeo.osgi.baseUrl";
-       /** Use org.argeo.osgi */
+       /** @deprecated */
        public final static String PROP_ARGEO_OSGI_MODULES_URL = "argeo.osgi.modulesUrl";
+       public final static String PROP_ARGEO_OSGI_DISTRIBUTION_URL = "argeo.osgi.distributionUrl";
 
        // booleans
        public final static String PROP_ARGEO_OSGI_BOOT_DEBUG = "argeo.osgi.boot.debug";
@@ -159,6 +160,7 @@ public class OsgiBoot {
                installUrls(getBundlesUrls());
                installUrls(getLocationsUrls());
                installUrls(getModulesUrls());
+               installUrls(getDistributionUrls());
                checkUnresolved();
                startBundles();
                long duration = System.currentTimeMillis() - begin;
@@ -189,6 +191,14 @@ public class OsgiBoot {
        /*
         * INSTALLATION
         */
+       /** Install a single url. Convenience method. */
+       public Bundle installUrl(String url) {
+               List urls = new ArrayList();
+               urls.add(url);
+               installUrls(urls);
+               return (Bundle) getBundlesByLocation().get(url);
+       }
+
        /** Install the bundles at this URL list. */
        public void installUrls(List urls) {
                Map installedBundles = getBundlesByLocation();
@@ -496,15 +506,23 @@ public class OsgiBoot {
         * effects.
         */
        public List getBundlesUrls() {
-               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL,
-                               DEFAULT_BASE_URL);
                String bundlePatterns = OsgiBootUtils
                                .getProperty(PROP_ARGEO_OSGI_BUNDLES);
+               return getBundlesUrls(bundlePatterns);
+       }
+
+       /**
+        * Compute alist of URLs to install based on the provided patterns, with
+        * default base url
+        */
+       public List getBundlesUrls(String bundlePatterns) {
+               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL,
+                               DEFAULT_BASE_URL);
                return getBundlesUrls(baseUrl, bundlePatterns);
        }
 
        /** Implements the path matching logic */
-       public List getBundlesUrls(String baseUrl, String bundlePatterns) {
+       List getBundlesUrls(String baseUrl, String bundlePatterns) {
                List urls = new ArrayList();
                if (bundlePatterns == null)
                        return urls;
@@ -552,6 +570,34 @@ public class OsgiBoot {
                return urls;
        }
 
+       /*
+        * DISTRIBUTION JAR INSTALLATION
+        */
+       public List getDistributionUrls() {
+               List urls = new ArrayList();
+               String distributionUrl = OsgiBootUtils
+                               .getProperty(PROP_ARGEO_OSGI_DISTRIBUTION_URL);
+               if (distributionUrl == null)
+                       return urls;
+               String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL);
+
+               DistributionBundle distributionBundle;
+               if (baseUrl != null
+                               && !(distributionUrl.startsWith("http") || distributionUrl
+                                               .startsWith("file"))) {
+                       // relative url
+                       distributionBundle = new DistributionBundle(baseUrl,
+                                       distributionUrl);
+               } else {
+                       distributionBundle = new DistributionBundle(distributionUrl);
+                       if (baseUrl != null)
+                               distributionBundle.setBaseUrl(baseUrl);
+
+               }
+               distributionBundle.processUrl();
+               return distributionBundle.listUrls();
+       }
+
        /*
         * MODULES LIST INSTALLATION (${argeo.osgi.modulesUrl})
         */
@@ -561,6 +607,8 @@ public class OsgiBoot {
         * If ${argeo.osgi.baseUrl} is set, URLs will be considered relative paths
         * and be concatenated with the base URL, typically the root of a Maven
         * repository.
+        * 
+        * @deprecated
         */
        public List getModulesUrls() {
                List urls = new ArrayList();