@@ -83,6 +83,12 @@ public class RExecTask extends Task {
*/
public class RExecSubTask {
protected String taskString = "";
/**
* Execute the subtask.
* @param rexec the client
* @throws BuildException always as it is not allowed to instantiate this object
*/
public void execute(AntRExecClient rexec)
throws BuildException {
throw new BuildException("Shouldn't be able instantiate a SubTask directly");
@@ -90,6 +96,7 @@ public class RExecTask extends Task {
/**
* the message as nested text
* @param s the nested text
*/
public void addText(String s) {
setString(getProject().replaceProperties(s));
@@ -97,6 +104,7 @@ public class RExecTask extends Task {
/**
* the message as an attribute
* @param s a <code>String</code> value
*/
public void setString(String s) {
taskString += s;
@@ -108,6 +116,11 @@ public class RExecTask extends Task {
*/
public class RExecWrite extends RExecSubTask {
private boolean echoString = true;
/**
* Execute the write exec task.
* @param rexec the task to use
* @throws BuildException on error
*/
public void execute(AntRExecClient rexec)
throws BuildException {
rexec.sendString(taskString, echoString);
@@ -116,6 +129,7 @@ public class RExecTask extends Task {
/**
* Whether or not the message should be echoed to the log.
* Defaults to <code>true</code>.
* @param b a <code>boolean</code> value
*/
public void setEcho(boolean b) {
echoString = b;
@@ -128,12 +142,18 @@ public class RExecTask extends Task {
*/
public class RExecRead extends RExecSubTask {
private Integer timeout = null;
/**
* Execute the read exec task.
* @param rexec the task to use
* @throws BuildException on error
*/
public void execute(AntRExecClient rexec)
throws BuildException {
rexec.waitForString(taskString, timeout);
}
/**
* a timeout value that overrides any task wide timeout.
* @param i an <code>Integer</code> value
*/
public void setTimeout(Integer i) {
this.timeout = i;
@@ -141,6 +161,7 @@ public class RExecTask extends Task {
/**
* Sets the default timeout if none has been set already
* @param defaultTimeout an <code>Integer</code> value
* @ant.attribute ignore="true"
*/
public void setDefaultTimeout(Integer defaultTimeout) {
@@ -206,7 +227,8 @@ public class RExecTask extends Task {
/**
* Write this string to the rexec session.
* @param echoString Logs string sent
* @param s the string to write
* @param echoString if true log the string sent
*/
public void sendString(String s, boolean echoString) {
OutputStream os = this.getOutputStream();
@@ -279,6 +301,7 @@ public class RExecTask extends Task {
* A string to wait for from the server.
* A subTask <read> tag was found. Create the object,
* Save it in our list, and return it.
* @return a read sub task
*/
public RExecSubTask createRead() {
@@ -290,6 +313,7 @@ public class RExecTask extends Task {
* Add text to send to the server
* A subTask <write> tag was found. Create the object,
* Save it in our list, and return it.
* @return a write sub task
*/
public RExecSubTask createWrite() {
RExecSubTask task = (RExecSubTask) new RExecWrite();
@@ -298,8 +322,9 @@ public class RExecTask extends Task {
}
/**
* Verify that all parameters are included.
* Connect and possibly login
* Iterate through the list of Reads and writes
* Connect and possibly login.
* Iterate through the list of Reads and writes.
* @throws BuildException on error
*/
public void execute() throws BuildException {
/** A server name is required to continue */
@@ -367,10 +392,15 @@ public class RExecTask extends Task {
}
/**
* Set the the comand to execute on the server;
* @param c a <code>String</code> value
*/
public void setCommand(String c) { this.command = c; }
public void setCommand(String c) {
this.command = c;
}
/**
* send a carriage return after connecting; optional, defaults to false.
* @param b a <code>boolean</code> value
*/
public void setInitialCR(boolean b) {
this.addCarriageReturn = b;
@@ -378,19 +408,32 @@ public class RExecTask extends Task {
/**
* Set the the login password to use
* required if <tt>userid</tt> is set.
* @param p a <code>String</code> value
*/
public void setPassword(String p) { this.password = p; }
public void setPassword(String p) {
this.password = p;
}
/**
* Set the tcp port to connect to; default is 23.
* @param p an <code>int</code> value
*/
public void setPort(int p) { this.port = p; }
public void setPort(int p) {
this.port = p;
}
/**
* Set the hostname or address of the remote server.
* @param m a <code>String</code> value
*/
public void setServer(String m) { this.server = m; }
public void setServer(String m) {
this.server = m;
}
/**
* set a default timeout in seconds to wait for a response,
* zero means forever (the default)
* @param i an <code>Integer</code> value
*/
public void setTimeout(Integer i) {
this.defaultTimeout = i;
@@ -398,6 +441,9 @@ public class RExecTask extends Task {
/**
* Set the the login id to use on the server;
* required if <tt>password</tt> is set.
* @param u a <code>String</code> value
*/
public void setUserid(String u) { this.userid = u; }
public void setUserid(String u) {
this.userid = u;
}
}