X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.osgiboot%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fosgiboot%2FActivator.java;h=6d5a6ed02ee3d4317384a98d9f7c772477f57b92;hb=56f9a29fc3d208bb1a0e9476b9d67dc372098e70;hp=56bcff5a6f242d231c0069e2a4358592dad69063;hpb=a9c8741503194937709bdef6b5a7a1a89afcf938;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Activator.java b/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Activator.java index 56bcff5a6..6d5a6ed02 100644 --- a/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Activator.java +++ b/runtime/org.argeo.slc.osgiboot/src/main/java/org/argeo/slc/osgiboot/Activator.java @@ -24,20 +24,23 @@ public class Activator implements BundleActivator { public final static String PROP_SLC_OSGI_DEV_BASES = "slc.osgi.devBases"; public final static String PROP_SLC_OSGI_DEV_PATTERNS = "slc.osgi.devPatterns"; public final static String PROP_SLC_OSGI_LOCATIONS = "slc.osgi.locations"; + public final static String PROP_SLC_OSGI_BASE_URL = "slc.osgi.baseUrl"; public final static String PROP_SLC_MAVEN_DEPENDENCY_FILE = "slc.maven.dependencyFile"; + public final static String PROP_SLC_OSGIBOOT_DEBUG = "slc.osgiboot.debug"; - private static Boolean debug = false; + private static Boolean debug = Boolean.parseBoolean(System.getProperty( + PROP_SLC_OSGIBOOT_DEBUG, "false")); public void start(BundleContext bundleContext) throws Exception { try { info("SLC OSGi bootstrap starting..."); - installUrls(bundleContext, getDevLocationsUrls()); + // installUrls(bundleContext, getDevLocationsUrls()); installUrls(bundleContext, getLocationsUrls()); + installUrls(bundleContext, getBundlesUrls()); - List urls = getMavenUrls(); - installUrls(bundleContext, urls); + installUrls(bundleContext, getMavenUrls()); startBundles(bundleContext); @@ -56,13 +59,11 @@ public class Activator implements BundleActivator { Map installedBundles = getInstalledBundles(bundleContext); for (String url : urls) { try { - if (installedBundles.containsKey(url)) { Bundle bundle = installedBundles.get(url); // bundle.update(); - if (debug) - debug("Bundle " + bundle.getSymbolicName() - + " already installed from " + url); + info("Bundle " + bundle.getSymbolicName() + + " already installed from " + url); } else { Bundle bundle = bundleContext.installBundle(url); if (debug) @@ -80,6 +81,7 @@ public class Activator implements BundleActivator { protected List getLocationsUrls() { List urlsProvided = new ArrayList(); + String baseUrl = getProperty(PROP_SLC_OSGI_BASE_URL, "reference:file:"); String bundlesList = getProperty(PROP_SLC_OSGI_LOCATIONS); if (bundlesList == null) return urlsProvided; @@ -88,7 +90,7 @@ public class Activator implements BundleActivator { StringTokenizer st = new StringTokenizer(bundlesList, File.pathSeparator); while (st.hasMoreTokens()) { - urlsProvided.add("reference:file:" + st.nextToken().trim()); + urlsProvided.add(baseUrl + st.nextToken().trim()); } return urlsProvided; } @@ -236,7 +238,7 @@ public class Activator implements BundleActivator { } for (File file : files) - match(matcher, matched, base, file.getName(), pattern); + match(matcher, matched, base, file.getName(), pattern); } else { String fullPath = base + '/' + currentPath; if (matched.contains(fullPath)) @@ -327,14 +329,18 @@ public class Activator implements BundleActivator { } } + /** Key is location */ protected static Map getInstalledBundles( BundleContext bundleContext) { Map installedBundles = new HashMap(); - for (Bundle bundle : bundleContext.getBundles()) + + for (Bundle bundle : bundleContext.getBundles()) { installedBundles.put(bundle.getLocation(), bundle); + } return installedBundles; } + /** Key is symbolic name */ protected static Map getBundles(BundleContext bundleContext) { Map installedBundles = new HashMap(); for (Bundle bundle : bundleContext.getBundles()) @@ -368,14 +374,23 @@ public class Activator implements BundleActivator { return component; } - protected String getProperty(String name) { - String value = System.getProperty(name); + protected static String getProperty(String name, String defaultValue) { + final String value; + if (defaultValue != null) + value = System.getProperty(name, defaultValue); + else + value = System.getProperty(name); + if (value == null || value.equals("")) return null; else return value; } + protected static String getProperty(String name) { + return getProperty(name, null); + } + private static void info(Object obj) { System.out.println("# INFO " + obj); } @@ -386,7 +401,11 @@ public class Activator implements BundleActivator { } private static void warn(Object obj) { - System.err.println("# WARN " + obj); + System.out.println("# WARN " + obj); + // if (System.getProperty("os.name").contains("Windows")) + // System.out.println("# WARN " + obj); + // else + // System.err.println("# WARN " + obj); } static class MavenFile {