Package halfpipe.client

Source Code of halfpipe.client.ClientConfigurer

package halfpipe.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import feign.Feign;
import feign.InvocationHandlerFactory;
import feign.Logger;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.jackson.JacksonEncoder;
import feign.slf4j.Slf4jLogger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.inject.Inject;

@Configuration
public class ClientConfigurer {

    @Inject
    ObjectMapper objectMapper;

    @Bean
    public Encoder feignEncoder() {
        return new JacksonEncoder(objectMapper);
    }

    @Bean
    public Decoder feignDecoder() {
        return new HystrixJacksonDecoder(objectMapper);
        //return new JacksonDecoder();
    }

    @Bean
    public Logger feignLogger() {
        return new Slf4jLogger(); //TODO pass Client classname in
    }

    @Bean
    public InvocationHandlerFactory invocationHandlerFactory() {
        return new HystrixInvocationHandler.Factory();
    }

    protected Feign.Builder client() {
        return Feign.builder()
                .logger(feignLogger())
                .encoder(feignEncoder())
                .decoder(feignDecoder())
                .invocationHandlerFactory(invocationHandlerFactory());
    }

}
TOP

Related Classes of halfpipe.client.ClientConfigurer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.