+ /*
+ * MODULES LIST INSTALLATION (${argeo.osgi.modulesUrl})
+ */
+ /**
+ * Downloads a list of URLs in CSV format from ${argeo.osgi.modulesUrl}:<br>
+ * <code>Bundle-SymbolicName,Bundle-Version,url</code>)<br>
+ * 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.
+ */
+ public List getModulesUrls() {
+ List urls = new ArrayList();
+ String modulesUrlStr = OsgiBootUtils
+ .getProperty(PROP_ARGEO_OSGI_MODULES_URL);
+ if (modulesUrlStr == null)
+ return urls;
+
+ String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL);
+
+ Map installedBundles = getBundlesBySymbolicName();
+
+ BufferedReader reader = null;
+ try {
+ URL modulesUrl = new URL(modulesUrlStr);
+ reader = new BufferedReader(new InputStreamReader(
+ modulesUrl.openStream()));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ StringTokenizer st = new StringTokenizer(line,
+ modulesUrlSeparator);
+ String moduleName = st.nextToken();
+ String moduleVersion = st.nextToken();
+ String url = st.nextToken();
+ if (baseUrl != null)
+ url = baseUrl + url;
+
+ if (installedBundles.containsKey(moduleName)) {
+ Bundle bundle = (Bundle) installedBundles.get(moduleName);
+ String bundleVersion = bundle.getHeaders()
+ .get(Constants.BUNDLE_VERSION).toString();
+ int comp = OsgiBootUtils.compareVersions(bundleVersion,
+ moduleVersion);
+ if (comp > 0) {
+ OsgiBootUtils.warn("Installed version " + bundleVersion
+ + " of bundle " + moduleName
+ + " is newer than provided version "
+ + moduleVersion);
+ } else if (comp < 0) {
+ urls.add(url);
+ OsgiBootUtils.info("Updated bundle " + moduleName
+ + " with version " + moduleVersion
+ + " (old version was " + bundleVersion + ")");
+ } else {
+ // do nothing
+ }
+ } else {
+ urls.add(url);
+ }
+ }
+ } catch (Exception e1) {
+ throw new RuntimeException("Cannot read url " + modulesUrlStr, e1);
+ } finally {
+ if (reader != null)
+ try {
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return urls;
+ }
+
+ /*
+ * HIGH LEVEL UTILITIES
+ */
+ /** Actually performs the matching logic. */