import org.apache.tools.ant.Project;\r
import org.apache.tools.ant.helper.ProjectHelperImpl;\r
\r
+import org.argeo.slc.core.structure.StructurePath;\r
+import org.argeo.slc.core.structure.tree.TreeSElement;\r
+import org.argeo.slc.core.structure.tree.TreeSPath;\r
+import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
+\r
public class SlcProjectHelper extends ProjectHelperImpl {\r
public static String PROP_APPLICATION_CONTEXT = "org.argeo.slc.slcRootContext";\r
public static String REF_ROOT_CONTEXT = "slcApplicationContext";\r
+ public static String REF_STRUCTURE_REGISTRY = "slcStructureRegistry";\r
\r
@Override\r
public void parse(Project project, Object source) throws BuildException {\r
stdOut("Entered SLC project helper");\r
\r
+ // init Spring application context\r
+ String acPath = System.getProperty(PROP_APPLICATION_CONTEXT,\r
+ "applicationContext.xml");\r
+ ApplicationContext context = new FileSystemXmlApplicationContext(acPath);\r
+ project.addReference(REF_ROOT_CONTEXT, context);\r
+\r
+ // init structure register\r
+ TreeSRegistry registry = new TreeSRegistry();\r
+ project.addReference(REF_STRUCTURE_REGISTRY, registry);\r
+\r
// call the underlying implementation to do the actual work\r
super.parse(project, source);\r
\r
- String acPath = System.getProperty(PROP_APPLICATION_CONTEXT);\r
- if (acPath == null) {\r
- acPath = "applicationContext.xml";\r
- }\r
- ApplicationContext context = new FileSystemXmlApplicationContext(acPath);\r
- project.addReference(REF_ROOT_CONTEXT, context);\r
+ String projectDescription = project.getDescription() != null ? project\r
+ .getDescription() : "Root";\r
+ TreeSElement element = TreeSElement.createRootElelment(\r
+ getProjectPathName(project), projectDescription);\r
+ registry.register(element);\r
}\r
\r
private static void stdOut(Object o) {\r
System.out.println(o);\r
}\r
\r
+ static TreeSPath getProjectPath(Project project) {\r
+ return TreeSPath.createChild(null, getProjectPathName(project));\r
+ }\r
+\r
+ private static String getProjectPathName(Project project) {\r
+ String projectName = project.getName() != null ? project.getName()\r
+ : "project";\r
+ return projectName;\r
+ }\r
}\r