com.zopen.ato.autoconfigure.AliyunVodAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zopen-ato-starter Show documentation
Show all versions of zopen-ato-starter Show documentation
Alibaba Tencent And Others For Spring Boot.
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;
}
}