Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 11933 invoked from network); 15 Mar 2006 13:01:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Mar 2006 13:01:57 -0000 Received: (qmail 23733 invoked by uid 500); 15 Mar 2006 13:01:56 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 23495 invoked by uid 500); 15 Mar 2006 13:01:55 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 23484 invoked by uid 500); 15 Mar 2006 13:01:55 -0000 Received: (qmail 23480 invoked by uid 99); 15 Mar 2006 13:01:55 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2006 05:01:54 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 15 Mar 2006 05:01:54 -0800 Received: (qmail 11732 invoked by uid 65534); 15 Mar 2006 13:01:32 -0000 Message-ID: <20060315130132.11705.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r386065 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs: ConditionTask.java WaitFor.java condition/ConditionBase.java Date: Wed, 15 Mar 2006 13:01:14 -0000 To: ant-cvs@apache.org From: stevel@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: stevel Date: Wed Mar 15 05:01:10 2006 New Revision: 386065 URL: http://svn.apache.org/viewcvs?rev=386065&view=rev Log: Adding some low level diagnostics for waitfor, calling the processSucess and processTimeout methods at appropriate times Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java?rev=386065&r1=386064&r2=386065&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java Wed Mar 15 05:01:10 2006 @@ -43,6 +43,10 @@ private String value = "true"; private String alternative = null; + public ConditionTask() { + super("condition"); + } + /** * The name of the property to set. Required. * @param p the name of the property @@ -81,11 +85,12 @@ public void execute() throws BuildException { if (countConditions() > 1) { throw new BuildException("You must not nest more than one " - + "condition into "); + + "condition into " + + getTaskName()); } if (countConditions() < 1) { throw new BuildException("You must nest a condition into " - + ""); + + getTaskName()); } if (property == null) { throw new BuildException("The property attribute is required."); Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java?rev=386065&r1=386064&r2=386065&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/WaitFor.java Wed Mar 15 05:01:10 2006 @@ -19,6 +19,7 @@ import java.util.Hashtable; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.ConditionBase; import org.apache.tools.ant.types.EnumeratedAttribute; @@ -42,6 +43,8 @@ * The maxwaitunit and checkeveryunit are allowed to have the following values: * millisecond, second, minute, hour, day and week. The default is millisecond. * + * For programmatic use/subclassing, there are two methods that may be overrridden, + * processSuccess and processTimeout * @since Ant 1.5 * * @ant.task category="control" @@ -55,6 +58,10 @@ private long checkEveryMultiplier = 1L; private String timeoutProperty; + public WaitFor() { + super("waitfor"); + } + /** * Set the maximum length of time to wait. * @param time a long value @@ -103,11 +110,12 @@ public void execute() throws BuildException { if (countConditions() > 1) { throw new BuildException("You must not nest more than one " - + "condition into "); + + "condition into " + + getTaskName()); } if (countConditions() < 1) { throw new BuildException("You must nest a condition into " - + ""); + + getTaskName()); } Condition c = (Condition) getConditions().nextElement(); @@ -121,6 +129,7 @@ while (System.currentTimeMillis() < end) { if (c.eval()) { + processSuccess(); return; } try { @@ -130,12 +139,33 @@ } } - if (timeoutProperty != null) { - getProject().setNewProperty(timeoutProperty, "true"); - } + processTimeout(); } finally { maxWaitMillis = savedMaxWaitMillis; checkEveryMillis = savedCheckEveryMillis; + } + } + + /** + * Actions to be taken on a successful waitfor. + * This is an override point. The base implementation does nothing. + * @since Ant1.7 + */ + protected void processSuccess() { + log(getTaskName()+": condition was met", Project.MSG_VERBOSE); + } + + /** + * Actions to be taken on an unsuccessful wait. + * This is an override point. It is where the timeout processing takes place. + * The base implementation sets the timeoutproperty if there was a timeout + * and the property was defined. + * @since Ant1.7 + */ + protected void processTimeout() { + log(getTaskName() +": timeout", Project.MSG_VERBOSE); + if (timeoutProperty != null) { + getProject().setNewProperty(timeoutProperty, "true"); } } Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java?rev=386065&r1=386064&r2=386065&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java Wed Mar 15 05:01:10 2006 @@ -32,9 +32,36 @@ * @since Ant 1.4 */ public abstract class ConditionBase extends ProjectComponent { + + + /** + * name of the component + */ + private String taskName="condition"; + + /** + * + */ private Vector conditions = new Vector(); /** + * simple constructor. + */ + protected ConditionBase() { + taskName = "component"; + } + + /** + * constructor that takes the name of the task + * in the task name + * @param taskName + * @since Ant1.7 + */ + protected ConditionBase(String taskName) { + this.taskName = taskName; + } + + /** * Count the conditions. * * @return the number of conditions in the container @@ -55,6 +82,27 @@ } /** + * Sets the name to use in logging messages. + * + * @param name The name to use in logging messages. + * Should not be null. + * @since Ant 1.7 + */ + public void setTaskName(String name) { + this.taskName = name; + } + + /** + * Returns the name to use in logging messages. + * + * @return the name to use in logging messages. + * @since Ant 1.7 + */ + public String getTaskName() { + return taskName; + } + + /** * Add an <available> condition. * @param a an available condition * @since 1.1 @@ -216,6 +264,7 @@ /** * Add an <typefound> condition. * @param test a TypeFound condition + * @since Ant 1.7 */ public void addTypeFound(TypeFound test) { conditions.addElement(test); @@ -242,6 +291,7 @@ * Add an <isreachable> condition. * * @param test the condition + * @since Ant 1.7 */ public void addIsReachable(IsReachable test) { conditions.addElement(test); @@ -251,6 +301,7 @@ * Add an <issigned> condition. * * @param test the condition + * @since Ant 1.7 */ public void addIsSigned(IsSigned test) { conditions.addElement(test); @@ -260,6 +311,7 @@ * Add an <parsersupports> condition. * * @param test the condition + * @since Ant 1.7 */ public void addParserSupports(ParserSupports test) { conditions.addElement(test); @@ -269,6 +321,7 @@ * Add a <ResourcesMatch> condition. * * @param test the condition + * @since Ant 1.7 */ public void addResourcesMatch(ResourcesMatch test) { conditions.addElement(test); @@ -279,6 +332,7 @@ * Add an <xor> condition. * * @param test the condition + * @since Ant 1.7 */ public void addXor(Xor test) { conditions.addElement(test); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org