mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
polish #761 update pkg name & maven coordinate for Greenwich
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss;
|
||||
package com.alibaba.alicloud.oss;
|
||||
|
||||
import java.util.Map;
|
||||
|
@@ -14,16 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss;
|
||||
package com.alibaba.alicloud.oss;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.alicloud.oss.resource.OssStorageProtocolResolver;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.alicloud.oss.resource.OssStorageProtocolResolver;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
|
||||
/**
|
||||
* OSS Auto {@link Configuration}
|
||||
*
|
||||
@@ -34,10 +36,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConditionalOnProperty(name = OssConstants.ENABLED, havingValue = "true", matchIfMissing = true)
|
||||
public class OssAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OssStorageProtocolResolver ossStorageProtocolResolver() {
|
||||
return new OssStorageProtocolResolver();
|
||||
}
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OssStorageProtocolResolver ossStorageProtocolResolver() {
|
||||
return new OssStorageProtocolResolver();
|
||||
}
|
||||
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss;
|
||||
package com.alibaba.alicloud.oss;
|
||||
|
||||
/**
|
||||
* OSS constants
|
||||
@@ -23,7 +23,7 @@ package org.springframework.cloud.alicloud.oss;
|
||||
*/
|
||||
public interface OssConstants {
|
||||
|
||||
String PREFIX = "spring.cloud.alibaba.oss";
|
||||
String ENABLED = PREFIX + ".enabled";
|
||||
String PREFIX = "spring.cloud.alibaba.oss";
|
||||
String ENABLED = PREFIX + ".enabled";
|
||||
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.alicloud.oss.endpoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
|
||||
/**
|
||||
* Actuator {@link Endpoint} to expose OSS Meta Data
|
||||
*
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
||||
@Endpoint(id = "oss")
|
||||
public class OssEndpoint {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@ReadOperation
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
Map<String, OSSClient> ossClientMap = applicationContext
|
||||
.getBeansOfType(OSSClient.class);
|
||||
|
||||
int size = ossClientMap.size();
|
||||
|
||||
List<Object> ossClientList = new ArrayList<>();
|
||||
|
||||
ossClientMap.keySet().forEach(beanName -> {
|
||||
Map<String, Object> ossProperties = new HashMap<>();
|
||||
OSSClient client = ossClientMap.get(beanName);
|
||||
ossProperties.put("beanName", beanName);
|
||||
ossProperties.put("endpoint", client.getEndpoint().toString());
|
||||
ossProperties.put("clientConfiguration", client.getClientConfiguration());
|
||||
ossProperties.put("credentials",
|
||||
client.getCredentialsProvider().getCredentials());
|
||||
ossProperties.put("bucketList", client.listBuckets().stream()
|
||||
.map(bucket -> bucket.getName()).toArray());
|
||||
ossClientList.add(ossProperties);
|
||||
});
|
||||
|
||||
result.put("size", size);
|
||||
result.put("info", ossClientList);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss.endpoint;
|
||||
package com.alibaba.alicloud.oss.endpoint;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss.resource;
|
||||
package com.alibaba.alicloud.oss.resource;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss.resource;
|
||||
package com.alibaba.alicloud.oss.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -35,7 +35,8 @@ import com.aliyun.oss.model.OSSObject;
|
||||
|
||||
/**
|
||||
* Implements {@link Resource} for reading and writing objects in Aliyun Object Storage
|
||||
* Service (OSS). An instance of this class represents a handle to a bucket or an OSSObject.
|
||||
* Service (OSS). An instance of this class represents a handle to a bucket or an
|
||||
* OSSObject.
|
||||
*
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
* @see OSS
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alicloud.oss.endpoint;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Actuator {@link Endpoint} to expose OSS Meta Data
|
||||
*
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
||||
@Endpoint(id = "oss")
|
||||
public class OssEndpoint {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@ReadOperation
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
Map<String, OSSClient> ossClientMap = applicationContext
|
||||
.getBeansOfType(OSSClient.class);
|
||||
|
||||
int size = ossClientMap.size();
|
||||
|
||||
List<Object> ossClientList = new ArrayList<>();
|
||||
|
||||
ossClientMap.keySet().forEach(beanName -> {
|
||||
Map<String, Object> ossProperties = new HashMap<>();
|
||||
OSSClient client = ossClientMap.get(beanName);
|
||||
ossProperties.put("beanName", beanName);
|
||||
ossProperties.put("endpoint", client.getEndpoint().toString());
|
||||
ossProperties.put("clientConfiguration", client.getClientConfiguration());
|
||||
ossProperties.put("credentials",
|
||||
client.getCredentialsProvider().getCredentials());
|
||||
ossProperties.put("bucketList", client.listBuckets().stream()
|
||||
.map(bucket -> bucket.getName()).toArray());
|
||||
ossClientList.add(ossProperties);
|
||||
});
|
||||
|
||||
result.put("size", size);
|
||||
result.put("info", ossClientList);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.alicloud.oss.OssAutoConfiguration,\
|
||||
org.springframework.cloud.alicloud.oss.endpoint.OssEndpointAutoConfiguration
|
||||
com.alibaba.alicloud.oss.OssAutoConfiguration,\
|
||||
com.alibaba.alicloud.oss.endpoint.OssEndpointAutoConfiguration
|
||||
org.springframework.context.ApplicationListener=\
|
||||
org.springframework.cloud.alicloud.oss.OssApplicationListener
|
||||
com.alibaba.alicloud.oss.OssApplicationListener
|
Reference in New Issue
Block a user