Package feign.jaxb

Class JAXBEncoder

  • All Implemented Interfaces:
    feign.codec.Encoder

    public class JAXBEncoder
    extends java.lang.Object
    implements feign.codec.Encoder
    Encodes requests using JAXB.

    Basic example with with Feign.Builder:

     JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder()
         .withMarshallerJAXBEncoding("UTF-8")
         .withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd")
         .build();
    
     api = Feign.builder()
         .encoder(new JAXBEncoder(jaxbFactory))
         .target(MyApi.class, "http://api");
     

    The JAXBContextFactory should be reused across requests as it caches the created JAXB contexts.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface feign.codec.Encoder

        feign.codec.Encoder.Default
    • Field Summary

      • Fields inherited from interface feign.codec.Encoder

        MAP_STRING_WILDCARD
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void encode​(java.lang.Object object, java.lang.reflect.Type bodyType, feign.RequestTemplate template)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encode

        public void encode​(java.lang.Object object,
                           java.lang.reflect.Type bodyType,
                           feign.RequestTemplate template)
        Specified by:
        encode in interface feign.codec.Encoder