That is the expected behavior.  We have the following note in the STAF Ant 
User's Guide section 3.2:

Note that since Ant properties are immutable, meaning that they cannot be 
changed after being set, to get the correct return code and result value 
from the STAF Ant Task, you need to use a unique resultPrefix every time 
the STAF Ant Task is used. 

David Bender
STAF/STAX Development
(512-286-5315)
IBM Austin Bldg. 903-5B002
Internet: bda...@us.ibm.com




George Flaherty <george.flahe...@sas.com> 
05/04/2009 10:53 AM

To
"staf-users@lists.sourceforge.net" <staf-users@lists.sourceforge.net>
cc

Subject
[staf-users] STAF Ant resultprefix






Hello,

I Just want to confirm if the resultprefix logic for the STAF Ant addon is 
correct or not. I am currently building up an ANT script which will 
contains ANT based marcos. The ANT based macros are wrappers for STAF 
commands, for example:

This ant macro wraps the STAF variable resolution based on target system 
and variable.
        <macrodef name="getSTAFVAR">
                <attribute name="targetSystem"  default="localhost"/>
                <attribute name="targetVAR"     default="none-provided"/>
                <attribute name="stafres"               default="none"/>
        <sequential>
        <staf location="@{targetSystem}"
              service="VAR"
              request="RESOLVE STRING &#123;@{targetVAR}&#125;"
                  resultPrefix="@{stafres}"
              throwBuildException="1"/>
        </sequential>
        </macrodef>


Now when I call this macro such as:

    <target name="test.staf.1">
                <getSTAFVAR targetSystem="localhost" targetVAR="FOOBAR_1" 
stafres="foobar"/>
                <getSTAFVAR targetSystem="localhost" targetVAR="FOOBAR_2" 
stafres="foobar"/>
                <echo message="${foobar.result}"/>
                <echo message="${foobar.result}"/>
    </target>

It seems that the resultPrefix it maintaining the original value and not 
be overwritten by the second calling of the ANT macro "getSTAFVAR", as you 
can see below:

Please note I have the following set in my STAF.cfg
SET SYSTEM VAR FOOBAR_1=Hello
SET SYSTEM VAR FOOBAR_2=GoodBye


test.staf.1:
     [staf] localhost VAR RESOLVE STRING {FOOBAR_1}
     [staf] RC=0, Result=Hello
     [staf] localhost VAR RESOLVE STRING {FOOBAR_2}
     [staf] RC=0, Result=GoodBye
     [echo] Hello <--This is from the first call
     [echo] Hello <-This is from the second call, yet I was expecting 
"GoodBye"

The only way I am currently getting around this is by each call, having a 
unique resultPrefix such as:


    <target name="test.staf.2" depends="test.staf.1">
                <getSTAFVAR targetSystem="localhost" targetVAR="FOOBAR_1" 
stafres="foobar"/>
                <getSTAFVAR targetSystem="localhost" targetVAR="FOOBAR_2" 
stafres="foobar2"/>
                <echo message="${foobar.result}"/>
                <echo message="${foobar2.result}"/>
    </target>

test.staf.2:
     [staf] localhost VAR RESOLVE STRING {FOOBAR_1}
     [staf] RC=0, Result=Hello
     [staf] localhost VAR RESOLVE STRING {FOOBAR_2}
     [staf] RC=0, Result=GoodBye
     [echo] Hello
     [echo] GoodBye


Therefore is this the intended functionality/logic for the resultPefix Or 
am I missing something here? As always thanks!

-george





------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to