import org.argeo.slc.core.structure.tree.TreeSPath;
import org.argeo.slc.core.structure.tree.TreeSRegistry;
import org.argeo.slc.logging.Log4jUtils;
-import org.argeo.slc.runtime.SlcExecutionContext;
import org.argeo.slc.runtime.SlcExecutionOutput;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
private final static Log log = LogFactory.getLog(AntSlcApplication.class);
private Resource contextLocation;
- private ApplicationContext parentContext;
+ private ConfigurableApplicationContext parentContext;
private Resource rootDir;
private Resource confDir;
// Ant project initialization
Project project = new Project();
AntExecutionContext executionContext = new AntExecutionContext(project);
- project.addReference(SlcAntConstants.REF_ROOT_CONTEXT, ctx);
- project.addReference(SlcAntConstants.REF_SLC_EXECUTION, slcExecution);
+ project.addReference(AntConstants.REF_ROOT_CONTEXT, ctx);
+ project.addReference(AntConstants.REF_SLC_EXECUTION, slcExecution);
initProject(project, properties, references);
parseProject(project, scriptRelativePath);
}
}
- if (System.getProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
- System.setProperty(SlcAntConstants.DEFAULT_TEST_RUN_PROPERTY,
+ if (System.getProperty(AntConstants.DEFAULT_TEST_RUN_PROPERTY) == null) {
+ System.setProperty(AntConstants.DEFAULT_TEST_RUN_PROPERTY,
"defaultTestRun");
}
try {
if (rootDir != null)
- System.setProperty(SlcAntConstants.ROOT_DIR_PROPERTY, rootDir
+ System.setProperty(AntConstants.ROOT_DIR_PROPERTY, rootDir
.getURL().toString());
if (confDir != null)
- System.setProperty(SlcAntConstants.CONF_DIR_PROPERTY, confDir
+ System.setProperty(AntConstants.CONF_DIR_PROPERTY, confDir
.getURL().toString());
if (workDir != null)
- System.setProperty(SlcAntConstants.WORK_DIR_PROPERTY, workDir
+ System.setProperty(AntConstants.WORK_DIR_PROPERTY, workDir
.getCanonicalPath());
// Additional properties in slc.properties file. Already set sytem
}
}
} catch (Exception e) {
- throw new SlcAntException("Cannot init system properties.", e);
+ throw new SlcException("Cannot init system properties.", e);
}
}
// Find runtime definition
Resource runtimeRes = null;
String runtimeStr = slcExecution.getAttributes().get(
- SlcAntConstants.EXECATTR_RUNTIME);
+ AntConstants.EXECATTR_RUNTIME);
if (runtimeStr == null)
runtimeStr = "default";
ctx.refresh();
return ctx;
} catch (Exception e) {
- throw new SlcAntException(
+ throw new SlcException(
"Cannot create SLC execution application context.", e);
}
}
protected String findAntScript(SlcExecution slcExecution) {
String scriptStr = slcExecution.getAttributes().get(
- SlcAntConstants.EXECATTR_ANT_FILE);
+ AntConstants.EXECATTR_ANT_FILE);
if (scriptStr == null)
- throw new SlcAntException("No Ant script provided");
+ throw new SlcException("No Ant script provided");
return scriptStr;
}
protected List<String> findAntTargets(SlcExecution slcExecution) {
String targetList = slcExecution.getAttributes().get(
- SlcAntConstants.EXECATTR_ANT_TARGETS);
+ AntConstants.EXECATTR_ANT_TARGETS);
List<String> targets = new Vector<String>();
if (targetList != null) {
StringTokenizer stTargets = new StringTokenizer(targetList, ",");
project.addBuildListener(new CommonsLoggingListener());
ListableBeanFactory context = (ListableBeanFactory) project
- .getReference(SlcAntConstants.REF_ROOT_CONTEXT);
+ .getReference(AntConstants.REF_ROOT_CONTEXT);
// Register build listeners
Map<String, BuildListener> listeners = context.getBeansOfType(
BuildListener.class, false, true);
}
// Register log4j appenders from context
- MDC.put(SlcAntConstants.MDC_ANT_PROJECT, project);
+ MDC.put(AntConstants.MDC_ANT_PROJECT, project);
Map<String, Appender> appenders = context.getBeansOfType(
Appender.class, false, true);
for (Appender appender : appenders.values()) {
/** Loads the SLC specific Ant tasks. */
protected void addCustomTaskAndTypes(Project project) {
Properties taskdefs = getDefs(project,
- SlcAntConstants.SLC_TASKDEFS_RESOURCE_PATH);
+ AntConstants.SLC_TASKDEFS_RESOURCE_PATH);
for (Object o : taskdefs.keySet()) {
String name = o.toString();
try {
}
}
Properties typedefs = getDefs(project,
- SlcAntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
+ AntConstants.SLC_TYPEDEFS_RESOURCE_PATH);
for (Object o : typedefs.keySet()) {
String name = o.toString();
try {
defs.load(in);
in.close();
} catch (IOException e) {
- throw new SlcAntException("Cannot load task definitions", e);
+ throw new SlcException("Cannot load task definitions", e);
}
return defs;
}
protected void initStructure(Project project, String scriptRelativePath) {
// Init structure registry
StructureRegistry<TreeSPath> registry = new TreeSRegistry();
- project.addReference(SlcAntConstants.REF_STRUCTURE_REGISTRY, registry);
+ project.addReference(AntConstants.REF_STRUCTURE_REGISTRY, registry);
// Lowest levels
StringTokenizer st = new StringTokenizer(scriptRelativePath, "/");
.getDescription() : projectPath.getName();
registry.register(projectPath, new SimpleSElement(projectDesc));
- project.addReference(SlcAntConstants.REF_PROJECT_PATH, projectPath);
+ project.addReference(AntConstants.REF_PROJECT_PATH, projectPath);
if (log.isDebugEnabled())
log.debug("Project path: " + projectPath);
projectHelper);
projectHelper.parse(project, script.getURL());
} catch (Exception e) {
- throw new SlcAntException("Could not parse project for script "
+ throw new SlcException("Could not parse project for script "
+ scriptRelativePath, e);
}
}
} catch (Throwable e) {
exception = e;
- throw new SlcAntException("SLC Ant execution failed", exception);
+ throw new SlcException("SLC Ant execution failed", exception);
} finally {
p.fireBuildFinished(exception);
}
this.workDir = workDir;
}
- public void setParentContext(ApplicationContext runtimeContext) {
+ public void setParentContext(ConfigurableApplicationContext runtimeContext) {
this.parentContext = runtimeContext;
}