##############################################################################
# JBoss, Home of Professional Open Source
# Copyright 2009, Red Hat and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#

##############################################################################
#
# log a message to indicate that triggerMethod1 was called and fired the rule

RULE log potentially recursively triggered method
CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
METHOD triggerMethod1(int)
HELPER org.jboss.byteman.tests.helpers.Default
AT ENTRY
BIND test = $0;
     count = $1
IF TRUE
DO test.log("triggerMethod1 : triggered with " + count)
ENDRULE

##############################################################################
#
# log a message to indicate that triggerMethod2 was called and call
# triggerMethod1 with recursive triggering enabled (the default)

RULE test recursive trigger enabled
CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
METHOD triggerMethod2()
HELPER org.jboss.byteman.tests.helpers.Default
AT ENTRY
BIND test : TestRecursiveTriggers = $0
IF TRUE
DO test.log("triggerMethod2 : triggered");
   test.triggerMethod1(2)
ENDRULE

##############################################################################
#
# log a message to indicate that triggerMethod2 was called and call
# triggerMethod1 with recursive triggering disabled and then again with
# triggering enabled


RULE test recursive trigger disabled then enabled
CLASS org.jboss.byteman.tests.misc.TestRecursiveTriggers
METHOD triggerMethod3()
HELPER org.jboss.byteman.tests.helpers.Default
AT ENTRY
BIND test : TestRecursiveTriggers = $0
IF TRUE
DO test.log("triggerMethod3 : triggered");
   setTriggering(false);
   test.triggerMethod1(3);
   setTriggering(true);
   test.triggerMethod1(4)
ENDRULE



