From: Mathieu Baudier Date: Thu, 2 Oct 2008 14:00:53 +0000 (+0000) Subject: Restrcuture the location of the execution server X-Git-Tag: argeo-slc-2.1.7~2508 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=e95a183611a40be7aca3233bb19b89bdc5043338;hp=fb9ed691edda82f33f7948e36aded2cbdc01c840;p=gpl%2Fargeo-slc.git Restrcuture the location of the execution server git-svn-id: https://svn.argeo.org/slc/trunk@1683 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/detached/SlcDetachedTask.java b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/detached/SlcDetachedTask.java index 8f18c8251..d973d3815 100644 --- a/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/detached/SlcDetachedTask.java +++ b/org.argeo.slc.agent/src/main/java/org/argeo/slc/ant/detached/SlcDetachedTask.java @@ -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; + } }