]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Introduce SLC Main command line
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 12 Jun 2008 20:02:50 +0000 (20:02 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 12 Jun 2008 20:02:50 +0000 (20:02 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1251 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.agent/pom.xml
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/AntSlcApplication.java
org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcMain.java [new file with mode: 0644]
org.argeo.slc.agent/src/test/java/org/argeo/slc/ant/SlcAntTest.java

index 62a5562d8733ed9c6bd191cac1d8e2ec815b503a..1fbd1a40fdce354caf11d5c0282a881e7be8bb04 100644 (file)
                        <artifactId>maven-settings</artifactId>
                </dependency>
 
+               <dependency>
+                       <groupId>commons-cli</groupId>
+                       <artifactId>commons-cli</artifactId>
+               </dependency>
+
        </dependencies>
 </project>
\ No newline at end of file
index 3638340e16cb8fa3eaea8fa6b863e3597adc7b8c..79f325a9c781dbd0032ecaac10330804498254dc 100644 (file)
@@ -37,11 +37,35 @@ public class AntSlcApplication {
        private SlcRuntime slcRuntime;
 
        private Resource contextLocation;
+       private ConfigurableApplicationContext context;
 
        private Resource rootDir;
        private Resource confDir;
        private Resource workDir;
 
+       public void init() {
+               try {
+                       if (confDir != null && contextLocation == null) {
+                               contextLocation = confDir
+                                               .createRelative("applicationContext.xml");
+                       }
+
+                       GenericApplicationContext ctx = new GenericApplicationContext(
+                                       slcRuntime.getRuntimeContext());
+                       if (contextLocation != null && contextLocation.exists()) {
+                               XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
+                                               ctx);
+                               xmlReader.loadBeanDefinitions(contextLocation);
+                       }
+                       ctx.refresh();
+                       context = ctx;
+               } catch (Exception e) {
+                       throw new SlcAntException(
+                                       "Cannot create SLC app application context.", e);
+               }
+
+       }
+
        public void execute(SlcExecution slcExecution, Properties properties,
                        Map<String, Object> references) {
                if (log.isDebugEnabled()) {
@@ -66,6 +90,8 @@ public class AntSlcApplication {
 
                initStructure(project, script);
                runProject(project, targets);
+               
+               ctx.close();
        }
 
        protected Resource findAntScript(SlcExecution slcExecution) {
@@ -114,18 +140,9 @@ public class AntSlcApplication {
 
        protected ConfigurableApplicationContext createExecutionContext() {
                try {
-                       if (confDir != null && contextLocation == null) {
-                               contextLocation = confDir
-                                               .createRelative("applicationContext.xml");
-                       }
-
                        GenericApplicationContext ctx = new GenericApplicationContext(
-                                       slcRuntime.getRuntimeContext());
-                       if (contextLocation != null && contextLocation.exists()) {
-                               XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
-                                               ctx);
-                               xmlReader.loadBeanDefinitions(contextLocation);
-                       }
+                                       context);
+                       ctx.refresh();
                        return ctx;
                } catch (Exception e) {
                        throw new SlcAntException(
@@ -234,30 +251,6 @@ public class AntSlcApplication {
                        throw new SlcAntException("Cannot inititalize execution structure",
                                        e);
                }
-
-               /*
-                * File rootDir = new File(project
-                * .getUserProperty(SlcAntConstants.ROOT_DIR_PROPERTY))
-                * .getAbsoluteFile(); File baseDir =
-                * project.getBaseDir().getAbsoluteFile(); List<File> dirs = new Vector<File>();
-                * File currentDir = baseDir; do { dirs.add(currentDir); currentDir =
-                * currentDir.getParentFile(); if (log.isTraceEnabled()) log.trace("List " +
-                * currentDir); } while (!currentDir.equals(rootDir.getParentFile())); //
-                * first path is root dir (because of previous algorithm) TreeSPath
-                * currPath = TreeSPath.createRootPath(rootDir.getName()); for (int i =
-                * dirs.size() - 1; i >= 0; i--) { File dir = dirs.get(i); // retrieves
-                * description for this path final String description; if (i == 0) {//
-                * project itself description = project.getDescription() != null &&
-                * !project.getDescription().equals("") ? project .getDescription() :
-                * project.getName(); } else { description = dir.getName(); if
-                * (log.isTraceEnabled()) log.trace("Dir desc " + i + "/" + dirs.size() + ": " +
-                * description); } SimpleSElement element = new
-                * SimpleSElement(description); // creates and register path if
-                * (!dir.equals(rootDir)) {// already set currPath =
-                * currPath.createChild(dir.getName()); } registry.register(currPath,
-                * element); } project.addReference(SlcAntConstants.REF_PROJECT_PATH,
-                * currPath);
-                */
        }
 
        protected void parseProject(Project project, Resource script) {
diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcMain.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/SlcMain.java
new file mode 100644 (file)
index 0000000..cf737a0
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.ant;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
+public class SlcMain {
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public static Options createOptions(){
+               Options options = new Options();
+               return options;
+       }
+}
index c49fcc74fc53b613944658989bae6ec4bedbdd1b..4cbdb86cb6515338bc59b12f20dfb91a066bd8cf 100644 (file)
@@ -29,6 +29,7 @@ public class SlcAntTest extends AbstractSpringTestCase {
                slcApp.setRootDir(new FileSystemResource(new File("src/test/resources")\r
                                .getAbsolutePath()\r
                                + File.separator));\r
+               slcApp.init();\r
 \r
                SlcExecution slcExecution = new SlcExecution();\r
                slcExecution.getAttributes().put(SlcAntConstants.EXECATTR_ANT_FILE,\r