1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

format code with maven plugins

This commit is contained in:
fangjian0423
2019-09-26 17:15:41 +08:00
parent ed6942d9df
commit 2435167e1e
529 changed files with 6304 additions and 5164 deletions

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -18,16 +18,16 @@ package com.alibaba.alicloud.oss;
import java.util.Map;
import com.aliyun.oss.OSS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import com.aliyun.oss.OSS;
/**
* Shutdown All OSS Clients when {@code ApplicationContext} gets closed
* {@link ApplicationListener}
* {@link ApplicationListener}.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/
@@ -46,4 +46,5 @@ public class OssApplicationListener implements ApplicationListener<ContextClosed
ossClientMap.get(beanName).shutdown();
});
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -16,29 +16,31 @@
package com.alibaba.alicloud.oss;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import com.alibaba.alicloud.oss.resource.OssStorageProtocolResolver;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.alibaba.alicloud.oss.resource.OssStorageProtocolResolver;
import com.aliyun.oss.OSS;
import org.springframework.context.annotation.Lazy;
import java.util.concurrent.*;
import static com.alibaba.alicloud.oss.OssConstants.OSS_TASK_EXECUTOR_BEAN_NAME;
/**
* OSS Auto {@link Configuration}
* OSS Auto {@link Configuration}.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/
@Configuration
@ConditionalOnClass(OSS.class)
@ConditionalOnProperty(name = OssConstants.ENABLED, havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(name = OssConstants.ENABLED, havingValue = "true",
matchIfMissing = true)
public class OssAutoConfiguration {
@Bean

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -17,15 +17,29 @@
package com.alibaba.alicloud.oss;
/**
* OSS constants
* OSS constants.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/
public interface OssConstants {
public final class OssConstants {
String PREFIX = "spring.cloud.alibaba.oss";
String ENABLED = PREFIX + ".enabled";
/**
* Prefix of OSSConfigurationProperties.
*/
public static final String PREFIX = "spring.cloud.alibaba.oss";
String OSS_TASK_EXECUTOR_BEAN_NAME = "ossTaskExecutor";
/**
* Enable OSS.
*/
public static final String ENABLED = PREFIX + ".enabled";
/**
* OSS ThreadPool bean name.
*/
public static final String OSS_TASK_EXECUTOR_BEAN_NAME = "ossTaskExecutor";
private OssConstants() {
throw new AssertionError("Must not instantiate constant utility class");
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -21,15 +21,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
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 com.aliyun.oss.OSSClient;
/**
* Actuator {@link Endpoint} to expose OSS Meta Data
* Actuator {@link Endpoint} to expose OSS Meta Data.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* OSS {@link Endpoint} Auto-{@link Configuration}
* OSS {@link Endpoint} Auto-{@link Configuration}.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
*/

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -16,8 +16,10 @@
package com.alibaba.alicloud.oss.resource;
import com.aliyun.oss.OSS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -27,8 +29,6 @@ import org.springframework.core.io.ProtocolResolver;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import com.aliyun.oss.OSS;
/**
* A {@link ProtocolResolver} implementation for the {@code oss://} protocol.
*
@@ -37,6 +37,9 @@ import com.aliyun.oss.OSS;
public class OssStorageProtocolResolver
implements ProtocolResolver, BeanFactoryPostProcessor, ResourceLoaderAware {
/**
* protocol of oss resource.
*/
public static final String PROTOCOL = "oss://";
private static final Logger log = LoggerFactory
@@ -82,4 +85,5 @@ public class OssStorageProtocolResolver
throws BeansException {
this.beanFactory = beanFactory;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-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
* https://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,
@@ -16,6 +16,18 @@
package com.alibaba.alicloud.oss.resource;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSException;
@@ -23,17 +35,12 @@ import com.aliyun.oss.model.Bucket;
import com.aliyun.oss.model.OSSObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.WritableResource;
import org.springframework.util.Assert;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import static com.alibaba.alicloud.oss.OssConstants.OSS_TASK_EXECUTOR_BEAN_NAME;
/**
@@ -48,25 +55,32 @@ import static com.alibaba.alicloud.oss.OssConstants.OSS_TASK_EXECUTOR_BEAN_NAME;
*/
public class OssStorageResource implements WritableResource {
private static final Logger logger = LoggerFactory.getLogger(OssStorageResource.class);
private static final Logger logger = LoggerFactory
.getLogger(OssStorageResource.class);
private static final String MESSAGE_KEY_NOT_EXIST = "The specified key does not exist.";
private final OSS oss;
private final String bucketName;
private final String objectKey;
private final URI location;
private final boolean autoCreateFiles;
private final ExecutorService ossTaskExecutor;
private final ConfigurableListableBeanFactory beanFactory;
public OssStorageResource(OSS oss, String location, ConfigurableListableBeanFactory beanFactory) {
this(oss, location, beanFactory,false);
}
public OssStorageResource(OSS oss, String location,
ConfigurableListableBeanFactory beanFactory) {
this(oss, location, beanFactory, false);
}
public OssStorageResource(OSS oss, String location,ConfigurableListableBeanFactory beanFactory, boolean autoCreateFiles) {
public OssStorageResource(OSS oss, String location,
ConfigurableListableBeanFactory beanFactory, boolean autoCreateFiles) {
Assert.notNull(oss, "Object Storage Service can not be null");
Assert.isTrue(location.startsWith(OssStorageProtocolResolver.PROTOCOL),
"Location must start with " + OssStorageProtocolResolver.PROTOCOL);
@@ -89,7 +103,8 @@ public class OssStorageResource implements WritableResource {
throw new IllegalArgumentException("Invalid location: " + location, e);
}
this.ossTaskExecutor = this.beanFactory.getBean(OSS_TASK_EXECUTOR_BEAN_NAME, ExecutorService.class);
this.ossTaskExecutor = this.beanFactory.getBean(OSS_TASK_EXECUTOR_BEAN_NAME,
ExecutorService.class);
}
public boolean isAutoCreateFiles() {
@@ -219,7 +234,7 @@ public class OssStorageResource implements WritableResource {
/**
* create a bucket.
* @return
* @return OSS Bucket
*/
public Bucket createBucket() {
return this.oss.createBucket(this.bucketName);
@@ -231,10 +246,10 @@ public class OssStorageResource implements WritableResource {
}
/**
* acquire an OutputStream for write.
* Note: please close the stream after writing is done
* @return
* @throws IOException
* acquire an OutputStream for write. Note: please close the stream after writing is
* done
* @return OutputStream of OSS resource
* @throws IOException throw by oss operation
*/
@Override
public OutputStream getOutputStream() throws IOException {