Java TPS arguments

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Java TPS arguments

  • Creator
    Topic
  • #51178
    Kyley Jex
    Participant

      Does anyone know if the Java procs supports passing sets of arguments?

      With TCL procs, sets of arguments can be passed in using the syntax:

      { {NAME xxx} {VALUE xxx} }

      { {NAME xxx} {VALUE xxx} }

      However, when I try to pass the same arguments to a Java proc, the userArgs PropertyTree looks like this:

      {CLASS com.mmmhis.cloverleaf.upoc.HttpGetTPS} {{{NAME name1}} {VALUE value1}} {{{NAME name2}} {VALUE value2}}

      Here is what I’m trying to do:  I’ve got a TPS that POSTs a message to a server via HTTPS.  I’d like to pass to the TPS the arguments to construct the URL.  For example, I’d like to pass the URL as one argument and the URL parameters as a set of arguments ( ie. {{NAME param1} {VALUE value1}} {{NAME param2} {VALUE value2}} …).

      I’m already able to achieve the expected behavior by passing the URL parameters as a single TPS argument.  I’m just wondering if this behavior is supported and I’m just not configuring it correctly.

      Cheers,

      Kyley

    Viewing 0 reply threads
    • Author
      Replies
      • #69066
        Levy Lazarre
        Participant

          Kyley,

          Yes, this behavior is supported and you can pass sets of arguments to Java procs.

          In the arguments window, you have to build your arguments as a tree with the main key on top and the branches below. In your case, the URL is the main key, so you could put something like this in your Args window:

           { URL {

                 { LINK “www.google.com” }

                 { param1 “value1” }

                 { param2 “value2” }

             } }

          The userArgs PropertyTree should now look the way you desired.

          Next, in order to retrieve the values of the arguments in your java class, you will have to use the dot (“.”) notation, starting from the parent key (“URL”). For example, in your class constructor, you could have something like:

          /*** Standard TPS Constructors ***/

          public HttpGetTPS (CloverEnv cloverEnv, PropertyTree xArgs) throws CloverleafException

          {

            super(cloverEnv,xArgs);

           

             

            String URL = xArgs.getString(“URL.LINK”);

            System.out.println(“The URL is: ” + URL);

           

            String PARAM1 = xArgs.getString(“URL.param1”);

            System.out.println(“The first parameter is: ” + PARAM1);

           

            String PARAM2 = xArgs.getString(“URL.param2”);

            System.out.println(“The second parameter is: ” + PARAM2);

          }

          I hope this helps.

      Viewing 0 reply threads
      • The forum ‘Cloverleaf’ is closed to new topics and replies.