- protected void initRuntimeContext(SlcExecution slcExecution) {
- if (runtimeContext == null) {
- Resource runtimeRes = null;
- String runtimeStr = slcExecution.getAttributes().get(
- SlcAntConstants.EXECATTR_RUNTIME);
- if (runtimeStr != null) {
- try {
- ResourceLoader rl = new DefaultResourceLoader(getClass()
- .getClassLoader());
- try {
- runtimeRes = rl.getResource(runtimeStr);
- } catch (Exception e) {
- // silent
- }
- if (runtimeRes == null || !runtimeRes.exists()) {
- runtimeRes = confDir.createRelative("runtime/"
- + runtimeStr + ".xml");
- }
-
- if (runtimeRes.exists()) {
- GenericApplicationContext ctx = new GenericApplicationContext();
- XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
- ctx);
- xmlReader.loadBeanDefinitions(runtimeRes);
-
- // Add property place holder
- PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
- ppc.setIgnoreUnresolvablePlaceholders(true);
- ctx.addBeanFactoryPostProcessor(ppc);
-
- ctx.refresh();
-
- runtimeContext = ctx;
- }
- } catch (Exception e) {
- throw new SlcException(
- "Could not initialize runtime context from "
- + runtimeStr, e);
- }
- }
-
- if (runtimeContext == null)
- log.warn("No runtime is defined.");
+ /**
+ * 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();