Node init can manage relative directories (relative to execution directory)
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 15 Oct 2015 13:42:31 +0000 (13:42 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 15 Oct 2015 13:42:31 +0000 (13:42 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8490 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.cms/src/org/argeo/cms/internal/kernel/Kernel.java
org.argeo.cms/src/org/argeo/cms/internal/kernel/KernelUtils.java

index 871163fc0f57df925446cc9c2a163e79cf1568b8..1002304007ff3e64d42a86834a8de8a64fa95f6a 100644 (file)
@@ -173,8 +173,14 @@ final class Kernel implements KernelHeader, KernelConstants, ServiceListener {
 
        private void firstInit() {
                log.info("## FIRST INIT ##");
-               File initDir = new File(getFrameworkProp(NODE_INIT,
-                               KernelUtils.getOsgiInstancePath("../../../init")));
+               String nodeInit = getFrameworkProp(NODE_INIT);
+               if (nodeInit == null)
+                       nodeInit = "../../init";
+               File initDir;
+               if (nodeInit.startsWith("."))
+                       initDir = KernelUtils.getExecutionDir(nodeInit);
+               else
+                       initDir = new File(nodeInit);
                // TODO also uncompress archives
                if (initDir.exists())
                        try {
index 28eb526952934937e075fe19fec6e4242c7eceb4..1d15e2a3ae041911c95f963e69042c6833877416 100644 (file)
@@ -43,6 +43,17 @@ class KernelUtils implements KernelConstants {
                return asDictionary(props);
        }
 
+       static File getExecutionDir(String relativePath) {
+               File executionDir = new File(getFrameworkProp("user.dir"));
+               if (relativePath == null)
+                       return executionDir;
+               try {
+                       return new File(executionDir, relativePath).getCanonicalFile();
+               } catch (IOException e) {
+                       throw new CmsException("Cannot get canonical file", e);
+               }
+       }
+
        static File getOsgiInstanceDir() {
                return new File(Activator.getBundleContext()
                                .getProperty(OSGI_INSTANCE_AREA).substring("file:".length()))