]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java
Revert to Java 5 compatibility
[gpl/argeo-slc.git] / org.argeo.slc.agent / src / main / java / org / argeo / slc / ant / AntSlcApplication.java
index b6c98ebbc3e44f6c571783fd190c05a0c8ce0872..37bdff0dce8f93f352dd6dbfaf4e8e5fb1306998 100644 (file)
@@ -112,11 +112,9 @@ public class AntSlcApplication {
 
                try {
                        if (rootDir != null)
-                               System.setProperty(AntConstants.ROOT_DIR_PROPERTY, rootDir
-                                               .getURL().toString());
+                               setSystemPropertyForRes(AntConstants.ROOT_DIR_PROPERTY, rootDir);
                        if (confDir != null)
-                               System.setProperty(AntConstants.CONF_DIR_PROPERTY, confDir
-                                               .getURL().toString());
+                               setSystemPropertyForRes(AntConstants.CONF_DIR_PROPERTY, confDir);
                        if (workDir != null)
                                System.setProperty(AntConstants.WORK_DIR_PROPERTY, workDir
                                                .getCanonicalPath());
@@ -136,7 +134,8 @@ public class AntSlcApplication {
                                                IOUtils.closeQuietly(in);
                                        }
 
-                                       for (String key : slcProperties.stringPropertyNames()) {
+                                       for (Object obj : slcProperties.keySet()) {
+                                               String key = obj.toString();
                                                if (!System.getProperties().containsKey(key)) {
                                                        String value = SystemPropertyUtils
                                                                        .resolvePlaceholders(slcProperties
@@ -151,6 +150,21 @@ public class AntSlcApplication {
                }
        }
 
+       /**
+        * Set property as an absolute file path if the resource can be located on
+        * the file system, or as an url.
+        */
+       private void setSystemPropertyForRes(String key, Resource res)
+                       throws IOException {
+               String value = null;
+               try {
+                       value = res.getFile().getCanonicalPath();
+               } catch (IOException e) {
+                       value = res.getURL().toString();
+               }
+               System.setProperty(key, value);
+       }
+
        protected ConfigurableApplicationContext createExecutionContext(
                        SlcExecution slcExecution) {
                try {
@@ -160,7 +174,8 @@ public class AntSlcApplication {
                        String runtimeStr = slcExecution.getAttributes().get(
                                        AntConstants.EXECATTR_RUNTIME);
                        if (runtimeStr == null)
-                               runtimeStr = "default";
+                               runtimeStr = System.getProperty(AntConstants.RUNTIME_PROPERTY,
+                                               "default");
 
                        ResourceLoader rl = new DefaultResourceLoader(getClass()
                                        .getClassLoader());