X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fruntime%2FKernelUtils.java;h=fe9e3581cf8811eb54d4b5ff71ab57ff008dd935;hb=58ec99a5ae0a63167bf378d98751a8066271758d;hp=6e47873b35557f772ac7d702433652bdb342a3fa;hpb=27a964084a298e6423b9a19b88a665360fb0b567;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java index 6e47873b3..fe9e3581c 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java @@ -12,9 +12,7 @@ import java.util.Dictionary; import java.util.Hashtable; import java.util.Properties; import java.util.TreeMap; -import java.util.TreeSet; -import org.argeo.api.cms.CmsLog; import org.argeo.cms.internal.osgi.CmsActivator; /** Package utilities */ @@ -22,6 +20,8 @@ class KernelUtils implements KernelConstants { final static String OSGI_INSTANCE_AREA = "osgi.instance.area"; final static String OSGI_CONFIGURATION_AREA = "osgi.configuration.area"; + final static String OSGI_FRAMEWORK_UUID = "org.osgi.framework.uuid"; + static void setJaasConfiguration(URL jaasConfigurationUrl) { try { URIParameter uriParameter = new URIParameter(jaasConfigurationUrl.toURI()); @@ -65,6 +65,13 @@ class KernelUtils implements KernelConstants { return Paths.get(uri); } + public static Path getOsgiConfigurationPath(String relativePath) { + URI uri = getOsgiConfigurationUri(relativePath); + if (uri == null) // no data area available + return null; + return Paths.get(uri); + } + public static URI getOsgiInstanceUri(String relativePath) { String osgiInstanceBaseUri = getFrameworkProp(OSGI_INSTANCE_AREA); if (osgiInstanceBaseUri == null) // no data area available @@ -75,12 +82,21 @@ class KernelUtils implements KernelConstants { return safeUri(osgiInstanceBaseUri + (relativePath != null ? relativePath : "")); } + public static URI getOsgiConfigurationUri(String relativePath) { + String osgiInstanceBaseUri = getFrameworkProp(OSGI_CONFIGURATION_AREA); + if (osgiInstanceBaseUri == null) // no data area available + return null; + + if (!osgiInstanceBaseUri.endsWith("/")) + osgiInstanceBaseUri = osgiInstanceBaseUri + "/"; + return safeUri(osgiInstanceBaseUri + (relativePath != null ? relativePath : "")); + } + static String getFrameworkProp(String key, String def) { String value; - if (CmsActivator.getBundleContext() != null) - value = CmsActivator.getBundleContext().getProperty(key); - else - value = System.getProperty(key); + value = CmsActivator.getFrameworkProperty(key); +// if (value == null) +// value = System.getProperty(key); if (value == null) return def; return value; @@ -90,11 +106,11 @@ class KernelUtils implements KernelConstants { return getFrameworkProp(key, null); } - static void logFrameworkProperties(CmsLog log) { - for (Object sysProp : new TreeSet(System.getProperties().keySet())) { - log.debug(sysProp + "=" + getFrameworkProp(sysProp.toString())); - } - } +// static void logFrameworkProperties(CmsLog log) { +// for (Object sysProp : new TreeSet(System.getProperties().keySet())) { +// log.debug(sysProp + "=" + getFrameworkProp(sysProp.toString())); +// } +// } static void printSystemProperties(PrintStream out) { TreeMap display = new TreeMap<>(); @@ -121,6 +137,7 @@ class KernelUtils implements KernelConstants { if (uri == null) throw new IllegalArgumentException("URI cannot be null"); try { + // FIXME does not work if URI contains illegal characters (such as spaces, etc.) return new URI(uri); } catch (URISyntaxException e) { throw new IllegalArgumentException("Badly formatted URI " + uri, e);