X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.osgi.boot%2Fsrc%2Forg%2Fargeo%2Fosgi%2Fboot%2FOsgiBoot.java;h=bd49d99d47dcd8f465bb8f4f4d70268da7e5a289;hb=ebd927da42511bb5959000c50a39974c6cfa5f49;hp=2d24cc8811d0be7a2fb3520f082bfca562f15c63;hpb=eda7dc80fe41eff1e621f9c90b90d9e73b84a2c3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java index 2d24cc881..bd49d99d4 100644 --- a/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java +++ b/org.argeo.osgi.boot/src/org/argeo/osgi/boot/OsgiBoot.java @@ -232,15 +232,19 @@ public class OsgiBoot implements OsgiBootConstants { * START */ public void startBundles() { + startBundles(System.getProperties()); + } + + public void startBundles(Properties properties) { FrameworkStartLevel frameworkStartLevel = bundleContext.getBundle(0).adapt(FrameworkStartLevel.class); // default and active start levels from System properties Integer defaultStartLevel = new Integer( - Integer.parseInt(OsgiBootUtils.getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL, "4"))); - Integer activeStartLevel = new Integer(OsgiBootUtils.getProperty(PROP_OSGI_STARTLEVEL, "6")); + Integer.parseInt(getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL, "4"))); + Integer activeStartLevel = new Integer(getProperty(PROP_OSGI_STARTLEVEL, "6")); SortedMap> startLevels = new TreeMap>(); - computeStartLevels(startLevels, System.getProperties(), defaultStartLevel); + computeStartLevels(startLevels, properties, defaultStartLevel); // inverts the map for the time being, TODO optimise Map bundleStartLevels = new HashMap<>(); for (Integer level : startLevels.keySet()) { @@ -445,7 +449,7 @@ public class OsgiBoot implements OsgiBootConstants { * effects. */ public List getBundlesUrls() { - String bundlePatterns = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BUNDLES); + String bundlePatterns = getProperty(PROP_ARGEO_OSGI_BUNDLES); return getBundlesUrls(bundlePatterns); } @@ -454,7 +458,7 @@ public class OsgiBoot implements OsgiBootConstants { * default base url */ public List getBundlesUrls(String bundlePatterns) { - String baseUrl = OsgiBootUtils.getProperty(PROP_ARGEO_OSGI_BASE_URL, DEFAULT_BASE_URL); + String baseUrl = getProperty(PROP_ARGEO_OSGI_BASE_URL, DEFAULT_BASE_URL); return getBundlesUrls(baseUrl, bundlePatterns); } @@ -514,11 +518,15 @@ public class OsgiBoot implements OsgiBootConstants { * DISTRIBUTION JAR INSTALLATION */ public List getDistributionUrls() { + String distributionUrl = getProperty(PROP_ARGEO_OSGI_DISTRIBUTION_URL); + String baseUrl = getProperty(PROP_ARGEO_OSGI_BASE_URL); + return getDistributionUrls(distributionUrl, baseUrl); + } + + public List getDistributionUrls(String distributionUrl, String baseUrl) { 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"))) { @@ -646,6 +654,33 @@ public class OsgiBoot implements OsgiBootConstants { // return url; // } + /** + * Gets a property value + * + * @return null when defaultValue is "" + */ + public String getProperty(String name, String defaultValue) { + String value = bundleContext.getProperty(name); + if (value == null) + return defaultValue; // may be null + else + return value; + +// if (defaultValue != null) +// value = System.getProperty(name, defaultValue); +// else +// value = System.getProperty(name); +// +// if (value == null || value.equals("")) +// return null; +// else +// return value; + } + + public String getProperty(String name) { + return getProperty(name, null); + } + /* * BEAN METHODS */