Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 38124 invoked from network); 17 Jun 2008 05:58:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jun 2008 05:58:07 -0000 Received: (qmail 4229 invoked by uid 500); 17 Jun 2008 05:58:08 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 4155 invoked by uid 500); 17 Jun 2008 05:58:07 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 4144 invoked by uid 99); 17 Jun 2008 05:58:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jun 2008 22:58:07 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jun 2008 05:57:26 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0E49B234C142 for ; Mon, 16 Jun 2008 22:57:45 -0700 (PDT) Message-ID: <282942309.1213682265057.JavaMail.jira@brutus> Date: Mon, 16 Jun 2008 22:57:45 -0700 (PDT) From: "Elaine Wong (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (SCXML-73) Propose to evaluate delay expression in Send action before parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Propose to evaluate delay expression in Send action before parsing ------------------------------------------------------------------ Key: SCXML-73 URL: https://issues.apache.org/jira/browse/SCXML-73 Project: Commons SCXML Issue Type: Wish Affects Versions: 0.7, 0.6, 0.5, 0.8, 1.0 Reporter: Elaine Wong Fix For: 0.8, 1.0, 0.7, 0.6, 0.5 I am using the Send action to schedule a future event. The current implementation for Send requires me to express delay either as a number or a string defined in CSS2 format. My delay can be as long as 1 month, which works out to: 2678400s for Jan, Mar, May, Jul, Aug, Oct, Dec 2592000s for Apr, Jun, Sep, Nov 2419200s for Feb (non-leap years) A straightforward way for me to calculate the number of seconds for the current month is to tap on Java's calendar classes, so I created a helper object to perform that calculation and tried calling my object in the delay expression, i.e. But this doesn't work. I get the following error message: ERROR [log] For input string: "delay" java.lang.NumberFormatException: For input string: "time.ms(0,1,0,0,0,0)" Looking at the code for Send, I realize that the delay expression does not get evaluated by the evaluator, unlike the other attributes. I did a little experiment and modified the Send.execute method to evaluate the delay expression before parsing. ie. In execute(), I added: String delayString = (String) eval.eval(ctx, delay); long wait = parseDelay(delayString, appLog); I then modified parseDelay() to parse delayString instead of delay, i.e. private long parseDelay(final String delayString, final Log appLog) throws SCXMLExpressionException { long wait = 0L; long multiplier = 1L; if (!SCXMLHelper.isStringEmpty(delayString)) { String trimDelay = delayString.trim(); String numericDelay = trimDelay; .... With these modifications, the above delay expression worked. Although this is a minor tweak, it is very useful for delay expressions that go beyond a couple of seconds or change under different scenarios. Can this feature be included in the next release for SCXML? Elaine -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.