com.region.spring.RegionClientFactoryBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of region-adapter-spring Show documentation
Show all versions of region-adapter-spring Show documentation
It is currently adapted to Spring.
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);
}
}