use of com.jeesuite.cos.provider.aliyun.AliyunProvider in project jeesuite-libs by vakinge.
the class CosProviderServiceFacade method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
//
if (defaultBucket == null) {
defaultBucket = ResourceUtils.getProperty("cos.defaultBucket");
}
if (type == null) {
type = ResourceUtils.getAndValidateProperty("cos.provider");
}
if (config == null) {
config = new CosProviderConfig();
config.setAccessKey(ResourceUtils.getProperty("cos.accessKey"));
config.setSecretKey(ResourceUtils.getProperty("cos.secretKey"));
config.setAppId(ResourceUtils.getProperty("cos.appId"));
config.setRegionName(ResourceUtils.getProperty("cos.regionName"));
config.setMaxConnectionsCount(ResourceUtils.getInt("cos.maxConnections", 200));
}
if (AliyunProvider.NAME.equals(type)) {
provider = new AliyunProvider(config);
} else if (QcloudProvider.NAME.equals(type)) {
provider = new QcloudProvider(config);
} else if (QiniuProvider.NAME.equals(type)) {
provider = new QiniuProvider(config);
} else {
throw new JeesuiteBaseException("cos[" + type + "] not support");
}
if (defaultBucket != null) {
BucketConfig bucketConfig = provider.getBucketConfig(defaultBucket);
bucketConfig.setUrlPrefix(ResourceUtils.getProperty("cos.defaultUrlPrefix"));
((AbstractProvider) provider).addBucketConfig(bucketConfig);
} else {
Map<String, String> urlPrefixMappings = ResourceUtils.getMappingValues("cos.bucket.urlPrefix.mapping");
if (urlPrefixMappings != null) {
urlPrefixMappings.forEach((bucket, urlPrefix) -> {
BucketConfig bucketConfig = provider.getBucketConfig(defaultBucket);
bucketConfig.setUrlPrefix(ResourceUtils.getProperty("cos.defaultUrlPrefix"));
((AbstractProvider) provider).addBucketConfig(bucketConfig);
});
}
}
logUrl = ResourceUtils.getProperty("cos.loghandler.url");
if (logUrl != null && Boolean.parseBoolean(ResourceUtils.getProperty("cos.loghandler.enabled", "true"))) {
int nThread = ResourceUtils.getInt("cos.loghandler.threads", 1);
int capacity = ResourceUtils.getInt("cos.loghandler.queueSize", 1000);
logHandleExecutor = new ThreadPoolExecutor(nThread, nThread, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(capacity), new StandardThreadFactory("cosLogHandleExecutor"));
logger.info("init logHandleExecutor OK ,nThread:{},queue:{}", nThread, capacity);
}
}
Aggregations