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

org.zodiac.autoconfigure.oss.PlatformHuaweiObsAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.oss;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.oss.condition.ConditionalOnOssEnabled;
import org.zodiac.autoconfigure.security.condition.ConditionalOnSecurityHttpEnabled;

@SpringBootConfiguration
@ConditionalOnOssEnabled
//@ConditionalOnWebApplication
@ConditionalOnSecurityHttpEnabled
@AutoConfigureAfter(value = {PlatformOssAutoConfiguration.class})
@ConditionalOnClass(value = {com.obs.services.ObsClient.class, org.zodiac.oss.config.PlatformOssInfo.class, org.zodiac.security.SecurityAuthOperations.class})
@ConditionalOnProperty(value = org.zodiac.oss.constants.OssSystemPropertiesConstants.PLATFORM_OSS_NAME, havingValue = org.zodiac.oss.constants.OssConstants.HUAWEI_OBS)
public class PlatformHuaweiObsAutoConfiguration {

    private final PlatformOssProperties ossProperties;

    public PlatformHuaweiObsAutoConfiguration(PlatformOssProperties ossProperties) {
        this.ossProperties = ossProperties;
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.oss.rule.OssRule ossRule(org.zodiac.security.SecurityAuthOperations2 securityAuthOperations) {
        return new org.zodiac.oss.rule.PlatfotmOssRule(ossProperties.isTenantMode(), securityAuthOperations);
    }

    @Bean
    @ConditionalOnMissingBean
    protected com.obs.services.ObsClient obsClient() {
        /*使用可定制各参数的配置类(ObsConfiguration)创建OBS客户端(ObsClient),创建完成后不支持再次修改参数*/
        com.obs.services.ObsConfiguration conf = new com.obs.services.ObsConfiguration ();

        conf.setEndPoint(ossProperties.getEndpoint());
        org.zodiac.oss.config.HuaweiObsInfo huaweiObs = ossProperties.getHuaweiObs();
        conf.setMaxConnections(huaweiObs.getMaxConnections());
        conf.setSocketTimeout(huaweiObs.getSocketTimeout());
        conf.setConnectionTimeout(huaweiObs.getConnectionTimeout());
        conf.setConnectionRequestTimeout(huaweiObs.getConnectionRequestTimeout());
        conf.setIdleConnectionTime(huaweiObs.getIdleConnectionTime());
        conf.setMaxErrorRetry(huaweiObs.getMaxErrorRetry());
        return new com.obs.services.ObsClient(ossProperties.getAccessKey(), ossProperties.getSecretKey(), conf);
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnBean({com.obs.services.ObsClient.class, org.zodiac.oss.rule.OssRule.class})
    protected org.zodiac.oss.HuaweiObsTemplate huaweiobsTemplate(com.obs.services.ObsClient ossClient, org.zodiac.oss.rule.OssRule ossRule) {
        return new org.zodiac.oss.HuaweiObsTemplate(ossClient, ossProperties, ossRule);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy