- script = slcRuntime.getRuntimeContext().getResource(scriptStr);
- if (log.isTraceEnabled())
- log.trace("script(absolute)=" + script);
- if (script.exists())
- return script;
-
- script = new FileSystemResource(scriptStr);
- if (log.isTraceEnabled())
- log.trace("script(fs)=" + script);
- if (script.exists())
- return script;
+ /**
+ * 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 {
+
+ // Find runtime definition
+ Resource runtimeRes = null;
+ String runtimeStr = slcExecution.getAttributes().get(
+ AntConstants.EXECATTR_RUNTIME);
+ if (runtimeStr == null)
+ runtimeStr = System.getProperty(AntConstants.RUNTIME_PROPERTY,
+ "default");
+
+ ResourceLoader rl = new DefaultResourceLoader(getClass()
+ .getClassLoader());
+ try {// tries absolute reference
+ runtimeRes = rl.getResource(runtimeStr);
+ } catch (Exception e) {
+ // silent
+ }
+ if (runtimeRes == null || !runtimeRes.exists()) {
+ if (confDir != null)
+ runtimeRes = confDir.createRelative("runtime/" + runtimeStr
+ + ".xml");
+ }
+
+ // Find runtime independent application context definition
+ if (confDir != null && contextLocation == null) {
+ contextLocation = confDir
+ .createRelative("applicationContext.xml");
+ }