All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.region.spring.RegionClientFactoryBean Maven / Gradle / Ivy

The newest version!
package com.region.spring;

import com.region.core.env.Operators;
import com.region.core.env.PropertiesOperator;
import com.region.http.client.RegionHttpClient;
import com.region.http.client.config.ClientConfig;
import com.region.http.client.core.RegionClientFactory;
import com.region.spring.operator.RegionSpringPropertiesOperator;
import com.region.spring.resolver.MultipartFileParameterResolver;
import com.region.spring.resolver.MultipartFileResultResolver;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;

/**
 * @author 26225
 * @date 2024/7/20 15:40
 * @description
 */
public class RegionClientFactoryBean implements InitializingBean, EnvironmentAware {

    private ClientConfig config;

    private RegionClientFactory regionClientFactory;

    public void setConfig(ClientConfig config) {
        this.config = config;
    }

    public RegionClientFactory getFactory() {
        return regionClientFactory;
    }

    @Override
    public void setEnvironment(Environment environment) {
        PropertiesOperator operator = Operators.createOperator(RegionSpringPropertiesOperator.class);
        if (operator instanceof RegionSpringPropertiesOperator) {
            RegionSpringPropertiesOperator regionSpringPropertiesOperator = (RegionSpringPropertiesOperator) operator;
            regionSpringPropertiesOperator.setEnvironment(environment);
        }
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        config.getParameterResolvers().add(new MultipartFileParameterResolver());
        config.getResultResolvers().add(new MultipartFileResultResolver());
        regionClientFactory = RegionHttpClient.create(config);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy