Added sleep operation to MiscService

git-svn-id: https://brutex.net/svn/xservices/trunk@20 e7e49efb-446e-492e-b9ec-fcafc1997a86
tag-20130205r
Brian Rosenberger 2010-02-14 08:42:03 +00:00
parent ea59329a8c
commit 146aae010c
3 changed files with 29 additions and 8 deletions

View File

@ -37,8 +37,10 @@ public class RunTask {
Project antproject;
Target anttarget;
Task anttask;
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
ByteArrayOutputStream myout = new ByteArrayOutputStream();
ByteArrayOutputStream myerr = new ByteArrayOutputStream();
PrintStream out = new PrintStream(myout);
PrintStream err = new PrintStream(myerr);
TimestampedLogger log = null;
public RunTask(Task anttask) {
@ -47,8 +49,8 @@ public class RunTask {
antproject.init();
antproject.setBasedir(System.getProperty("java.io.tmpdir"));
log = new TimestampedLogger();
log.setOutputPrintStream(new PrintStream(out));
log.setErrorPrintStream(new PrintStream(err));
log.setOutputPrintStream(out);
log.setErrorPrintStream(err);
log.setMessageOutputLevel(Echo.EchoLevel.WARN.getLevel());
antproject.addBuildListener(log);
@ -79,7 +81,7 @@ public class RunTask {
try {
antproject.executeTarget(anttarget.getName());
} catch (BuildException ex) {
new PrintStream(err).println(ex.getMessage());
err.print(ex.getMessage());
returnCode = 1;
}
newMap = antproject.getProperties();
@ -90,8 +92,8 @@ public class RunTask {
//anttask.execute();
return new ReturnCode(returnCode,
out.toString(),
err.toString(),
myout.toString(),
myerr.toString(),
AntProperty.createAntPropertyList(newMap));
}

View File

@ -39,4 +39,8 @@ public interface MiscService {
@WebParam(name="to") String tolist,
@WebParam(name="subject") String subject,
@WebParam(name="message") String message);
@WebMethod(operationName="sleep")
public ReturnCode sleep(@WebParam(name="minutes") int minutes,
@WebParam(name="seconds") int seconds);
}

View File

@ -22,8 +22,8 @@ import net.brutex.xservices.types.HostConnection;
import net.brutex.xservices.types.ReturnCode;
import net.brutex.xservices.util.RunTask;
import org.apache.tools.ant.taskdefs.HostInfo;
import org.apache.tools.ant.taskdefs.Sleep;
import org.apache.tools.ant.taskdefs.email.EmailTask;
import org.apache.tools.ant.taskdefs.email.Mailer;
/**
*
@ -56,6 +56,10 @@ public class MiscServiceImpl implements MiscService {
false);
}
public ReturnCode sleep(int minutes, int seconds) {
return sleep(0, minutes, seconds, 0);
}
private ReturnCode antGetHostinfo(String hostname, String prefix) {
@ -107,4 +111,15 @@ public class MiscServiceImpl implements MiscService {
return runner.postTask();
}
private ReturnCode sleep(int hours, int minutes, int seconds, int milliseconds) {
Sleep sleep = new Sleep();
sleep.setTaskName("Sleep");
RunTask runner = new RunTask(sleep);
sleep.setHours(hours);
sleep.setMinutes(minutes);
sleep.setSeconds(seconds);
sleep.setMilliseconds(milliseconds);
return runner.postTask();
}
}