]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/deploy/SlcDeployTask.java
Improve spring arguments
[gpl/argeo-slc.git] / org.argeo.slc.agent / src / main / java / org / argeo / slc / ant / deploy / SlcDeployTask.java
index 36c22547bd73d1aee2428562f5de51e3eb85987c..8e6fc63b108b84b04c0df2a15b8c8d84241512d2 100644 (file)
@@ -3,12 +3,13 @@ package org.argeo.slc.ant.deploy;
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
 import org.apache.tools.ant.BuildException;\r
-\r
-import org.argeo.slc.ant.spring.AbstractSpringArg;\r
+import org.argeo.slc.ant.SlcAntConfig;\r
+import org.argeo.slc.ant.spring.SpringArg;\r
 import org.argeo.slc.ant.structure.SAwareTask;\r
+import org.argeo.slc.core.build.Distribution;\r
+import org.argeo.slc.core.deploy.Deployment;\r
 import org.argeo.slc.core.deploy.DeploymentData;\r
 import org.argeo.slc.core.deploy.TargetData;\r
-import org.argeo.slc.core.deploy.WritableDeployment;\r
 \r
 /** Ant task wrapping a deployment. */\r
 public class SlcDeployTask extends SAwareTask {\r
@@ -16,22 +17,28 @@ public class SlcDeployTask extends SAwareTask {
 \r
        private String deploymentBean = null;\r
 \r
-       private DeploymentDataArg deploymentDataArg;\r
-       private TargetDataArg targetDataArg;\r
+       private SpringArg<DeploymentData> deploymentDataArg;\r
+       private SpringArg<TargetData> targetDataArg;\r
+       private SpringArg<Distribution> distributionArg;\r
 \r
        @Override\r
        public void executeActions(String mode) throws BuildException {\r
-               WritableDeployment deployment = (WritableDeployment) getContext()\r
-                               .getBean(deploymentBean);\r
+               Deployment deployment = (Deployment) getContext().getBean(\r
+                               deploymentBean);\r
 \r
                // set overridden references\r
+               if (distributionArg != null) {\r
+                       deployment.setDistribution(distributionArg.getBeanInstance());\r
+                       log.trace("Overrides distribution");\r
+               }\r
+\r
                if (deploymentDataArg != null) {\r
-                       deployment.setDeploymentData(deploymentDataArg.getDeploymentData());\r
+                       deployment.setDeploymentData(deploymentDataArg.getBeanInstance());\r
                        log.trace("Overrides deployment data");\r
                }\r
 \r
                if (targetDataArg != null) {\r
-                       deployment.setTargetData(targetDataArg.getTargetData());\r
+                       deployment.setTargetData(targetDataArg.getBeanInstance());\r
                        log.trace("Overrides target data");\r
                }\r
 \r
@@ -48,28 +55,19 @@ public class SlcDeployTask extends SAwareTask {
        }\r
 \r
        /** Creates deployment data sub tag. */\r
-       public DeploymentDataArg createDeploymentData() {\r
-               deploymentDataArg = new DeploymentDataArg();\r
+       public SpringArg<DeploymentData> createDeploymentData() {\r
+               deploymentDataArg = new SpringArg<DeploymentData>();\r
                return deploymentDataArg;\r
        }\r
 \r
        /** Creates target data sub tag. */\r
-       public TargetDataArg createTargetData() {\r
-               targetDataArg = new TargetDataArg();\r
+       public SpringArg<TargetData> createTargetData() {\r
+               targetDataArg = new SpringArg<TargetData>();\r
                return targetDataArg;\r
        }\r
-}\r
 \r
-class DeploymentDataArg extends AbstractSpringArg {\r
-       DeploymentData getDeploymentData() {\r
-               return (DeploymentData) getBeanInstance();\r
+       public SpringArg<Distribution> createDistribution() {\r
+               distributionArg = new SpringArg<Distribution>();\r
+               return distributionArg;\r
        }\r
-\r
-}\r
-\r
-class TargetDataArg extends AbstractSpringArg {\r
-       TargetData getTargetData() {\r
-               return (TargetData) getBeanInstance();\r
-       }\r
-\r
 }\r