4 Replies Latest reply on May 31, 2019 4:38 PM by Ramesh Reddy

    Documentation Teiid Spring Boot annotations

    dmitri kov Newbie

      Hello,

       

      Could someone please kindly post a link to documentation for all Teiid Spring boot annotations?

       

      In particular, I am struggling to understand usage of "@RestConfiguration" annotation.

       

      One of the tutorials recommends referring to the reference guide Reference Guide · GitBook , but no luck.

       

      Teiid Api docs

      http://docs.jboss.org/teiid/8.6.0.Final/apidocs/index.html?org/teiid/adminapi/AdminObject.html

      does not contain that information either

       

      Many thanks!

      D.

        • 1. Re: Documentation Teiid Spring Boot annotations
          Steven Hawkins Master

          > Could someone please kindly post a link to documentation for all Teiid Spring boot annotations?

           

          There are only a handful of Teiid Spring Boot annotations.  Everything else is simply Spring Boot.  See teiid-spring-boot/Reference.adoc at master · teiid/teiid-spring-boot · GitHub

          • 2. Re: Documentation Teiid Spring Boot annotations
            Ramesh Reddy Master

            Also Teiid specific annotations have detailed java doc on them. Also in examples there possibly is an example on it on its use.

             

            For spring boot specific or jpa specific we don't have anything in documents

             

             

            Ramesh..

            • 3. Re: Documentation Teiid Spring Boot annotations
              dmitri kov Newbie

              Hi,

               

              Saw that link and was happy for a second! It does mention @RestConfiguration annotation, but all it says about it is this:

               

              @RestConfiguration

              When working with REST based sources with entities like @JsonTable or @TextTable, to configure http verbs or headers use this annotation to configure those properties. If used on any non REST based sources it will not have any effect.

               

              I need to understand: how do I use this annotation to add a header to my wed service call? With the information above I cannot guess it. The annotation text a String parameter "HeaderBean", which is I guess what I need. But how to use it? What should I set this string too? Do I need to define a separate HeaderBean class?.. The pass its name?.. It would be really great to get a bit more info.

               

              Thanks again,

              Dmitry

              • 4. Re: Documentation Teiid Spring Boot annotations
                Ramesh Reddy Master

                From Java Doc

                 


                 @Entity
                 @JsonTable(source=rest, endpoint="http://my.serviceprovider.com/service")
                 @RestConfiguration(method="GET", headersBean="myHeaders")
                 public class Person {
                  @Id
                  private int id;
                
                  @Column(name="FirstName")
                  private String firstName;
                
                  @Column(name="LastName")
                  private String lastName;
                
                  @Column(name="Age")
                  private int age;
                  ...
                 }

                 

                and for "headersBean" on the method's Javadoc

                 

                Bean name which defines the HTTP Headers to be sent to the REST invocation. For example when you want to handle HTTP Basic Authentication, you can do like.

                 @Configuration public class MyConfigClass {
                 @Bean(name="myHeaders") 
                 private HttpHeaders createHttpHeaders() { 
                     String notEncoded = "user:password"; 
                     String encodedAuth = Base64.getEncoder().encodeToString(notEncoded.getBytes()); 
                     HttpHeaders headers = new HttpHeaders(); 
                     headers.setContentType(MediaType.APPLICATION_JSON); 
                     headers.add("Authorization", "Basic " + encodedAuth); 
                     return headers; 
                 }

                 

                In th above example if you are looking for "Person" entity, it will use "GET" method on endpoint with given headers to grab the content, and parse using the Person class and provide you with an entity. You can also use JDBCTemplate and issue any calls like "select * from Person", which will also do the same but returns the resultset. Hopefully, that is clear?

                1 of 1 people found this helpful