]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Restrcuture the location of the execution server
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 2 Oct 2008 14:00:53 +0000 (14:00 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 2 Oct 2008 14:00:53 +0000 (14:00 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1683 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/detached/SlcDetachedTask.java

index 8f18c8251f174ded7bcbcebfb1fbe8cbc83ac052..d973d381513b141546f50730d76fad664cb88138 100644 (file)
@@ -1,14 +1,17 @@
 package org.argeo.slc.ant.detached;
 
+import java.util.Properties;
 import java.util.UUID;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.ant.spring.MapArg;
 import org.argeo.slc.ant.structure.SAwareTask;
 import org.argeo.slc.core.SlcException;
 import org.argeo.slc.detached.DetachedAnswer;
 import org.argeo.slc.detached.DetachedClient;
 import org.argeo.slc.detached.DetachedRequest;
+import org.argeo.slc.spring.SpringUtils;
 
 public class SlcDetachedTask extends SAwareTask {
        private final static Log log = LogFactory.getLog(SlcDetachedTask.class);
@@ -16,12 +19,32 @@ public class SlcDetachedTask extends SAwareTask {
        private String client;
        private String action;
 
+       private MapArg properties;
+
        @Override
        protected void executeActions(String mode) {
-               DetachedClient detachedClient = getBean(client);
+               // Find detached client
+               DetachedClient detachedClient = null;
+               if (client != null)
+                       detachedClient = getBean(client);
+               else
+                       detachedClient = SpringUtils.loadSingleFromContext(getContext(),
+                                       DetachedClient.class);
+
+               if (detachedClient == null)
+                       throw new SlcException("Could not find any detached client.");
+
+               // Prepare and send request
                DetachedRequest request = new DetachedRequest(UUID.randomUUID()
                                .toString());
                request.setRef(action);
+
+               if (properties != null) {
+                       Properties props = new Properties();
+                       props.putAll(properties.getMap());
+                       request.setProperties(props);
+               }
+
                try {
                        detachedClient.sendRequest(request);
                        DetachedAnswer answer = detachedClient.receiveAnswer();
@@ -43,4 +66,11 @@ public class SlcDetachedTask extends SAwareTask {
                this.action = action;
        }
 
+       public MapArg createProperties() {
+               if (properties == null)
+                       properties = new MapArg();
+               else
+                       throw new SlcException("Properties already declared.");
+               return properties;
+       }
 }