7 Replies Latest reply on Apr 8, 2014 2:09 PM by hemartins

    REST reference questions

    hemartins

      Hi,

       

      I have two issues using references with REST binding. The first is that I must be able to change the binding IP address without redeploy the whole service. Is it possible to change the address during the execution of the service?

       

          <sca:reference name="Task" multiplicity="0..1" promote="ProcessComponent/Task">
            <sca:interface.java interface="Task"/>
            <resteasy:binding.rest>
              <resteasy:interfaces>Task</resteasy:interfaces>
              <resteasy:address>http://10.112.34.31:8080/</resteasy:address>
            </resteasy:binding.rest>
          </sca:reference>
      

       

       

      The second is about using Path Parameters on the reference path. Below is the Interface that implements the reference. This interface is used by a service task in a bpmn proccess. I'm not finding a way to use this... Which is the best way?

       

       

      @Path("/sensor")
      public interface Task {
        @GET
        @Path("/{id}/info")
        @Consumes(MediaType.APPLICATION_XML)
        public Data getInfo();
      }
      

       

       

      Thanks in advance,

      Best Regards

        • 1. Re: REST reference questions
          trohovsky

          Hi Henrique,

           

          a dynamic change of an address in REST binding have been already discussed in this thread: Dynamic soap, http and resteasy endpoints.

           

          Checkout the rest-binding quickstart to see how to configure REST on a reference. You can see how to use path parameters in quickstarts/rest-binding/src/main/java/org/switchyard/quickstarts/rest/binding/WarehouseResource.java at master · jboss-…

           

          Tomas

          • 2. Re: REST reference questions
            hemartins

            Thanks Tomas. I will check it

            • 3. Re: Re: REST reference questions
              hemartins

              I've tried to use properties in order to change the address. In my switchyard.xml I have:

                  <sca:reference name="Task" multiplicity="0..1" promote="ProcessComponent/Task">
                    <sca:interface.java interface="transformers.Task"/>
                    <resteasy:binding.rest>
                      <resteasy:interfaces>transformers.Task</resteasy:interfaces>
                      <resteasy:address>{$refAddress}</resteasy:address>
                    </resteasy:binding.rest>
                  </sca:reference>
              
              

               

              This works fine, but when I change the value of refAddress nothing happens, it still points to the original value. It seems the property value (and the switchyard.xml file) are only read once. Is there any other way to change the value of the address?

              • 4. Re: Re: REST reference questions
                trohovsky

                You have a typo in your switchyard.xml, replace {$refAddress} with ${refAddress}. If it is just in the posted snippet and not in your switchyard.xml, then: How do you configure the property?

                • 5. Re: Re: REST reference questions
                  hemartins

                  Sorry my bad, it's only on the snippet. The switchyard.xml is correct and works fine. I configure the property using a properties file and I am injecting the file into the runtime environment using -P during Jboss start up.
                  When I change the property in the file or in the JBoss management console the switchyard ignores it... I think this is caused because the switchyard.xml is only read at the startup, so further changes are ignored...

                  • 6. Re: Re: REST reference questions
                    trohovsky

                    You don't have to restart the whole JBoss AS/EAP. Re-deployment of the application worked for me. A substitution of properties is probably handled during deployment. Properties should be changed in the management console or by jboss-cli, changing of them in the properties file, loaded by -P, will not take an effect.

                    • 7. Re: Re: REST reference questions
                      hemartins

                      Re-deployment works for me too. But it must be a way to change it dynamically without any redeployment... Later I will try other approaches.

                       

                      Thanks a lot for your time Tomas.


                      Best Regards