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

com.zopen.ato.autoconfigure.AliyunVodAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.zopen.ato.autoconfigure;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.zopen.ato.properties.AliyunVodProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(AliyunVodProperties.class)
@ComponentScan("com.zopen.aliyun.vod")
@ConditionalOnProperty(prefix = "zopen.aliyun.vod", name = "open", havingValue = "true")
public class AliyunVodAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(AliyunVodAutoConfiguration.class);

    private final AliyunVodProperties properties;

    public AliyunVodAutoConfiguration(AliyunVodProperties properties) {
        this.properties = properties;
        logger.info("初始化 AliyunVod 配置:" + properties);
    }

    @Bean
    @ConditionalOnMissingBean
    public DefaultAcsClient initVodClient() {
        String regionId = AliyunVodProperties.REGION_ID;  // 点播服务接入区域
        DefaultProfile profile = DefaultProfile.getProfile(regionId, properties.getAccessKeyId(), properties.getAccessKeySecret());
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy