0 Replies Latest reply on Jun 4, 2014 6:02 AM by aqtwrdnr aqtwrdnr

    CLI if-else construction on the value of a JNDI binding

    aqtwrdnr aqtwrdnr Newbie

      Hello,

       

      I want to toggle a Boolean JNDI binding value through the jboss-cli.sh, but I cannot get it to work. I have modified the following statements from if-else control flow :

       

      if (result.value == true) of /system-property=test:read-resource

          /system-property=test:write-attribute(name=value,value=false)

      else

          /system-property=test:write-attribute(name=value,value=true)

      end-if

       

      which works correctly. To test my modified version, follow the following steps:

       

      1) Open the CLI interactively to manually create a test JNDI binding:

              $JBOSS_HOME/bin/jboss-cli.sh -c

              /subsystem=naming/binding=java\:global\/test:add(binding-type=simple, type=java.lang.Boolean, value=true)

              quit

       

      2) Create a file if-else-test.cli with the code to toggle the value of the JNDI binding:

       

              vi if-else.cli

       

              Give the if-else.cli the following content:

       

      /subsystem=naming/binding=java\:global\/test:read-attribute(name=value)

      if (result.value == true) of /subsystem=naming/binding=java\:global\/test:read-resource

          /subsystem=naming/binding=java\:global\/test:write-attribute(name=value, value=false)

      else

          /subsystem=naming/binding=java\:global\/test:write-attribute(name=value, value=true)

      end-if

      :reload

      /subsystem=naming/binding=java\:global\/test:read-attribute(name=value)

       

      3) Now execute the if-else.cli file and check from the output whether the value of java:global/test indeed toggles between true and false.

              $JBOSS_HOME/bin/jboss-cli.sh -c --file=if-else.cli

       

      4) Afterwards you can remove the test JNDI binding:

              $JBOSS_HOME/bin/jboss-cli.sh -c

              /subsystem=naming/binding=java\:global\/test:remove()

              quit

       

      What am I doing wrong?

       

      Kind regards,

       

      Barry