├── .mvn ├── jvm.config ├── maven.config └── wrapper │ └── maven-wrapper.properties ├── aliyun-spring-boot-samples ├── aliyun-oss-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── oss-test.json │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── examples │ │ │ └── oss │ │ │ └── OssApplication.java │ └── pom.xml ├── aliyun-compileflow-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── examples │ │ │ └── compileflow │ │ │ ├── mock │ │ │ ├── KtvService.java │ │ │ └── MockJavaClazz.java │ │ │ └── CompileflowApplication.java │ ├── pom.xml │ └── README_zh.md ├── aliyun-sms-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── examples │ │ │ └── sms │ │ │ ├── SmsApplication.java │ │ │ ├── SmsUpMessageListener.java │ │ │ └── SmsReportMessageListener.java │ └── pom.xml ├── aliyun-redis-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── examples │ │ │ └── redis │ │ │ ├── RedisApplication.java │ │ │ └── RedisController.java │ └── pom.xml ├── aliyun-schedulerx-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── log4j2.xml │ │ │ └── application.yml │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── examples │ │ │ └── schedulerx │ │ │ ├── SchedulerxApplication.java │ │ │ ├── domain │ │ │ ├── PageTask.java │ │ │ ├── Record.java │ │ │ ├── OrderInfo.java │ │ │ ├── ParallelAccountInfo.java │ │ │ └── AccountInfo.java │ │ │ └── job │ │ │ ├── ShardingJob.java │ │ │ ├── SleepJob.java │ │ │ ├── SimpleJob.java │ │ │ ├── KillJob.java │ │ │ ├── MapReduceJob.java │ │ │ ├── BroadcastJob.java │ │ │ └── ParallelJob.java │ └── pom.xml ├── aliyun-rds-spring-boot-sample │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── application.properties │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── examples │ │ │ └── rds │ │ │ ├── RdsApplication.java │ │ │ └── Order.java │ ├── README-zh.md │ └── pom.xml ├── aliyun-fc-spring-boot-sample │ ├── s.yaml │ └── README.md └── pom.xml ├── aliyun-spring-boot-starters ├── aliyun-compileflow-spring-boot-starter │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── compileflow │ │ │ ├── actuate │ │ │ ├── CompileflowEndpoint.java │ │ │ └── autoconfigure │ │ │ │ └── CompileflowEndpointAutoConfiguration.java │ │ │ └── env │ │ │ └── CompileflowProperties.java │ └── pom.xml ├── aliyun-rds-spring-boot-starter │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── META-INF │ │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alibaba │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── boot │ │ │ │ ├── ds │ │ │ │ └── autocofigure │ │ │ │ │ └── RdsAutoConfiguration.java │ │ │ │ └── rds │ │ │ │ └── env │ │ │ │ ├── RDSConstants.java │ │ │ │ └── RdsProperties.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── rds │ │ │ └── actuate │ │ │ └── autoconfigure │ │ │ └── RdsEndpointAutoConfigurationTest.java │ └── pom.xml ├── aliyun-redis-spring-boot-starter │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── META-INF │ │ │ │ │ ├── spring.factories │ │ │ │ │ └── redis │ │ │ │ │ └── default │ │ │ │ │ └── actuator-endpoints.properties │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── alibaba │ │ │ │ └── cloud │ │ │ │ └── spring │ │ │ │ └── boot │ │ │ │ └── redis │ │ │ │ ├── autocofigure │ │ │ │ └── RedisAutoConfiguration.java │ │ │ │ ├── env │ │ │ │ └── RedisProperties.java │ │ │ │ └── actuate │ │ │ │ └── endpoint │ │ │ │ ├── RedisDescribeAccountsEndpoint.java │ │ │ │ ├── RedisDescribeAvailableResourceEndpoint.java │ │ │ │ ├── RedisDescribeInstancesEndpoint.java │ │ │ │ └── AbstractRedisEndpoint.java │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── redis │ │ │ └── actuate │ │ │ └── autoconfigure │ │ │ └── RedisEndpointAutoConfigurationTest.java │ └── pom.xml ├── aliyun-context-spring-boot-starter │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── context │ │ │ ├── autoconfigure │ │ │ ├── AliCloudContextAutoConfiguration.java │ │ │ └── EdasContextAutoConfiguration.java │ │ │ ├── condition │ │ │ ├── ConditionalOnRequiredProperties.java │ │ │ ├── ConditionalOnRequiredProperty.java │ │ │ ├── ConditionalOnAliCloudEndpoint.java │ │ │ ├── OnRequiredPropertiesCondition.java │ │ │ ├── OnAliCloudEndpointCondition.java │ │ │ └── OnRequiredPropertyCondition.java │ │ │ └── env │ │ │ ├── EdasProperties.java │ │ │ └── AliCloudProperties.java │ └── pom.xml ├── aliyun-sms-spring-boot-starter │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── sms │ │ │ ├── SmsUpMessageListener.java │ │ │ ├── SmsReportMessageListener.java │ │ │ ├── base │ │ │ ├── MessageListener.java │ │ │ ├── QueryTokenForMnsQueueResponseUnmarshaller.java │ │ │ ├── QueryTokenForMnsQueueRequest.java │ │ │ └── TokenForAlicom.java │ │ │ ├── SmsMessageListener.java │ │ │ ├── actuate │ │ │ ├── SmsEndpoint.java │ │ │ ├── autoconfigure │ │ │ │ └── SmsEndpointAutoConfiguration.java │ │ │ └── ReceiveMessageEntity.java │ │ │ ├── autoconfigure │ │ │ ├── SmsContextAutoConfiguration.java │ │ │ └── SmsAutoConfiguration.java │ │ │ ├── AbstractSmsService.java │ │ │ ├── env │ │ │ └── SmsProperties.java │ │ │ └── ISmsService.java │ └── pom.xml ├── aliyun-oss-spring-boot-starter │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── oss │ │ │ ├── OssConstants.java │ │ │ ├── actuate │ │ │ ├── autoconfigure │ │ │ │ └── OssEndpointAutoConfiguration.java │ │ │ └── OssEndpoint.java │ │ │ ├── context │ │ │ └── OssApplicationListener.java │ │ │ ├── autoconfigure │ │ │ └── OssAutoConfiguration.java │ │ │ └── resource │ │ │ └── OssStorageProtocolResolver.java │ └── pom.xml ├── aliyun-fc-spring-boot-starter │ ├── README.md │ └── src │ │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── alibaba │ │ │ └── cloud │ │ │ └── spring │ │ │ └── boot │ │ │ └── fc │ │ │ ├── User.java │ │ │ └── TestMain.java │ │ └── main │ │ └── java │ │ └── com │ │ └── alibaba │ │ └── cloud │ │ └── spring │ │ └── boot │ │ └── fc │ │ ├── InputOutputFunction.java │ │ ├── InputOutputPair.java │ │ ├── RequestResponsePair.java │ │ ├── RequestResponseFunction.java │ │ ├── StreamRequestFCSpringFunctionInvoker.java │ │ ├── Pair.java │ │ └── HttpRequestFCSpringFunctionInvoker.java ├── pom.xml └── aliyun-schedulerx-spring-boot-starter │ └── pom.xml ├── .github └── ISSUE_TEMPLATE │ ├── question.md │ ├── feature_request.md │ └── issue-report.md ├── .gitignore └── aliyun-spring-boot-docs ├── pom.xml └── asciidoc-zh └── rds.adoc /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-oss-spring-boot-sample/src/main/resources/oss-test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oss-test" 3 | } -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-compileflow-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.alibaba.cloud.spring.boot.compileflow.autoconfigure.CompileflowAutoConfiguration -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alibaba.cloud.spring.boot.ds.autocofigure.RdsAutoConfiguration,\ 3 | com.alibaba.cloud.spring.boot.rds.actuate.autoconfigure.RdsEndpointAutoConfiguration -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alibaba.cloud.spring.boot.redis.autocofigure.RedisAutoConfiguration,\ 3 | com.alibaba.cloud.spring.boot.redis.actuate.autoconfigure.RedisEndpointAutoConfiguration -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alibaba.cloud.spring.boot.context.autoconfigure.AliCloudContextAutoConfiguration,\ 3 | com.alibaba.cloud.spring.boot.context.autoconfigure.EdasContextAutoConfiguration -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-oss-spring-boot-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=aliyun-spring-boot-oss-sample 2 | 3 | server.port=18084 4 | 5 | alibaba.cloud.access-key=AK 6 | alibaba.cloud.secret-key=SK 7 | alibaba.cloud.oss.endpoint=***.aliyuncs.com 8 | 9 | management.endpoints.web.exposure.include=* 10 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alibaba.cloud.spring.boot.sms.autoconfigure.SmsAutoConfiguration,\ 3 | com.alibaba.cloud.spring.boot.sms.autoconfigure.SmsContextAutoConfiguration,\ 4 | com.alibaba.cloud.spring.boot.sms.actuate.autoconfigure.SmsEndpointAutoConfiguration -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Spring Boot properties 2 | spring.application.name=aliyun-spring-boot-compileflow-sample 3 | server.port=9011 4 | # Spring Boot Actuator 5 | management.endpoints.web.exposure.include=* 6 | # Aliyun Compileflow properties 7 | alibaba.cloud.compileflow.precompile=true 8 | alibaba.cloud.compileflow.precompile-process-files=bpm/ktv/ktvExample.bpm 9 | alibaba.cloud.compileflow.precompile-process-dirs=bpmn20 -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.alibaba.cloud.spring.boot.oss.autoconfigure.OssAutoConfiguration,\ 3 | com.alibaba.cloud.spring.boot.oss.autoconfigure.OssContextAutoConfiguration,\ 4 | com.alibaba.cloud.spring.boot.oss.actuate.autoconfigure.OssEndpointAutoConfiguration 5 | 6 | org.springframework.context.ApplicationListener=\ 7 | com.alibaba.cloud.spring.boot.oss.context.OssApplicationListener -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/compileflow/mock/KtvService.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.cloud.spring.boot.examples.compileflow.mock; 2 | 3 | /** 4 | * @author yusu 5 | */ 6 | public class KtvService { 7 | 8 | public void sing(String name) { 9 | System.out.println(name + " is singing"); 10 | } 11 | 12 | public void payMoney(int price) { 13 | System.out.println("actually paid money: " + price); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: 'Ask your question after you try ' 4 | title: "[Question]" 5 | labels: help wanted 6 | assignees: '' 7 | 8 | --- 9 | 10 | 我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。 11 | We recommend using English. If you are non-native English speaker, you can use the translation software. 12 | 13 | **Describe what problem you have encountered** 14 | A clear and concise description of what you want to do. 15 | 16 | **Describe what information you have read** 17 | eg. I have read the reference doc of Sentinel 18 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/README.md: -------------------------------------------------------------------------------- 1 | This project provides an adapter layer for a Spring Cloud Function application onto [Alibaba Cloud Funtion Compute](https://www.alibabacloud.com/help/doc-detail/52895.html). You can write an app with a single @Bean of type Function and it will be deployable in Alibaba Cloud if you get the JAR file laid out right. 2 | 3 | ## Sample Function 4 | 5 | Go to the [aliyun-fc-spring-boot-sample](https://github.com/alibaba/aliyun-spring-boot/tree/master/aliyun-spring-boot-samples/aliyun-fc-spring-boot-sample) to learn about how the sample works, and how to run and test it. -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-sms-spring-boot-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Spring Boot properties 2 | spring.application.name=aliyun-spring-boot-sms-sample 3 | server.port=9051 4 | 5 | # Spring Boot Actuator 6 | management.endpoints.web.exposure.include=* 7 | 8 | # Aliyun SMS properties 9 | alibaba.cloud.access-key=***** 10 | alibaba.cloud.secret-key=****** 11 | alibaba.cloud.sms.report-queue-name=***** 12 | alibaba.cloud.sms.up-queue-name=***** 13 | 14 | # The value of placeholders using in the sample 15 | sample.phone-number = ********* 16 | sample.sign-name = ********* 17 | sample.template-code = ******* -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | *.classpath 4 | *.factorypath 5 | .flattened-pom.xml 6 | 7 | # Log file 8 | *.log 9 | 10 | # BlueJ files 11 | *.ctxt 12 | 13 | # Mobile Tools for Java (J2ME) 14 | .mtj.tmp/ 15 | 16 | # Package Files # 17 | *.jar 18 | *.war 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | # IDE Files # 28 | *.iml 29 | .idea 30 | .idea/ 31 | .project 32 | .settings 33 | target 34 | .DS_Store 35 | /aliyun-spring-boot-samples/aliyun-fc-spring-boot-sample/.fun/ 36 | /aliyun-spring-boot-samples/aliyun-fc-spring-boot-sample/.s/ 37 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/resources/META-INF/redis/default/actuator-endpoints.properties: -------------------------------------------------------------------------------- 1 | # The default properties for Alibaba Cloud Redis Endpoints 2 | 3 | # Enabled Status 4 | management.endpoint.redisDescribeAvailableResource.enabled = true 5 | management.endpoint.redisDescribeAccounts.enabled = false 6 | management.endpoint.redisDescribeInstances.enabled = true 7 | 8 | # Path Mappings 9 | management.endpoints.web.path-mapping.redisDescribeAvailableResource = redis/describe-available-resource 10 | management.endpoints.web.path-mapping.redisDescribeAccounts = redis/describe-accounts 11 | management.endpoints.web.path-mapping.redisDescribeInstances = redis/describe-instances -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature]" 5 | labels: Feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-redis-spring-boot-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Spring Boot properties 2 | spring.application.name= aliyun-redis-spring-boot-sample 3 | server.port = 9090 4 | 5 | ## Specify the DNS URI of your Redis cache. 6 | spring.redis.host=r-***.redis.rds.aliyuncs.com 7 | ## Specify the port for your Redis cache. 8 | spring.redis.port=**** 9 | ## Specify the access key for your Redis cache. 10 | spring.redis.password=****** 11 | 12 | # Spring Boot Actuator properties 13 | management.endpoints.web.exposure.include=* 14 | management.endpoint.redisdescribeavailableresource.enabled=true 15 | management.endpoint.redisDescribeAccounts.enabled=true 16 | 17 | # Aliyun Redis properties 18 | alibaba.cloud.access-key=***** 19 | alibaba.cloud.secret-key=****** 20 | alibaba.cloud.redis.instance-id=r-******** 21 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/SmsUpMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms; 18 | 19 | /** 20 | * @author pbting 21 | */ 22 | public interface SmsUpMessageListener extends SmsMessageListener { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/SmsReportMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms; 18 | 19 | /** 20 | * @author pbting 21 | */ 22 | public interface SmsReportMessageListener extends SmsMessageListener { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/base/MessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.base; 18 | 19 | import com.aliyun.mns.model.Message; 20 | 21 | public interface MessageListener { 22 | 23 | boolean dealMessage(Message message); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue report 3 | about: Create a report to help us improve 4 | title: "[ISSUE] " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/SmsMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms; 18 | 19 | 20 | import com.alibaba.cloud.spring.boot.sms.base.MessageListener; 21 | 22 | /** 23 | * @author pbting 24 | */ 25 | public interface SmsMessageListener extends MessageListener { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/compileflow/mock/MockJavaClazz.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.cloud.spring.boot.examples.compileflow.mock; 2 | 3 | /** 4 | * @author yusu 5 | */ 6 | public class MockJavaClazz { 7 | 8 | public void mockJavaMethod(int num) { 9 | System.out.println("java: number is " + num); 10 | } 11 | 12 | public void mockJavaMethod(long num) { 13 | System.out.println("spring-bean: number is " + num); 14 | } 15 | 16 | public int mockReturnMethod(int num) { 17 | System.out.println("java: minus 100"); 18 | return num - 100; 19 | } 20 | 21 | public void doException() { 22 | throw new RuntimeException("mock exception"); 23 | } 24 | 25 | public void mockMonitorMethod(Throwable e) { 26 | if (e != null) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | public int calPrice(int num) { 32 | System.out.println("total price: " + 30 * num); 33 | return 30 * num; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-compileflow-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/compileflow/actuate/CompileflowEndpoint.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.cloud.spring.boot.compileflow.actuate; 2 | 3 | import com.alibaba.cloud.spring.boot.compileflow.env.CompileflowProperties; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 6 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author yusu 13 | */ 14 | @Endpoint(id = "compileflow") 15 | public class CompileflowEndpoint { 16 | 17 | @Autowired 18 | private CompileflowProperties compileflowProperties; 19 | 20 | @ReadOperation 21 | public Map invoke() { 22 | Map result = new HashMap(); 23 | result.put("version", this.getClass().getPackage().getImplementationVersion()); 24 | result.put("properties", this.compileflowProperties); 25 | return result; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-rds-spring-boot-sample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Spring Boot properties 2 | spring.application.name= aliyun-rds-spring-boot-sample 3 | server.port = 9090 4 | 5 | # Spring Boot Actuator properties 6 | management.endpoints.web.exposure.include=* 7 | 8 | # Aliyun properties 9 | alibaba.cloud.access-key=****** 10 | alibaba.cloud.secret-key=****** 11 | 12 | # RDS控制台:https://rdsnext.console.aliyun.com 13 | # 数据源名称 14 | spring.datasource.name=defaultDataSource 15 | 16 | # 数据库连接地址: 17 | spring.datasource.url=jdbc:mysql://localhost:3306/test_db?serverTimezone=UTC 18 | 19 | # 数据库用户名&密码: 20 | # 请在控制台中,对应数据库实例的"账号管理"功能下维护 21 | spring.datasource.username=****** 22 | spring.datasource.password=****** 23 | 24 | # 数据库驱动: 25 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 26 | 27 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 28 | spring.datasource.druid.name=defaultDataSource 29 | spring.datasource.druid.max-active=20 30 | spring.datasource.druid.min-idle=2 31 | spring.datasource.druid.initial-size=2 32 | 33 | # spring boot 文档参考:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/ -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/test/java/com/alibaba/cloud/spring/boot/fc/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | import lombok.NoArgsConstructor; 21 | 22 | /** 23 | * @author theonefx 24 | */ 25 | @Data 26 | @NoArgsConstructor 27 | @AllArgsConstructor 28 | public class User { 29 | private Long id; 30 | private String name; 31 | } 32 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-sms-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/sms/SmsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.sms; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * 24 | */ 25 | @SpringBootApplication 26 | public class SmsApplication { 27 | 28 | public static void main(String[] args) throws Exception { 29 | SpringApplication.run(SmsApplication.class, args); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/actuate/SmsEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.actuate; 18 | 19 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 20 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 21 | 22 | import java.util.Map; 23 | 24 | @Endpoint(id = "sms") 25 | public class SmsEndpoint { 26 | 27 | @ReadOperation 28 | public Map invoke() { 29 | 30 | return EndpointManager.getSmsEndpointMessage(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /aliyun-spring-boot-docs/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-parent 10 | ${revision} 11 | ../aliyun-spring-boot-parent/pom.xml 12 | 13 | 14 | aliyun-spring-boot-docs 15 | pom 16 | 17 | Aliyun Spring Boot :: Docs 18 | Spring Boot Documents for Aliyun Services 19 | 20 | 21 | 22 | 23 | org.apache.maven.plugins 24 | maven-deploy-plugin 25 | ${maven-deploy-plugin.version} 26 | 27 | true 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/InputOutputFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import java.io.InputStream; 19 | import java.io.OutputStream; 20 | import java.util.function.Consumer; 21 | 22 | /** 23 | * @author theonefx 24 | */ 25 | public interface InputOutputFunction extends Consumer { 26 | 27 | @Override 28 | default void accept(InputOutputPair pair) { 29 | apply(pair.getKey(), pair.getValue()); 30 | } 31 | 32 | void apply(InputStream in, OutputStream out); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-rds-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/rds/RdsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.rds; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * The bootstrap for Aliyun RDS Spring Boot. 24 | * 25 | * @author theonefx 26 | */ 27 | @SpringBootApplication 28 | public class RdsApplication { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(RdsApplication.class, args); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/InputOutputPair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import java.io.InputStream; 19 | import java.io.OutputStream; 20 | 21 | /** 22 | * @author theonefx 23 | */ 24 | class InputOutputPair extends Pair { 25 | 26 | /** 27 | * Creates a new pair 28 | * 29 | * @param key The key for this pair 30 | * @param value The value to use for this pair 31 | */ 32 | public InputOutputPair(InputStream key, OutputStream value) { 33 | super(key, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-fc-spring-boot-sample/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 1.0.0 2 | name: helloscf 3 | access: default 4 | vars: 5 | region: cn-shanghai 6 | services: 7 | fc-helloscf-fcspring: 8 | component: devsapp/fc 9 | actions: 10 | pre-deploy: 11 | - run: mvn package -DskipTests 12 | path: ./ 13 | pre-local: 14 | - run: mvn package -DskipTests 15 | path: ./ 16 | props: 17 | region: ${vars.region} 18 | service: 19 | name: helloscf 20 | description: hello alibaba function compute 21 | internetAccess: true 22 | function: 23 | name: fcspring 24 | handler: >- 25 | com.alibaba.cloud.spring.boot.fc.StreamRequestFCSpringFunctionInvoker::handleRequest 26 | timeout: 60 27 | memorySize: 512 28 | runtime: java8 29 | environmentVariables: 30 | SCF_FUNC_NAME: uppercase 31 | codeUri: target/deploy/aliyun-fc-spring-boot-sample-1.0.1-SNAPSHOT-fc.jar 32 | triggers: 33 | - name: string 34 | type: http 35 | config: 36 | authType: anonymous 37 | methods: 38 | - GET 39 | - POST 40 | customDomains: 41 | - domainName: auto 42 | protocol: HTTP 43 | routeConfigs: 44 | - path: /* 45 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-sms-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/sms/SmsUpMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.sms; 18 | 19 | import com.aliyun.mns.model.Message; 20 | import org.springframework.stereotype.Component; 21 | 22 | /** 23 | * @author 如果发送的短信需要接收对方回复的状态消息,只需实现该接口并初始化一个 Spring Bean 即可。 24 | */ 25 | @Component 26 | public class SmsUpMessageListener implements com.alibaba.cloud.spring.boot.sms.SmsUpMessageListener { 27 | 28 | @Override 29 | public boolean dealMessage(Message message) { 30 | System.err.println(this.getClass().getName() + "; " + message.toString()); 31 | return true; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/SchedulerxApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.context.annotation.ComponentScan; 22 | 23 | /** 24 | * SchedulerxApplication. 25 | * 26 | * @author xiaomeng.hxm 27 | */ 28 | @SpringBootApplication 29 | @ComponentScan(value="com.alibaba.schedulerx.*") 30 | public class SchedulerxApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(SchedulerxApplication.class, args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-spring-boot-starters 16 | pom 17 | 18 | Aliyun Spring Boot :: Starters 19 | Spring Boot Starters for Aliyun Services 20 | 21 | 22 | aliyun-context-spring-boot-starter 23 | aliyun-oss-spring-boot-starter 24 | aliyun-schedulerx-spring-boot-starter 25 | aliyun-sms-spring-boot-starter 26 | aliyun-redis-spring-boot-starter 27 | aliyun-rds-spring-boot-starter 28 | aliyun-compileflow-spring-boot-starter 29 | aliyun-fc-spring-boot-starter 30 | 31 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/RequestResponsePair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.servlet.http.HttpServletResponse; 20 | 21 | /** 22 | * @author theonefx 23 | */ 24 | class RequestResponsePair extends Pair { 25 | 26 | /** 27 | * Creates a new pair 28 | * 29 | * @param key The key for this pair 30 | * @param value The value to use for this pair 31 | */ 32 | public RequestResponsePair(HttpServletRequest key, HttpServletResponse value) { 33 | super(key, value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/RequestResponseFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import java.util.function.Consumer; 19 | import javax.servlet.http.HttpServletRequest; 20 | import javax.servlet.http.HttpServletResponse; 21 | 22 | /** 23 | * @author theonefx 24 | */ 25 | public interface RequestResponseFunction extends Consumer> { 26 | 27 | @Override 28 | default void accept(Pair pair) { 29 | apply(pair.getKey(), pair.getValue()); 30 | } 31 | 32 | void apply(HttpServletRequest in, HttpServletResponse out); 33 | } 34 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-compileflow-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/compileflow/actuate/autoconfigure/CompileflowEndpointAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.alibaba.cloud.spring.boot.compileflow.actuate.autoconfigure; 2 | 3 | import com.alibaba.cloud.spring.boot.compileflow.actuate.CompileflowEndpoint; 4 | import com.alibaba.cloud.spring.boot.compileflow.env.CompileflowProperties; 5 | import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; 6 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | /** 14 | * @author yusu 15 | */ 16 | @Configuration(proxyBeanMethods = false) 17 | @EnableConfigurationProperties(CompileflowProperties.class) 18 | @ConditionalOnClass(Endpoint.class) 19 | public class CompileflowEndpointAutoConfiguration { 20 | 21 | @Bean 22 | @ConditionalOnMissingBean 23 | @ConditionalOnAvailableEndpoint 24 | public CompileflowEndpoint redisDescribeAvailableResourceEndpoint() { 25 | return new CompileflowEndpoint(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/domain/PageTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.domain; 18 | 19 | /** 20 | * 21 | * @author xiaomeng.hxm 22 | */ 23 | public class PageTask { 24 | private String tableName; 25 | private long startId; 26 | private long endId; 27 | 28 | public PageTask(String tableName, long startId, long endId) { 29 | this.tableName = tableName; 30 | this.startId = startId; 31 | this.endId = endId; 32 | } 33 | 34 | public String getTableName() { 35 | return tableName; 36 | } 37 | 38 | public long getStartId() { 39 | return startId; 40 | } 41 | 42 | public long getEndId() { 43 | return endId; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/actuate/autoconfigure/SmsEndpointAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.actuate.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.sms.actuate.SmsEndpoint; 20 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; 23 | import org.springframework.context.annotation.Bean; 24 | 25 | @ConditionalOnWebApplication 26 | @ConditionalOnClass(Endpoint.class) 27 | public class SmsEndpointAutoConfiguration { 28 | 29 | @Bean 30 | public SmsEndpoint smsEndpoint() { 31 | return new SmsEndpoint(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/OssConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss; 18 | 19 | /** 20 | * OSS constants. 21 | * 22 | * @author Jim 23 | */ 24 | public final class OssConstants { 25 | 26 | /** 27 | * Prefix of OSSConfigurationProperties. 28 | */ 29 | public static final String PREFIX = "alibaba.cloud.oss"; 30 | 31 | /** 32 | * Enable OSS. 33 | */ 34 | public static final String ENABLED = PREFIX + ".enabled"; 35 | 36 | /** 37 | * OSS ThreadPool bean name. 38 | */ 39 | public static final String OSS_TASK_EXECUTOR_BEAN_NAME = "ossTaskExecutor"; 40 | 41 | private OssConstants() { 42 | throw new AssertionError("Must not instantiate constant utility class"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-redis-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/redis/RedisApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.examples.redis; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * The bootstrap for Aliyun Redis Spring Boot 24 | * 25 | * @author Mercy 26 | */ 27 | @SpringBootApplication 28 | public class RedisApplication { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(RedisApplication.class, args); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/domain/Record.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.domain; 18 | 19 | /** 20 | * 21 | * @author xiaomeng.hxm 22 | */ 23 | public class Record { 24 | private int id; 25 | private String name; 26 | private String data; 27 | 28 | public int getId() { 29 | return id; 30 | } 31 | 32 | public void setId(int id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public String getData() { 45 | return data; 46 | } 47 | 48 | public void setData(String data) { 49 | this.data = data; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/ds/autocofigure/RdsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.ds.autocofigure; 18 | 19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | import com.alibaba.cloud.spring.boot.rds.env.RDSConstants; 24 | import com.alibaba.cloud.spring.boot.rds.env.RdsProperties; 25 | 26 | 27 | /** 28 | * @author theonefx 29 | */ 30 | @Configuration(proxyBeanMethods = false) 31 | @EnableConfigurationProperties(RdsProperties.class) 32 | @ConditionalOnProperty(RDSConstants.ENABLE) 33 | public class RdsAutoConfiguration { 34 | } 35 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/ShardingJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import org.springframework.stereotype.Component; 20 | 21 | import com.alibaba.schedulerx.worker.domain.JobContext; 22 | import com.alibaba.schedulerx.worker.processor.JavaProcessor; 23 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 24 | 25 | /** 26 | * 分片任务,分布式模型需要选择sharding 27 | * @author xiaomeng.hxm 28 | */ 29 | @Component 30 | public class ShardingJob extends JavaProcessor { 31 | 32 | @Override 33 | public ProcessResult process(JobContext context) throws Exception { 34 | System.out.println("分片id=" + context.getShardingId() + ", 分片参数=" + context.getShardingParameter()); 35 | return new ProcessResult(true); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-fc-spring-boot-sample/README.md: -------------------------------------------------------------------------------- 1 | ## Alibaba Cloud Function Compute Sample Application 2 | 3 | ### Precondition 4 | 5 | Make sure that you have the [Serverless-Devs](https://github.com/Serverless-Devs/Serverless-Devs/blob/master/readme_en.md) installed. 6 | 7 | You must [configure Serverless-Devs](https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/en/command/config.md) before deploy the functions. 8 | 9 | ### Test locally 10 | 11 | Make sure Docker is installed and started in your host. 12 | 13 | Run the function: 14 | 15 | ```bash 16 | s local start 17 | ``` 18 | 19 | Invoke the HTTP function: 20 | 21 | 22 | 23 | ```bash 24 | curl http://localhost:7040 -d 'hello world' 25 | ``` 26 | 27 | ### Deploy to Alibaba Cloud 28 | 29 | Run the following command from the project root to deploy. 30 | 31 | ```bash 32 | s deploy -y 33 | ``` 34 | 35 | Invoke the HTTP function: 36 | 37 | 38 | 39 | ```bash 40 | curl https://fcspring-helloscf-umysuyquaf.REGION_ID.fcapp.run -d "hello world" 41 | 42 | # or 43 | 44 | curl http://fcspring.helloscf.ACCOUNT-ID.REGION_ID.fc.devsapp.net -d "hello world" 45 | ``` 46 | 47 | ### Tips 48 | 49 | The configuration items of `s.yaml` refer [Serverless Devs Description file (YAML) specification](https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/en/yaml.md). 50 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/autocofigure/RedisAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.autocofigure; 18 | 19 | import com.alibaba.cloud.spring.boot.redis.env.RedisProperties; 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | /** 24 | * The Auto-Configuration class for Alibaba Cloud Redis 25 | * 26 | * @author Mercy 27 | * @since 1.0.0 28 | */ 29 | @EnableConfigurationProperties(RedisProperties.class) 30 | @Configuration(proxyBeanMethods = false) 31 | public class RedisAutoConfiguration { 32 | } 33 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/domain/OrderInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.domain; 18 | 19 | /** 20 | * 21 | * @author xiaomeng.hxm 22 | */ 23 | public class OrderInfo { 24 | private String id; 25 | private int value; 26 | 27 | public OrderInfo(String id, int value) { 28 | this.id = id; 29 | this.value = value; 30 | } 31 | 32 | public String getId() { 33 | return id; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | 40 | public int getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(int value) { 45 | this.value = value; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "OrderInfo [id=" + id + ", value=" + value + "]"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/autoconfigure/AliCloudContextAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.context.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | /** 24 | * Auto-Configuration for Alibaba Cloud Context 25 | * 26 | * @author xiaolongzuo 27 | * @author theonefx 28 | */ 29 | @Configuration(proxyBeanMethods = false) 30 | @EnableConfigurationProperties(AliCloudProperties.class) 31 | public class AliCloudContextAutoConfiguration { 32 | } 33 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/test/java/com/alibaba/cloud/spring/boot/fc/TestMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import java.util.function.Function; 19 | 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | import org.springframework.context.annotation.Bean; 23 | 24 | /** 25 | * @author theonefx 26 | */ 27 | @SpringBootApplication 28 | public class TestMain { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(TestMain.class, args); 32 | } 33 | 34 | @Bean 35 | public Function string2string() { 36 | return string -> "receive string:" + string; 37 | } 38 | 39 | @Bean 40 | public Function string2object() { 41 | return string -> new User(0L, "receive string:" + string); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/autoconfigure/SmsContextAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.sms.env.SmsProperties; 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 22 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 23 | import org.springframework.context.annotation.Configuration; 24 | 25 | /** 26 | * @author pbting 27 | * @author xiaolongzuo 28 | */ 29 | @Configuration(proxyBeanMethods = false) 30 | @EnableConfigurationProperties(SmsProperties.class) 31 | @ConditionalOnClass(name = "com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest") 32 | @ConditionalOnProperty(name = "alibaba.cloud.sms.enabled", matchIfMissing = true) 33 | public class SmsContextAutoConfiguration { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/rds/env/RDSConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.rds.env; 18 | 19 | /** 20 | * the rds config contants. 21 | * 22 | * @author theonefx 23 | */ 24 | public final class RDSConstants { 25 | 26 | /** 27 | * The name of module. 28 | */ 29 | public static final String MODULE_NAME = "rds"; 30 | 31 | /** 32 | * Prefix of RDSConfigurationProperties. 33 | */ 34 | public static final String PROPERTY_PREFIX = "alibaba.cloud.rds"; 35 | 36 | /** 37 | * Enable RDS. 38 | */ 39 | public static final String ENABLE = PROPERTY_PREFIX + ".enable"; 40 | 41 | /** 42 | * Prefix of Rds actuator. 43 | */ 44 | public static final String ACTUATOR_PREFIX = PROPERTY_PREFIX + ".actuator"; 45 | 46 | 47 | private RDSConstants() { 48 | throw new AssertionError("Must not instantiate constant utility class"); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-sms-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/sms/SmsReportMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.sms; 18 | 19 | import com.aliyun.mns.model.Message; 20 | import org.springframework.stereotype.Component; 21 | 22 | import java.util.LinkedList; 23 | import java.util.List; 24 | 25 | /** 26 | * @author 如果需要监听短信是否被对方成功接收,只需实现这个接口并初始化一个 Spring Bean 即可。 27 | */ 28 | @Component 29 | public class SmsReportMessageListener implements com.alibaba.cloud.spring.boot.sms.SmsReportMessageListener { 30 | 31 | private List smsReportMessageSet = new LinkedList<>(); 32 | 33 | @Override 34 | public boolean dealMessage(Message message) { 35 | smsReportMessageSet.add(message); 36 | System.err.println(this.getClass().getName() + "; " + message.toString()); 37 | return true; 38 | } 39 | 40 | public List getSmsReportMessageSet() { 41 | 42 | return smsReportMessageSet; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/actuate/autoconfigure/OssEndpointAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss.actuate.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.oss.actuate.OssEndpoint; 20 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | /** 27 | * OSS {@link Endpoint} Auto-{@link Configuration}. 28 | * 29 | * @author Jim 30 | */ 31 | @ConditionalOnClass(Endpoint.class) 32 | public class OssEndpointAutoConfiguration { 33 | 34 | @Bean 35 | @ConditionalOnMissingBean 36 | public OssEndpoint ossEndpoint() { 37 | return new OssEndpoint(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/compileflow/CompileflowApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.examples.compileflow; 18 | 19 | import com.alibaba.cloud.spring.boot.examples.compileflow.mock.KtvService; 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | import org.springframework.context.annotation.Bean; 23 | 24 | /** 25 | * The bootstrap for Aliyun Compileflow Spring Boot 26 | * 27 | * @author yusu 28 | */ 29 | @SpringBootApplication 30 | public class CompileflowApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(CompileflowApplication.class, args); 34 | } 35 | 36 | @Bean 37 | public KtvService ktvService() { 38 | return new KtvService(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/ConditionalOnRequiredProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import org.springframework.context.annotation.Conditional; 20 | 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * The annotation to combine the multiple {@link ConditionalOnRequiredProperty} 29 | * 30 | * @author Mercy 31 | * @since 1.0.0 32 | * @see ConditionalOnRequiredProperty 33 | */ 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Target({ ElementType.METHOD, ElementType.TYPE }) 36 | @Documented 37 | @Conditional(OnRequiredPropertiesCondition.class) 38 | public @interface ConditionalOnRequiredProperties { 39 | 40 | /** 41 | * @return the multiple {@link ConditionalOnRequiredProperty} 42 | */ 43 | ConditionalOnRequiredProperty[] value(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/domain/ParallelAccountInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.domain; 18 | 19 | import com.alibaba.schedulerx.worker.processor.BizSubTask; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | * 并行计算模拟业务对象信息,业务对象需要实现BizSubTask接口 26 | * @author yaohui 27 | * @create 2022/3/16 下午6:14 28 | **/ 29 | public class ParallelAccountInfo implements BizSubTask { 30 | 31 | /** 32 | * 主键 33 | */ 34 | private long id; 35 | 36 | private String name; 37 | 38 | private String accountId; 39 | 40 | public ParallelAccountInfo(long id, String name, String accountId) { 41 | this.id = id; 42 | this.name = name; 43 | this.accountId = accountId; 44 | } 45 | 46 | /** 47 | * 实现labelMap方法,用于设置对应子任务的标签信息 48 | * @return 49 | */ 50 | @Override 51 | public Map labelMap() { 52 | Map labelMap = new HashMap(); 53 | labelMap.put("户名", name); 54 | return labelMap; 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/AbstractSmsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms; 18 | 19 | import com.aliyuncs.DefaultAcsClient; 20 | import com.aliyuncs.IAcsClient; 21 | import com.aliyuncs.profile.DefaultProfile; 22 | 23 | import java.util.concurrent.ConcurrentHashMap; 24 | 25 | /** 26 | * @author pbting 27 | */ 28 | public abstract class AbstractSmsService implements ISmsService { 29 | 30 | private ConcurrentHashMap acsClientConcurrentHashMap = new ConcurrentHashMap<>(); 31 | 32 | @Override 33 | public IAcsClient getHangZhouRegionClientProfile(String accessKeyId, 34 | String accessKeySecret) { 35 | 36 | return acsClientConcurrentHashMap.computeIfAbsent( 37 | getKey("cn-hangzhou", accessKeyId, accessKeySecret), 38 | (iacsClient) -> new DefaultAcsClient(DefaultProfile 39 | .getProfile("cn-hangzhou", accessKeyId, accessKeySecret))); 40 | } 41 | 42 | private String getKey(String regionId, String accessKeyId, String accessKeySecret) { 43 | 44 | return regionId + ":" + accessKeyId + ":" + accessKeySecret; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/SleepJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.stereotype.Component; 22 | 23 | import com.alibaba.schedulerx.worker.domain.JobContext; 24 | import com.alibaba.schedulerx.worker.processor.JavaProcessor; 25 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 26 | 27 | /** 28 | * 单机任务,所有节点随机选一台执行 29 | * @author yaohui 30 | */ 31 | @Component 32 | public class SleepJob extends JavaProcessor { 33 | 34 | /* 35 | * log4j2/logback配置schedulerxLogAppender,可以进行日志采集 36 | */ 37 | private static final Logger logger = LoggerFactory.getLogger("schedulerx"); 38 | 39 | @Override 40 | public ProcessResult process(JobContext context) throws Exception { 41 | System.out.println("this is " + context.getJobName() + ", start to sleep 15s"); 42 | Thread.sleep(15000); 43 | return new ProcessResult(true); 44 | } 45 | 46 | @Override 47 | public void kill(JobContext context) { 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/SimpleJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.stereotype.Component; 22 | 23 | import com.alibaba.schedulerx.worker.domain.JobContext; 24 | import com.alibaba.schedulerx.worker.processor.JavaProcessor; 25 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 26 | 27 | /** 28 | * 单机任务,所有节点随机选一台执行 29 | * @author yaohui 30 | */ 31 | @Component 32 | public class SimpleJob extends JavaProcessor { 33 | 34 | /* 35 | * log4j2/logback配置schedulerxLogAppender,可以进行日志采集 36 | */ 37 | private static final Logger logger = LoggerFactory.getLogger("schedulerx"); 38 | 39 | @Override 40 | public ProcessResult process(JobContext context) throws Exception { 41 | System.out.println("this is process, para=" + context.getJobParameters()); 42 | logger.info("hello schedulerx!"); 43 | return new ProcessResult(true); 44 | } 45 | 46 | @Override 47 | public void kill(JobContext context) { 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/ConditionalOnRequiredProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import org.springframework.context.annotation.Conditional; 20 | import org.springframework.core.env.PropertySources; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Repeatable; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | /** 30 | * {@link Conditional} checks the required property is present or not in the 31 | * {@link PropertySources}. 32 | * 33 | * @author Mercy 34 | * @since 1.0.0 35 | */ 36 | @Retention(RetentionPolicy.RUNTIME) 37 | @Target({ ElementType.METHOD, ElementType.TYPE }) 38 | @Documented 39 | @Conditional(OnRequiredPropertyCondition.class) 40 | @Repeatable(ConditionalOnRequiredProperties.class) 41 | public @interface ConditionalOnRequiredProperty { 42 | 43 | /** 44 | * @return The property name 45 | */ 46 | String value(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/ConditionalOnAliCloudEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import org.springframework.context.annotation.Conditional; 21 | 22 | import java.lang.annotation.Documented; 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * {@link Conditional @Conditional} that checks whether an endpoint of Alibaba Cloud is 30 | * available or not if and only if the properties that are 31 | * "alibaba.cloud.access-key" and "alibaba.cloud.secret-key" must be 32 | * present. 33 | * 34 | * @author Mercy 35 | * @since 1.0.0 36 | * @see OnAliCloudEndpointCondition 37 | * @see AliCloudProperties 38 | */ 39 | @Retention(RetentionPolicy.RUNTIME) 40 | @Target({ ElementType.METHOD, ElementType.TYPE }) 41 | @Documented 42 | @Conditional(OnAliCloudEndpointCondition.class) 43 | public @interface ConditionalOnAliCloudEndpoint { 44 | 45 | } 46 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | schedulerx2: 3 | endpoint: acm.aliyun.com #请填写不同region的endpoint 4 | namespace: 433d8b23-xxx-xxx-xxx-90d4d1b9a4af #region内全局唯一,建议使用UUID生成 5 | namespaceName: 测试环境 6 | appName: myTest #应用名称 7 | groupId: myTest.group #应用的id标识,一个命名空间下需要唯一 8 | appKey: myTest123@alibaba #应用的key,不要太简单,注意保管好 9 | regionId: public #请填写不同的regionId 10 | aliyunAccessKey: xxxxxxxxx 11 | aliyunSecretKey: xxxxxxxxx 12 | alarmChannel: sms,ding #报警通道:短信和钉钉 13 | jobs: 14 | simpleJob: 15 | jobModel: standalone 16 | className: com.alibaba.cloud.examples.schedulerx.processor.SimpleJob 17 | cron: 0/30 * * * * ? # cron表达式 18 | jobParameter: hello 19 | overwrite: true 20 | shardingJob: 21 | jobModel: sharding 22 | className: com.alibaba.cloud.examples.schedulerx.processor.ShardingJob 23 | oneTime: 2022-06-02 12:00:00 # 一次性任务表达式 24 | jobParameter: 0=Beijing,1=Shanghai,2=Guangzhou 25 | overwrite: true 26 | broadcastJob: # 不填写cron和oneTime,表示api任务 27 | jobModel: broadcast 28 | className: com.alibaba.cloud.examples.schedulerx.processor.BroadcastJob 29 | jobParameter: hello 30 | overwrite: true 31 | mapReduceJob: 32 | jobModel: mapreduce 33 | className: com.alibaba.cloud.examples.schedulerx.processor.MapReduceJob 34 | cron: 0 * * * * ? 35 | jobParameter: 100 36 | overwrite: true 37 | alarmUsers: 38 | user1: 39 | userName: 张三 40 | userPhone: 12345678900 41 | user2: 42 | userName: 李四 43 | ding: https://oapi.dingtalk.com/robot/send?access_token=xxxxx -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/context/OssApplicationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss.context; 18 | 19 | import com.aliyun.oss.OSS; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | import org.springframework.context.ApplicationListener; 23 | import org.springframework.context.event.ContextClosedEvent; 24 | 25 | import java.util.Map; 26 | 27 | /** 28 | * Shutdown All OSS Clients when {@code ApplicationContext} gets closed 29 | * {@link ApplicationListener}. 30 | * 31 | * @author Jim 32 | */ 33 | public class OssApplicationListener implements ApplicationListener { 34 | 35 | private static final Logger log = LoggerFactory 36 | .getLogger(OssApplicationListener.class); 37 | 38 | @Override 39 | public void onApplicationEvent(ContextClosedEvent event) { 40 | Map ossClientMap = event.getApplicationContext() 41 | .getBeansOfType(OSS.class); 42 | log.info("{} OSSClients will be shutdown soon", ossClientMap.size()); 43 | ossClientMap.keySet().forEach(beanName -> { 44 | log.info("shutdown ossClient: {}", beanName); 45 | ossClientMap.get(beanName).shutdown(); 46 | }); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/KillJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.stereotype.Component; 22 | 23 | import com.alibaba.schedulerx.worker.domain.JobContext; 24 | import com.alibaba.schedulerx.worker.processor.JavaProcessor; 25 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 26 | 27 | /** 28 | * 演示如何通过实现kill方法正确停止任务运行 29 | * @author xiaomeng.hxm 30 | */ 31 | @Component 32 | public class KillJob extends JavaProcessor { 33 | 34 | /* 35 | * log4j2/logback配置schedulerxLogAppender,可以进行日志采集 36 | */ 37 | private static final Logger logger = LoggerFactory.getLogger("schedulerx"); 38 | private volatile boolean killed = false; 39 | 40 | @Override 41 | public ProcessResult process(JobContext context) throws Exception { 42 | while (!killed) { 43 | System.out.println("do something..."); 44 | Thread.sleep(3000); 45 | } 46 | return new ProcessResult(true); 47 | } 48 | 49 | @Override 50 | public void kill(JobContext context) { 51 | System.out.println("start to kill"); 52 | killed = true; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/rds/env/RdsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.rds.env; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | /** 22 | * the rds properties. 23 | * 24 | * @author theonefx 25 | */ 26 | @ConfigurationProperties(prefix = RDSConstants.ACTUATOR_PREFIX) 27 | public class RdsProperties { 28 | 29 | /** 30 | * the default regionId. 31 | */ 32 | private String defaultRegionId; 33 | 34 | /** 35 | * all rdb regionId list, splited by an comma. 36 | */ 37 | private String allRegionIds; 38 | 39 | /** 40 | * the performace monitor key in actuator. 41 | */ 42 | private String performanceKey; 43 | 44 | public String getPerformanceKey() { 45 | return performanceKey; 46 | } 47 | 48 | public void setPerformanceKey(String performanceKey) { 49 | this.performanceKey = performanceKey; 50 | } 51 | 52 | public String getDefaultRegionId() { 53 | return defaultRegionId; 54 | } 55 | 56 | public void setDefaultRegionId(String defaultRegionId) { 57 | this.defaultRegionId = defaultRegionId; 58 | } 59 | 60 | public String getAllRegionIds() { 61 | return allRegionIds; 62 | } 63 | 64 | public void setAllRegionIds(String allRegionIds) { 65 | this.allRegionIds = allRegionIds; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/actuate/ReceiveMessageEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.actuate; 18 | 19 | 20 | import com.alibaba.cloud.spring.boot.sms.base.MessageListener; 21 | 22 | import java.io.Serializable; 23 | 24 | /** 25 | * @author pbting 26 | */ 27 | public class ReceiveMessageEntity implements Serializable { 28 | 29 | private String messageType; 30 | 31 | private String queueName; 32 | 33 | private MessageListener messageListener; 34 | 35 | public ReceiveMessageEntity(String messageType, String queueName, 36 | MessageListener messageListener) { 37 | this.messageType = messageType; 38 | this.queueName = queueName; 39 | this.messageListener = messageListener; 40 | } 41 | 42 | public String getMessageType() { 43 | return messageType; 44 | } 45 | 46 | public void setMessageType(String messageType) { 47 | this.messageType = messageType; 48 | } 49 | 50 | public String getQueueName() { 51 | return queueName; 52 | } 53 | 54 | public void setQueueName(String queueName) { 55 | this.queueName = queueName; 56 | } 57 | 58 | public MessageListener getMessageListener() { 59 | return messageListener; 60 | } 61 | 62 | public void setMessageListener(MessageListener messageListener) { 63 | this.messageListener = messageListener; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/domain/AccountInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.domain; 18 | 19 | import java.util.Map; 20 | 21 | import com.alibaba.schedulerx.worker.processor.BizSubTask; 22 | import com.google.common.collect.Maps; 23 | 24 | /** 25 | * AccountInfo. 26 | * 27 | * @author xiaomeng.hxm 28 | **/ 29 | public class AccountInfo implements BizSubTask { 30 | 31 | private long id; 32 | private String name; 33 | private String accountId; 34 | 35 | public AccountInfo(long id, String name, String accountId) { 36 | this.id = id; 37 | this.name = name; 38 | this.accountId = accountId; 39 | } 40 | 41 | /** 42 | * implement labelMap. 43 | * @return labelMap 44 | */ 45 | @Override 46 | public Map labelMap() { 47 | Map labelMap = Maps.newHashMap(); 48 | labelMap.put("user", name); 49 | return labelMap; 50 | } 51 | 52 | public long getId() { 53 | return id; 54 | } 55 | 56 | public void setId(long id) { 57 | this.id = id; 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | public void setName(String name) { 65 | this.name = name; 66 | } 67 | 68 | public String getAccountId() { 69 | return accountId; 70 | } 71 | 72 | public void setAccountId(String accountId) { 73 | this.accountId = accountId; 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/StreamRequestFCSpringFunctionInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.cloud.spring.boot.fc; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.io.OutputStream; 21 | 22 | import org.springframework.messaging.Message; 23 | 24 | import com.aliyun.fc.runtime.Context; 25 | import com.aliyun.fc.runtime.StreamRequestHandler; 26 | 27 | /** 28 | * @author theonefx 29 | */ 30 | public class StreamRequestFCSpringFunctionInvoker extends AbstractAliyunFCInvoker implements StreamRequestHandler { 31 | 32 | @Override 33 | public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { 34 | this.initialize(context); 35 | 36 | Class paramTtype = getInputType(); 37 | 38 | if (InputOutputPair.class.isAssignableFrom(paramTtype)) { 39 | doInvoke(new InputOutputPair(input, output)); 40 | } else { 41 | Object result = doInvokeAsStream(input, null); 42 | if (functionReturnsMessage(result)) { 43 | Message respMsg = (Message) result; 44 | output.write(serializeResult(respMsg.getPayload())); 45 | } else { 46 | output.write(serializeResult(result)); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-spring-boot-samples 16 | pom 17 | 18 | Aliyun Spring Boot :: Samples 19 | Spring Boot Samples for Aliyun Services 20 | 21 | 22 | 1.8 23 | 1.8 24 | 1.8 25 | UTF-8 26 | UTF-8 27 | 2.3.0.RELEASE 28 | 29 | 30 | 31 | aliyun-oss-spring-boot-sample 32 | aliyun-sms-spring-boot-sample 33 | aliyun-redis-spring-boot-sample 34 | aliyun-rds-spring-boot-sample 35 | aliyun-compileflow-spring-boot-sample 36 | aliyun-fc-spring-boot-sample 37 | aliyun-schedulerx-spring-boot-sample 38 | 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-deploy-plugin 45 | ${maven-deploy-plugin.version} 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-redis-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/redis/RedisController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.examples.redis; 18 | 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.beans.factory.annotation.Value; 21 | import org.springframework.data.redis.core.StringRedisTemplate; 22 | import org.springframework.data.redis.core.ValueOperations; 23 | import org.springframework.web.bind.annotation.GetMapping; 24 | import org.springframework.web.bind.annotation.PathVariable; 25 | import org.springframework.web.bind.annotation.RestController; 26 | 27 | /** 28 | * Redis Rest Controller 29 | * 30 | * @author Mercy 31 | */ 32 | @RestController 33 | public class RedisController { 34 | 35 | @Autowired 36 | private StringRedisTemplate redisTemplate; 37 | 38 | @Value("${sample.key:default}") 39 | private String key; 40 | 41 | @GetMapping("/get") 42 | public String get() { 43 | ValueOperations ops = this.redisTemplate.opsForValue(); 44 | return ops.get(key); 45 | } 46 | 47 | @GetMapping("/set/{value}") 48 | private String set(@PathVariable String value) { 49 | ValueOperations ops = this.redisTemplate.opsForValue(); 50 | ops.set(key, value); 51 | return "OK"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/autoconfigure/EdasContextAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.autoconfigure; 18 | 19 | import com.alibaba.cloud.context.edas.AliCloudEdasSdk; 20 | import com.alibaba.cloud.context.edas.AliCloudEdasSdkFactory; 21 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 22 | import com.alibaba.cloud.spring.boot.context.env.EdasProperties; 23 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; 24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 26 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 27 | import org.springframework.context.annotation.Bean; 28 | import org.springframework.context.annotation.Configuration; 29 | 30 | /** 31 | * @author xiaolongzuo 32 | */ 33 | @Configuration(proxyBeanMethods = false) 34 | @EnableConfigurationProperties(EdasProperties.class) 35 | @ImportAutoConfiguration(AliCloudContextAutoConfiguration.class) 36 | public class EdasContextAutoConfiguration { 37 | 38 | @Bean 39 | @ConditionalOnMissingBean 40 | @ConditionalOnClass(name = "com.aliyuncs.edas.model.v20170801.GetSecureTokenRequest") 41 | public AliCloudEdasSdk aliCloudEdasSdk(AliCloudProperties aliCloudProperties, EdasProperties edasProperties) { 42 | return AliCloudEdasSdkFactory.getDefaultAliCloudEdasSdk(aliCloudProperties, 43 | edasProperties.getRegionId()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-context-spring-boot-starter 16 | jar 17 | 18 | Aliyun Spring Boot :: Starters :: Context 19 | Spring Boot Starter For Aliyun Context 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-actuator-autoconfigure 27 | true 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | true 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-configuration-processor 39 | true 40 | 41 | 42 | 43 | 44 | com.alibaba.cloud 45 | alicloud-context 46 | 47 | 48 | 49 | com.aliyun 50 | aliyun-java-sdk-edas 51 | 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-starter-test 57 | test 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-compileflow-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/compileflow/env/CompileflowProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.compileflow.env; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author yusu 25 | */ 26 | @ConfigurationProperties("alibaba.cloud.compileflow") 27 | public class CompileflowProperties { 28 | 29 | private String flowSourceType = "file"; 30 | 31 | private boolean precompile = true; 32 | 33 | private List precompileProcessFiles; 34 | 35 | private List precompileProcessDirs; 36 | 37 | public String getFlowSourceType() { 38 | return flowSourceType; 39 | } 40 | 41 | public void setFlowSourceType(String flowSourceType) { 42 | this.flowSourceType = flowSourceType; 43 | } 44 | 45 | public boolean isPrecompile() { 46 | return precompile; 47 | } 48 | 49 | public void setPrecompile(boolean precompile) { 50 | this.precompile = precompile; 51 | } 52 | 53 | public List getPrecompileProcessFiles() { 54 | return precompileProcessFiles; 55 | } 56 | 57 | public void setPrecompileProcessFiles(List precompileProcessFiles) { 58 | this.precompileProcessFiles = precompileProcessFiles; 59 | } 60 | 61 | public List getPrecompileProcessDirs() { 62 | return precompileProcessDirs; 63 | } 64 | 65 | public void setPrecompileProcessDirs(List precompileProcessDirs) { 66 | this.precompileProcessDirs = precompileProcessDirs; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-oss-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/oss/OssApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.oss; 18 | 19 | import com.aliyun.oss.OSS; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.boot.ApplicationArguments; 22 | import org.springframework.boot.ApplicationRunner; 23 | import org.springframework.boot.SpringApplication; 24 | import org.springframework.boot.autoconfigure.SpringBootApplication; 25 | import org.springframework.context.annotation.Bean; 26 | 27 | import java.net.URISyntaxException; 28 | 29 | /** 30 | * OSS Application. 31 | * 32 | * @author Jim 33 | */ 34 | @SpringBootApplication 35 | public class OssApplication { 36 | 37 | /** 38 | * Bucket Name of OSS Example. 39 | */ 40 | public static final String BUCKET_NAME = "aliyun-spring-boot-oss-sample"; 41 | 42 | public static void main(String[] args) throws URISyntaxException { 43 | SpringApplication.run(OssApplication.class, args); 44 | } 45 | 46 | @Bean 47 | public AppRunner appRunner() { 48 | return new AppRunner(); 49 | } 50 | 51 | class AppRunner implements ApplicationRunner { 52 | 53 | @Autowired 54 | private OSS ossClient; 55 | 56 | @Override 57 | public void run(ApplicationArguments args) throws Exception { 58 | try { 59 | if (!ossClient.doesBucketExist(BUCKET_NAME)) { 60 | ossClient.createBucket(BUCKET_NAME); 61 | } 62 | } 63 | catch (Exception e) { 64 | System.err.println("oss handle bucket error: " + e.getMessage()); 65 | System.exit(-1); 66 | } 67 | } 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/OnRequiredPropertiesCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import org.springframework.boot.autoconfigure.condition.ConditionOutcome; 20 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition; 21 | import org.springframework.context.annotation.ConditionContext; 22 | import org.springframework.core.annotation.AnnotationAttributes; 23 | import org.springframework.core.type.AnnotatedTypeMetadata; 24 | 25 | import java.util.Map; 26 | 27 | import static com.alibaba.cloud.spring.boot.context.condition.OnRequiredPropertyCondition.doGetMatchOutcome; 28 | 29 | /** 30 | * Multiple {@link OnRequiredPropertyCondition} 31 | * 32 | * @author Mercy 33 | * @since 1.0.0 34 | */ 35 | public class OnRequiredPropertiesCondition extends SpringBootCondition { 36 | 37 | private static final String annotationName = ConditionalOnRequiredProperties.class 38 | .getName(); 39 | 40 | @Override 41 | public ConditionOutcome getMatchOutcome(ConditionContext context, 42 | AnnotatedTypeMetadata metadata) { 43 | 44 | Map annotationAttributes = metadata 45 | .getAnnotationAttributes(annotationName); 46 | 47 | AnnotationAttributes[] value = (AnnotationAttributes[]) annotationAttributes 48 | .get("value"); 49 | 50 | ConditionOutcome result = null; 51 | 52 | for (AnnotationAttributes attributes : value) { 53 | result = doGetMatchOutcome(context, attributes); 54 | if (!result.isMatch()) { 55 | break; 56 | } 57 | } 58 | return result; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.fc; 18 | 19 | import java.io.Serializable; 20 | import java.util.Objects; 21 | 22 | import javafx.beans.NamedArg; 23 | 24 | abstract class Pair implements Serializable{ 25 | 26 | /** 27 | * Key of this Pair. 28 | */ 29 | private K key; 30 | 31 | /** 32 | * Gets the key for this pair. 33 | * @return key for this pair 34 | */ 35 | public K getKey() { return key; } 36 | 37 | /** 38 | * Value of this this Pair. 39 | */ 40 | private V value; 41 | 42 | /** 43 | * Gets the value for this pair. 44 | * @return value for this pair 45 | */ 46 | public V getValue() { return value; } 47 | 48 | /** 49 | * Creates a new pair 50 | * @param key The key for this pair 51 | * @param value The value to use for this pair 52 | */ 53 | protected Pair(@NamedArg("key") K key, @NamedArg("value") V value) { 54 | this.key = key; 55 | this.value = value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return key + "=" + value; 61 | } 62 | 63 | @Override 64 | public int hashCode() { 65 | return key.hashCode() * 13 + (value == null ? 0 : value.hashCode()); 66 | } 67 | 68 | @Override 69 | public boolean equals(Object o) { 70 | if (this == o) return true; 71 | if (o instanceof Pair) { 72 | Pair pair = (Pair) o; 73 | if (!Objects.equals(key, pair.key)) return false; 74 | if (!Objects.equals(value, pair.value)) return false; 75 | return true; 76 | } 77 | return false; 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/autoconfigure/SmsAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import com.alibaba.cloud.spring.boot.sms.ISmsService; 21 | import com.alibaba.cloud.spring.boot.sms.SmsInitializerEventListener; 22 | import com.alibaba.cloud.spring.boot.sms.SmsServiceImpl; 23 | import com.alibaba.cloud.spring.boot.sms.env.SmsProperties; 24 | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; 25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 26 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 27 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 28 | import org.springframework.context.annotation.Bean; 29 | import org.springframework.context.annotation.Configuration; 30 | 31 | /** 32 | * @author pbting 33 | */ 34 | @Configuration(proxyBeanMethods = false) 35 | @EnableConfigurationProperties 36 | @ConditionalOnClass(SendSmsRequest.class) 37 | @ConditionalOnProperty(value = "alibaba.cloud.sms.enabled", matchIfMissing = true) 38 | public class SmsAutoConfiguration { 39 | 40 | @Bean 41 | public SmsServiceImpl smsService(AliCloudProperties aliCloudProperties, 42 | SmsProperties smsProperties) { 43 | return new SmsServiceImpl(aliCloudProperties, smsProperties); 44 | } 45 | 46 | @Bean 47 | public SmsInitializerEventListener smsInitializePostListener( 48 | SmsProperties smsProperties, ISmsService smsService) { 49 | return new SmsInitializerEventListener(smsProperties, smsService); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-samples 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | aliyun-schedulerx-spring-boot-sample 15 | jar 16 | 17 | Aliyun Spring Boot :: Samples :: SchedulerX 18 | Spring Boot Sample for Aliyun SchedulerX 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-dependencies 29 | ${spring-boot.version} 30 | pom 31 | import 32 | 33 | 34 | 35 | 36 | com.alibaba.cloud 37 | aliyun-spring-boot-dependencies 38 | ${revision} 39 | pom 40 | import 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | com.alibaba.cloud 51 | aliyun-schedulerx-spring-boot-starter 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-maven-plugin 61 | ${spring-boot.version} 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-schedulerx-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-schedulerx-spring-boot-starter 16 | jar 17 | 18 | Aliyun Spring Boot :: Starters :: SchedulerX 19 | Spring Boot Starter for Aliyun SchedulerX 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-actuator-autoconfigure 27 | true 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | true 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-configuration-processor 39 | true 40 | 41 | 42 | 43 | 44 | com.alibaba.cloud 45 | aliyun-context-spring-boot-starter 46 | 47 | 48 | 49 | 50 | com.aliyun.schedulerx 51 | schedulerx2-spring-boot-starter 52 | 1.5.0.2 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-test 59 | test 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/env/SmsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.env; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | /** 22 | * @author pbting 23 | * @author xiaolongzuo 24 | */ 25 | @ConfigurationProperties(prefix = "alibaba.cloud.sms") 26 | public class SmsProperties { 27 | 28 | /** 29 | * Product name. 30 | */ 31 | public static final String SMS_PRODUCT = "Dysmsapi"; 32 | 33 | /** 34 | * Product domain. 35 | */ 36 | public static final String SMS_DOMAIN = "dysmsapi.aliyuncs.com"; 37 | 38 | /** 39 | * Report queue name. 40 | */ 41 | private String reportQueueName; 42 | 43 | /** 44 | * Up queue name. 45 | */ 46 | private String upQueueName; 47 | 48 | /** 49 | * Connect timeout. 50 | */ 51 | private String connectTimeout = "10000"; 52 | 53 | /** 54 | * Read timeout. 55 | */ 56 | private String readTimeout = "10000"; 57 | 58 | public String getConnectTimeout() { 59 | return connectTimeout; 60 | } 61 | 62 | public void setConnectTimeout(String connectTimeout) { 63 | this.connectTimeout = connectTimeout; 64 | } 65 | 66 | public String getReadTimeout() { 67 | return readTimeout; 68 | } 69 | 70 | public void setReadTimeout(String readTimeout) { 71 | this.readTimeout = readTimeout; 72 | } 73 | 74 | public String getReportQueueName() { 75 | return reportQueueName; 76 | } 77 | 78 | public void setReportQueueName(String reportQueueName) { 79 | this.reportQueueName = reportQueueName; 80 | } 81 | 82 | public String getUpQueueName() { 83 | return upQueueName; 84 | } 85 | 86 | public void setUpQueueName(String upQueueName) { 87 | this.upQueueName = upQueueName; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/OnAliCloudEndpointCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import org.springframework.boot.autoconfigure.condition.ConditionOutcome; 21 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition; 22 | import org.springframework.context.annotation.Condition; 23 | import org.springframework.context.annotation.ConditionContext; 24 | import org.springframework.core.type.AnnotatedTypeMetadata; 25 | 26 | import static com.alibaba.cloud.spring.boot.context.condition.OnRequiredPropertyCondition.doGetMatchOutcome; 27 | import static com.alibaba.cloud.spring.boot.context.env.AliCloudProperties.ACCESS_KEY_PROPERTY; 28 | import static com.alibaba.cloud.spring.boot.context.env.AliCloudProperties.SECRET_KEY_PROPERTY; 29 | 30 | /** 31 | * {@link Condition} that checks whether an endpoint of Alibaba Cloud is available or not 32 | * if and only if the properties that are "alibaba.cloud.access-key" and 33 | * "alibaba.cloud.secret-key" must be present. 34 | * 35 | * @author Mercy 36 | * @since 1.0.0 37 | * @see ConditionalOnAliCloudEndpoint 38 | * @see AliCloudProperties 39 | */ 40 | class OnAliCloudEndpointCondition extends SpringBootCondition { 41 | 42 | @Override 43 | public ConditionOutcome getMatchOutcome(ConditionContext context, 44 | AnnotatedTypeMetadata metadata) { 45 | 46 | ConditionOutcome result = doGetMatchOutcome(context, ACCESS_KEY_PROPERTY); 47 | 48 | if (result.isMatch()) { 49 | result = doGetMatchOutcome(context, SECRET_KEY_PROPERTY); 50 | } 51 | 52 | return result; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-rds-spring-boot-sample/src/main/java/com/alibaba/cloud/spring/boot/examples/rds/Order.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.examples.rds; 18 | 19 | import java.io.Serializable; 20 | 21 | public class Order implements Serializable { 22 | 23 | /** 24 | * order id. 25 | */ 26 | private long id; 27 | 28 | /** 29 | * user id. 30 | */ 31 | private String userId; 32 | 33 | /** 34 | * commodity code. 35 | */ 36 | private String commodityCode; 37 | 38 | /** 39 | * count. 40 | */ 41 | private int count; 42 | 43 | /** 44 | * money. 45 | */ 46 | private int money; 47 | 48 | public long getId() { 49 | return id; 50 | } 51 | 52 | public void setId(long id) { 53 | this.id = id; 54 | } 55 | 56 | public String getUserId() { 57 | return userId; 58 | } 59 | 60 | public void setUserId(String userId) { 61 | this.userId = userId; 62 | } 63 | 64 | public String getCommodityCode() { 65 | return commodityCode; 66 | } 67 | 68 | public void setCommodityCode(String commodityCode) { 69 | this.commodityCode = commodityCode; 70 | } 71 | 72 | public int getCount() { 73 | return count; 74 | } 75 | 76 | public void setCount(int count) { 77 | this.count = count; 78 | } 79 | 80 | public int getMoney() { 81 | return money; 82 | } 83 | 84 | public void setMoney(int money) { 85 | this.money = money; 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "Order{" + "id=" + id + ", userId='" + userId + '\'' + ", commodityCode='" 91 | + commodityCode + '\'' + ", count=" + count + ", money=" + money + '}'; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-redis-spring-boot-starter 16 | jar 17 | 18 | Aliyun Spring Boot :: Starters :: Redis 19 | Spring Boot Starter for Aliyun Redis 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | true 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-configuration-processor 33 | true 34 | 35 | 36 | 37 | 38 | com.alibaba.cloud 39 | aliyun-context-spring-boot-starter 40 | 41 | 42 | 43 | com.aliyun 44 | aliyun-java-sdk-r-kvstore 45 | 46 | 47 | 48 | com.aliyun 49 | aliyun-java-sdk-core 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-test 56 | test 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-web 62 | test 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/env/RedisProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.env; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | 21 | import static com.alibaba.cloud.spring.boot.redis.env.RedisProperties.PROPERTY_PREFIX; 22 | 23 | 24 | /** 25 | * The {@link ConfigurationProperties} for Alibaba Cloud Redis 26 | * 27 | * @author Mercy 28 | * @since 1.0.0 29 | */ 30 | @ConfigurationProperties(PROPERTY_PREFIX) 31 | public class RedisProperties { 32 | 33 | /** 34 | * The prefix of the property of {@link RedisProperties} 35 | */ 36 | public static final String PROPERTY_PREFIX = "alibaba.cloud.redis"; 37 | 38 | /** 39 | * The property of {@link #getInstanceId()}, e,g. "r-bp1xxxxxxxxxxxxx" 40 | */ 41 | public static final String INSTANCE_ID_PROPERTY = PROPERTY_PREFIX + ".instance-id"; 42 | 43 | /** 44 | * Default region id of Redis 45 | */ 46 | private String defaultRegionId = "cn-hangzhou"; 47 | 48 | /** 49 | * The id of Redis instance 50 | */ 51 | private String instanceId; 52 | 53 | public String getInstanceId() { 54 | return instanceId; 55 | } 56 | 57 | public void setInstanceId(String instanceId) { 58 | this.instanceId = instanceId; 59 | } 60 | 61 | public String getDefaultRegionId() { 62 | return defaultRegionId; 63 | } 64 | 65 | public void setDefaultRegionId(String defaultRegionId) { 66 | this.defaultRegionId = defaultRegionId; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/base/QueryTokenForMnsQueueResponseUnmarshaller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.base; 18 | 19 | import com.aliyuncs.transform.UnmarshallerContext; 20 | 21 | public final class QueryTokenForMnsQueueResponseUnmarshaller { 22 | 23 | private QueryTokenForMnsQueueResponseUnmarshaller() { 24 | } 25 | 26 | public static QueryTokenForMnsQueueResponse unmarshall( 27 | QueryTokenForMnsQueueResponse queryTokenForMnsQueueResponse, 28 | UnmarshallerContext context) { 29 | queryTokenForMnsQueueResponse.setRequestId( 30 | context.stringValue("QueryTokenForMnsQueueResponse.RequestId")); 31 | queryTokenForMnsQueueResponse 32 | .setCode(context.stringValue("QueryTokenForMnsQueueResponse.Code")); 33 | queryTokenForMnsQueueResponse 34 | .setMessage(context.stringValue("QueryTokenForMnsQueueResponse.Message")); 35 | QueryTokenForMnsQueueResponse.MessageTokenDTO messageTokenDTO = new QueryTokenForMnsQueueResponse.MessageTokenDTO(); 36 | messageTokenDTO.setAccessKeyId(context.stringValue( 37 | "QueryTokenForMnsQueueResponse.MessageTokenDTO.AccessKeyId")); 38 | messageTokenDTO.setAccessKeySecret(context.stringValue( 39 | "QueryTokenForMnsQueueResponse.MessageTokenDTO.AccessKeySecret")); 40 | messageTokenDTO.setSecurityToken(context.stringValue( 41 | "QueryTokenForMnsQueueResponse.MessageTokenDTO.SecurityToken")); 42 | messageTokenDTO.setCreateTime(context 43 | .stringValue("QueryTokenForMnsQueueResponse.MessageTokenDTO.CreateTime")); 44 | messageTokenDTO.setExpireTime(context 45 | .stringValue("QueryTokenForMnsQueueResponse.MessageTokenDTO.ExpireTime")); 46 | queryTokenForMnsQueueResponse.setMessageTokenDTO(messageTokenDTO); 47 | return queryTokenForMnsQueueResponse; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-oss-spring-boot-starter 16 | jar 17 | 18 | Aliyun Spring Boot :: Starters :: OSS 19 | Spring Boot Starter for Aliyun OSS 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-actuator-autoconfigure 27 | true 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter 33 | true 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-configuration-processor 39 | true 40 | 41 | 42 | 43 | 44 | com.alibaba.cloud 45 | aliyun-context-spring-boot-starter 46 | 47 | 48 | 49 | 50 | com.aliyun.oss 51 | aliyun-sdk-oss 52 | 53 | 54 | 55 | org.slf4j 56 | slf4j-api 57 | true 58 | 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-starter-test 64 | test 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/autoconfigure/OssAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.oss.OssConstants; 20 | import com.alibaba.cloud.spring.boot.oss.resource.OssStorageProtocolResolver; 21 | import com.aliyun.oss.OSS; 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 23 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 25 | import org.springframework.context.annotation.Bean; 26 | import org.springframework.context.annotation.Configuration; 27 | 28 | import java.util.concurrent.ExecutorService; 29 | import java.util.concurrent.SynchronousQueue; 30 | import java.util.concurrent.ThreadPoolExecutor; 31 | import java.util.concurrent.TimeUnit; 32 | 33 | import static com.alibaba.cloud.spring.boot.oss.OssConstants.OSS_TASK_EXECUTOR_BEAN_NAME; 34 | 35 | /** 36 | * OSS Auto {@link Configuration}. 37 | * 38 | * @author Jim 39 | */ 40 | @Configuration(proxyBeanMethods = false) 41 | @ConditionalOnClass(OSS.class) 42 | @ConditionalOnProperty(name = OssConstants.ENABLED, havingValue = "true", 43 | matchIfMissing = true) 44 | public class OssAutoConfiguration { 45 | 46 | @Bean 47 | @ConditionalOnMissingBean 48 | public OssStorageProtocolResolver ossStorageProtocolResolver() { 49 | return new OssStorageProtocolResolver(); 50 | } 51 | 52 | @Bean(name = OSS_TASK_EXECUTOR_BEAN_NAME) 53 | @ConditionalOnMissingBean 54 | public ExecutorService ossTaskExecutor() { 55 | int coreSize = Runtime.getRuntime().availableProcessors(); 56 | return new ThreadPoolExecutor(coreSize, 128, 60, TimeUnit.SECONDS, 57 | new SynchronousQueue<>()); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/env/EdasProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.env; 18 | 19 | import com.alibaba.cloud.context.edas.EdasConfiguration; 20 | import org.springframework.beans.factory.annotation.Value; 21 | import org.springframework.boot.context.properties.ConfigurationProperties; 22 | 23 | /** 24 | * @author xiaolongzuo 25 | */ 26 | @ConfigurationProperties("alibaba.cloud.edas") 27 | public class EdasProperties implements EdasConfiguration { 28 | 29 | private static final String DEFAULT_APPLICATION_NAME = ""; 30 | 31 | /** 32 | * edas application name. 33 | */ 34 | @Value("${spring.application.name:${alibaba.cloud.edas.application.name:}}") 35 | private String applicationName; 36 | 37 | /** 38 | * edas namespace. 39 | */ 40 | private String namespace; 41 | 42 | /** 43 | * whether or not connect edas. 44 | */ 45 | private boolean enabled; 46 | 47 | @Override 48 | public String getRegionId() { 49 | if (namespace == null) { 50 | return null; 51 | } 52 | return namespace.contains(":") ? namespace.split(":")[0] : namespace; 53 | } 54 | 55 | @Override 56 | public boolean isApplicationNameValid() { 57 | return !DEFAULT_APPLICATION_NAME.equals(applicationName); 58 | } 59 | 60 | @Override 61 | public String getApplicationName() { 62 | return applicationName; 63 | } 64 | 65 | public void setApplicationName(String applicationName) { 66 | this.applicationName = applicationName; 67 | } 68 | 69 | @Override 70 | public String getNamespace() { 71 | return namespace; 72 | } 73 | 74 | public void setNamespace(String namespace) { 75 | this.namespace = namespace; 76 | } 77 | 78 | @Override 79 | public boolean isEnabled() { 80 | return enabled; 81 | } 82 | 83 | public void setEnabled(boolean enabled) { 84 | this.enabled = enabled; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/actuate/endpoint/RedisDescribeAccountsEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.actuate.endpoint; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import com.alibaba.cloud.spring.boot.redis.env.RedisProperties; 21 | import com.aliyuncs.r_kvstore.model.v20150101.DescribeAccountsRequest; 22 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 23 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 24 | import org.springframework.boot.actuate.endpoint.annotation.Selector; 25 | 26 | /** 27 | * The {@link Endpoint} for Alibaba Cloud Redis's 28 | * DescribeAccounts 29 | * 30 | * @author Mercy 31 | * @since 1.0.0 32 | */ 33 | @Endpoint(id = "redisDescribeAccounts") 34 | public class RedisDescribeAccountsEndpoint extends AbstractRedisEndpoint { 35 | 36 | public RedisDescribeAccountsEndpoint(AliCloudProperties aliCloudProperties, 37 | RedisProperties redisProperties) { 38 | super(aliCloudProperties, redisProperties); 39 | } 40 | 41 | @ReadOperation 42 | public Object describeAccountsWithDefaultRegionId() { 43 | return describeAccounts(getDefaultRegionID()); 44 | } 45 | 46 | @ReadOperation 47 | public Object describeAccounts(@Selector String regionId) { 48 | return execute(() -> { 49 | DescribeAccountsRequest request = new DescribeAccountsRequest(); 50 | request.setSysRegionId(regionId); 51 | request.setInstanceId(getInstanceId()); 52 | return createIAcsClient(regionId).getAcsResponse(request); 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/env/AliCloudProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.env; 18 | 19 | import com.alibaba.cloud.context.AliCloudConfiguration; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | 22 | import static com.alibaba.cloud.spring.boot.context.env.AliCloudProperties.PROPERTY_PREFIX; 23 | 24 | /** 25 | * The {@link ConfigurationProperties Properties} class for Alibaba Cloud 26 | * 27 | * @author xiaolongzuo 28 | * @author Mercy 29 | * @since 1.0.0 30 | */ 31 | @ConfigurationProperties(PROPERTY_PREFIX) 32 | public class AliCloudProperties implements AliCloudConfiguration { 33 | 34 | /** 35 | * The prefix of the property of {@link AliCloudProperties}. 36 | */ 37 | public static final String PROPERTY_PREFIX = "alibaba.cloud"; 38 | 39 | /** 40 | * The the property of {@link #getAccessKey()}. 41 | */ 42 | public static final String ACCESS_KEY_PROPERTY = PROPERTY_PREFIX + ".access-key"; 43 | 44 | /** 45 | * The prefix of the property of {@link #getSecretKey()}. 46 | */ 47 | public static final String SECRET_KEY_PROPERTY = PROPERTY_PREFIX + ".secret-key"; 48 | 49 | /** 50 | * alibaba cloud access key. 51 | */ 52 | private String accessKey; 53 | 54 | /** 55 | * alibaba cloud secret key. 56 | */ 57 | private String secretKey; 58 | 59 | @Override 60 | public String getAccessKey() { 61 | return accessKey; 62 | } 63 | 64 | public void setAccessKey(String accessKey) { 65 | this.accessKey = accessKey; 66 | } 67 | 68 | @Override 69 | public String getSecretKey() { 70 | return secretKey; 71 | } 72 | 73 | public void setSecretKey(String secretKey) { 74 | this.secretKey = secretKey; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/src/test/java/com/alibaba/cloud/spring/boot/rds/actuate/autoconfigure/RdsEndpointAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.rds.actuate.autoconfigure; 18 | 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | import com.alibaba.cloud.spring.boot.rds.actuate.endpoint.RdsInstancesEndpoint; 25 | import org.junit.Ignore; 26 | import org.junit.Test; 27 | import org.junit.runner.RunWith; 28 | import static org.junit.Assert.assertNotNull; 29 | 30 | /** 31 | * The test cases for {@link RdsEndpointAutoConfiguration} 32 | * 33 | * @author theonefx 34 | * @since 1.0.0 35 | */ 36 | @Ignore 37 | @RunWith(SpringRunner.class) 38 | @SpringBootTest(classes = {RdsEndpointAutoConfigurationTest.class}, 39 | webEnvironment = SpringBootTest.WebEnvironment.NONE, 40 | properties = { 41 | // Please set "-Dalibaba.cloud.access-key" for accessKey 42 | // Please set "-Dalibaba.cloud.secret-key" for secretKey 43 | "management.health.rds.enabled = true", 44 | "management.endpoints.web.exposure.include = *", 45 | "management.endpoints.jmx.exposure.include = *",}) 46 | @EnableAutoConfiguration 47 | public class RdsEndpointAutoConfigurationTest { 48 | 49 | @Autowired 50 | private RdsInstancesEndpoint rdsInstancesEndpoint; 51 | 52 | @Test 53 | public void testRedisDescribeAvailableResourceEndpoint() { 54 | assertNotNull(rdsInstancesEndpoint); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/actuate/OssEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss.actuate; 18 | 19 | import com.aliyun.oss.OSSClient; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 22 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 23 | import org.springframework.context.ApplicationContext; 24 | 25 | import java.util.ArrayList; 26 | import java.util.HashMap; 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | /** 31 | * Actuator {@link Endpoint} to expose OSS Meta Data. 32 | * 33 | * @author Jim 34 | */ 35 | @Endpoint(id = "oss") 36 | public class OssEndpoint { 37 | 38 | @Autowired 39 | private ApplicationContext applicationContext; 40 | 41 | @ReadOperation 42 | public Map invoke() { 43 | Map result = new HashMap<>(); 44 | 45 | Map ossClientMap = applicationContext 46 | .getBeansOfType(OSSClient.class); 47 | 48 | int size = ossClientMap.size(); 49 | 50 | List ossClientList = new ArrayList<>(); 51 | 52 | ossClientMap.keySet().forEach(beanName -> { 53 | Map ossProperties = new HashMap<>(); 54 | OSSClient client = ossClientMap.get(beanName); 55 | ossProperties.put("beanName", beanName); 56 | ossProperties.put("endpoint", client.getEndpoint().toString()); 57 | ossProperties.put("clientConfiguration", client.getClientConfiguration()); 58 | ossProperties.put("credentials", 59 | client.getCredentialsProvider().getCredentials()); 60 | ossProperties.put("bucketList", client.listBuckets().stream() 61 | .map(bucket -> bucket.getName()).toArray()); 62 | ossClientList.add(ossProperties); 63 | }); 64 | 65 | result.put("size", size); 66 | result.put("info", ossClientList); 67 | 68 | return result; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/actuate/endpoint/RedisDescribeAvailableResourceEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.actuate.endpoint; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import com.alibaba.cloud.spring.boot.redis.env.RedisProperties; 21 | import com.aliyuncs.r_kvstore.model.v20150101.DescribeInstancesRequest; 22 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 23 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 24 | import org.springframework.boot.actuate.endpoint.annotation.Selector; 25 | import org.springframework.lang.Nullable; 26 | 27 | /** 28 | * The {@link Endpoint} for Alibaba Cloud Redis's DescribeAvailableResource 30 | * 31 | * @author Mercy 32 | * @since 1.0.0 33 | */ 34 | @Endpoint(id = "redisDescribeAvailableResource") 35 | public class RedisDescribeAvailableResourceEndpoint extends AbstractRedisEndpoint { 36 | 37 | public RedisDescribeAvailableResourceEndpoint(AliCloudProperties aliCloudProperties, 38 | RedisProperties redisProperties) { 39 | super(aliCloudProperties, redisProperties); 40 | } 41 | 42 | @ReadOperation 43 | public Object describeAvailableResourceWithDefaultRegionId() { 44 | return describeAvailableResource(getDefaultRegionID()); 45 | } 46 | 47 | @ReadOperation 48 | public Object describeAvailableResource(@Selector @Nullable String regionId) { 49 | return execute(() -> { 50 | DescribeInstancesRequest request = new DescribeInstancesRequest(); 51 | request.setSysRegionId(regionId); 52 | return createIAcsClient(regionId).getAcsResponse(request); 53 | }); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-rds-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-parent 11 | ${revision} 12 | ../../aliyun-spring-boot-parent/pom.xml 13 | 14 | 15 | aliyun-rds-spring-boot-starter 16 | jar 17 | 18 | Aliyun Spring Boot :: Starters :: RDS 19 | Spring Boot Starter for Aliyun RDS 20 | 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-actuator 27 | true 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-configuration-processor 33 | true 34 | 35 | 36 | 37 | 38 | com.alibaba.cloud 39 | aliyun-context-spring-boot-starter 40 | 41 | 42 | 43 | 44 | com.aliyun 45 | aliyun-java-sdk-core 46 | 47 | 48 | org.apache.httpcomponents 49 | httpclient 50 | 51 | 52 | 53 | com.aliyun 54 | aliyun-java-sdk-rds 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-starter-test 61 | test 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-web 67 | test 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/actuate/endpoint/RedisDescribeInstancesEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.actuate.endpoint; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import com.alibaba.cloud.spring.boot.redis.env.RedisProperties; 21 | import com.aliyuncs.r_kvstore.model.v20150101.DescribeInstancesRequest; 22 | import org.springframework.boot.actuate.endpoint.annotation.Endpoint; 23 | import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; 24 | import org.springframework.boot.actuate.endpoint.annotation.Selector; 25 | 26 | /** 27 | * The {@link Endpoint} for Alibaba Cloud Redis's 28 | * DescribeInstances 29 | * 30 | * @author Mercy 31 | * @since 1.0.0 32 | */ 33 | @Endpoint(id = "redisDescribeInstances") 34 | public class RedisDescribeInstancesEndpoint extends AbstractRedisEndpoint { 35 | 36 | public RedisDescribeInstancesEndpoint(AliCloudProperties aliCloudProperties, 37 | RedisProperties redisProperties) { 38 | super(aliCloudProperties, redisProperties); 39 | } 40 | 41 | @ReadOperation 42 | public Object describeInstancesWithDefaultRegion() { 43 | return describeInstances(getDefaultRegionID()); 44 | } 45 | 46 | @ReadOperation 47 | public Object describeInstances(@Selector String regionId) { 48 | return execute(() -> { 49 | DescribeInstancesRequest request = new DescribeInstancesRequest(); 50 | request.setSysRegionId(regionId); 51 | request.setInstanceStatus("Normal"); 52 | return createIAcsClient(regionId).getAcsResponse(request); 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/test/java/com/alibaba/cloud/spring/boot/redis/actuate/autoconfigure/RedisEndpointAutoConfigurationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.actuate.autoconfigure; 18 | 19 | import com.alibaba.cloud.spring.boot.redis.actuate.endpoint.RedisDescribeAvailableResourceEndpoint; 20 | import org.junit.Ignore; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 25 | import org.springframework.boot.test.context.SpringBootTest; 26 | import org.springframework.test.context.junit4.SpringRunner; 27 | 28 | import static org.junit.Assert.assertNotNull; 29 | 30 | /** 31 | * The test cases for {@link RedisEndpointAutoConfiguration} 32 | * 33 | * @author Mercy 34 | * @since 1.0.0 35 | */ 36 | @Ignore 37 | @RunWith(SpringRunner.class) 38 | @SpringBootTest(classes = { 39 | RedisEndpointAutoConfigurationTest.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = { 40 | // Please set "-Dalibaba.cloud.access-key" for accessKey 41 | // Please set "-Dalibaba.cloud.secret-key" for secretKey 42 | "management.endpoint.redis-describe-available-resource.enabled = true", 43 | "management.endpoints.web.exposure.include = *", 44 | "management.endpoints.jmx.exposure.include = *", }) 45 | @EnableAutoConfiguration 46 | public class RedisEndpointAutoConfigurationTest { 47 | 48 | @Autowired 49 | private RedisDescribeAvailableResourceEndpoint redisDescribeAvailableResourceEndpoint; 50 | 51 | @Test 52 | public void testRedisDescribeAvailableResourceEndpoint() { 53 | Object response = redisDescribeAvailableResourceEndpoint.describeAvailableResource("cn-hangzhou"); 54 | assertNotNull(response); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/base/QueryTokenForMnsQueueRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.base; 18 | 19 | import com.aliyuncs.RpcAcsRequest; 20 | 21 | public class QueryTokenForMnsQueueRequest 22 | extends RpcAcsRequest { 23 | 24 | private String resourceOwnerAccount; 25 | 26 | private String messageType; 27 | 28 | private Long resourceOwnerId; 29 | 30 | private Long ownerId; 31 | 32 | public QueryTokenForMnsQueueRequest() { 33 | super("Dybaseapi", "2017-05-25", "QueryTokenForMnsQueue"); 34 | } 35 | 36 | public String getResourceOwnerAccount() { 37 | return this.resourceOwnerAccount; 38 | } 39 | 40 | public void setResourceOwnerAccount(String resourceOwnerAccount) { 41 | this.resourceOwnerAccount = resourceOwnerAccount; 42 | if (resourceOwnerAccount != null) { 43 | this.putQueryParameter("ResourceOwnerAccount", resourceOwnerAccount); 44 | } 45 | 46 | } 47 | 48 | public String getMessageType() { 49 | return this.messageType; 50 | } 51 | 52 | public void setMessageType(String messageType) { 53 | this.messageType = messageType; 54 | if (messageType != null) { 55 | this.putQueryParameter("MessageType", messageType); 56 | } 57 | 58 | } 59 | 60 | public Long getResourceOwnerId() { 61 | return this.resourceOwnerId; 62 | } 63 | 64 | public void setResourceOwnerId(Long resourceOwnerId) { 65 | this.resourceOwnerId = resourceOwnerId; 66 | if (resourceOwnerId != null) { 67 | this.putQueryParameter("ResourceOwnerId", resourceOwnerId.toString()); 68 | } 69 | 70 | } 71 | 72 | public Long getOwnerId() { 73 | return this.ownerId; 74 | } 75 | 76 | public void setOwnerId(Long ownerId) { 77 | this.ownerId = ownerId; 78 | if (ownerId != null) { 79 | this.putQueryParameter("OwnerId", ownerId.toString()); 80 | } 81 | 82 | } 83 | 84 | @Override 85 | public Class getResponseClass() { 86 | return QueryTokenForMnsQueueResponse.class; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/MapReduceJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | import org.springframework.stereotype.Component; 23 | 24 | import com.alibaba.schedulerx.worker.domain.JobContext; 25 | import com.alibaba.schedulerx.worker.processor.MapReduceJobProcessor; 26 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 27 | import com.google.common.collect.Lists; 28 | 29 | /** 30 | * MapReduce任务Demo:分发50条消息,分布式并行处理 31 | * @author yaohui 32 | * @create 2022/3/16 下午7:54 33 | **/ 34 | @Component 35 | public class MapReduceJob extends MapReduceJobProcessor { 36 | 37 | @Override 38 | public ProcessResult process(JobContext context) throws Exception { 39 | String taskName = context.getTaskName(); 40 | int dispatchNum = 50; 41 | if (context.getJobParameters() != null) { 42 | dispatchNum = Integer.valueOf(context.getJobParameters()); 43 | } 44 | if (isRootTask(context)) { 45 | System.out.println("start root task"); 46 | List msgList = Lists.newArrayList(); 47 | for (int i = 0; i <= dispatchNum; i++) { 48 | msgList.add("msg_" + i); 49 | } 50 | return map(msgList, "Level1Dispatch"); 51 | } else if (taskName.equals("Level1Dispatch")) { 52 | String task = (String)context.getTask(); 53 | Thread.sleep(2000); 54 | return new ProcessResult(true, task); 55 | } 56 | 57 | return new ProcessResult(false); 58 | } 59 | 60 | @Override 61 | public ProcessResult reduce(JobContext context) throws Exception { 62 | for (Map.Entry result : context.getTaskResults().entrySet()) { 63 | System.out.println("taskId:" + result.getKey() + ", result:" + result.getValue()); 64 | } 65 | return new ProcessResult(true, "MapReduceJob.reduce"); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-rds-spring-boot-sample/README-zh.md: -------------------------------------------------------------------------------- 1 | # Aliyun Spring Boot RDS 示例 2 | 3 | ## 项目说明 4 | 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数。 5 | 6 | 本示例工程,以RDS Mysql版为例,展示如何配置和使用RDS数据源; 7 | 8 | ## 准备工作 9 | 10 | 在运行此示例之前,你需要先完成如下几步准备工作: 11 | 12 | 1 创建 ORDER_TBL 表 13 | ```sql 14 | DROP TABLE IF EXISTS `order_tbl`; 15 | CREATE TABLE `order_tbl` ( 16 | `id` int(11) NOT NULL AUTO_INCREMENT, 17 | `user_id` varchar(255) DEFAULT NULL, 18 | `commodity_code` varchar(255) DEFAULT NULL, 19 | `count` int(11) DEFAULT 0, 20 | `money` int(11) DEFAULT 0, 21 | PRIMARY KEY (`id`) 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 23 | ``` 24 | 25 | 2 初始化数据 26 | ```sql 27 | INSERT INTO `order_tbl`(`user_id`, `commodity_code`, `count`, `money`) values('1001', '0001', '10', '20'); 28 | INSERT INTO `order_tbl`(`user_id`, `commodity_code`, `count`, `money`) values('1002', '0002', '3', '13'); 29 | ``` 30 | 31 | ## 配置示例 32 | ### 增加rds starter 依赖 33 | ```xml 34 | 35 | org.springframework.boot 36 | spring-boot-starter-jdbc 37 | 38 | 39 | com.alibaba.cloud 40 | aliyun-rds-spring-boot-starter 41 | 42 | ``` 43 | ### 增加数据库驱动 44 | ```xml 45 | 46 | mysql 47 | mysql-connector-java 48 | 5.1.31 49 | 50 | ``` 51 | 52 | ### 增加连接池依赖 53 | ```xml 54 | 55 | com.alibaba 56 | druid-spring-boot-starter 57 | 1.1.17 58 | 59 | ``` 60 | 数据库连接池是可选配置,不过在生产环境,为了更好的优化系统性能一般都会使用数据库连接池 61 | 62 | ### 应用配置 63 | * Aliyun 授权信息配置 64 | ```properties 65 | alibaba.cloud.access-key=*** 66 | alibaba.cloud.secret-key=*** 67 | ``` 68 | 你可以在https://usercenter.console.aliyun.com/#/manage/ak查看自己的access-key&secret-key 69 | 70 | * 数据源配置 71 | ```properties 72 | spring.datasource.name=defaultDataSource 73 | 74 | # 数据库连接地址: 75 | spring.datasource.url=jdbc:mysql://localhost:3306/test_db?serverTimezone=UTC 76 | 77 | # 数据库用户名&密码: 78 | spring.datasource.username=**** 79 | spring.datasource.password=**** 80 | ``` 81 | 数据库访问账号&密码,请在控制台中,对应数据库实例的"账号管理"功能下维护 82 | 83 | ## 运行示例 84 | 启动com.alibaba.cloud.spring.boot.examples.rds.RdsApplication 85 | 86 | 查询数据: 87 | ``` 88 | http://127.0.0.1:9090/query/1001 89 | ``` 90 | 91 | 更新数据 92 | ``` 93 | http://127.0.0.1:9090/update/1001/5 94 | ``` 95 | 96 | ## 参考 97 | [Spring Boot 文档参考](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) 98 | [RDS控制台](https://rdsnext.console.aliyun.com) 99 | [Druid连接池](https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE) -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/ISmsService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms; 18 | 19 | import com.aliyuncs.IAcsClient; 20 | import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest; 21 | import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse; 22 | import com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsRequest; 23 | import com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsResponse; 24 | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; 25 | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; 26 | import com.aliyuncs.exceptions.ClientException; 27 | import com.aliyuncs.exceptions.ServerException; 28 | 29 | /** 30 | * @author pbting 31 | */ 32 | public interface ISmsService { 33 | 34 | IAcsClient getHangZhouRegionClientProfile(String accessKeyId, String secret); 35 | 36 | SendSmsResponse sendSmsRequest(SendSmsRequest sendSmsRequest) 37 | throws ServerException, ClientException; 38 | 39 | SendBatchSmsResponse sendSmsBatchRequest(SendBatchSmsRequest sendBatchSmsRequest) 40 | throws ServerException, ClientException; 41 | 42 | SendSmsResponse sendSmsRequest(SendSmsRequest sendSmsRequest, String accessKeyId, 43 | String accessKeySecret) throws ServerException, ClientException; 44 | 45 | SendBatchSmsResponse sendSmsBatchRequest(SendBatchSmsRequest sendSmsRequest, 46 | String accessKeyId, String accessKeySecret) 47 | throws ServerException, ClientException; 48 | 49 | boolean startSmsReportMessageListener( 50 | SmsReportMessageListener smsReportMessageListener); 51 | 52 | boolean startSmsUpMessageListener(SmsUpMessageListener smsUpMessageListener); 53 | 54 | QuerySendDetailsResponse querySendDetails(QuerySendDetailsRequest request, 55 | String accessKeyId, String accessKeySecret) throws ClientException; 56 | 57 | QuerySendDetailsResponse querySendDetails(QuerySendDetailsRequest request) 58 | throws ClientException; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/sms/base/TokenForAlicom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.sms.base; 18 | 19 | import com.aliyun.mns.client.CloudQueue; 20 | import com.aliyun.mns.client.MNSClient; 21 | 22 | /** 23 | * 用于接收云通信消息的临时token. 24 | * 25 | */ 26 | public class TokenForAlicom { 27 | 28 | private String messageType; 29 | 30 | private String token; 31 | 32 | private Long expireTime; 33 | 34 | private String tempAccessKeyId; 35 | 36 | private String tempAccessKeySecret; 37 | 38 | private MNSClient client; 39 | 40 | private CloudQueue queue; 41 | 42 | public String getMessageType() { 43 | return messageType; 44 | } 45 | 46 | public void setMessageType(String messageType) { 47 | this.messageType = messageType; 48 | } 49 | 50 | public String getToken() { 51 | return token; 52 | } 53 | 54 | public void setToken(String token) { 55 | this.token = token; 56 | } 57 | 58 | public Long getExpireTime() { 59 | return expireTime; 60 | } 61 | 62 | public void setExpireTime(Long expireTime) { 63 | this.expireTime = expireTime; 64 | } 65 | 66 | public String getTempAccessKeyId() { 67 | return tempAccessKeyId; 68 | } 69 | 70 | public void setTempAccessKeyId(String tempAccessKeyId) { 71 | this.tempAccessKeyId = tempAccessKeyId; 72 | } 73 | 74 | public String getTempAccessKeySecret() { 75 | return tempAccessKeySecret; 76 | } 77 | 78 | public void setTempAccessKeySecret(String tempAccessKeySecret) { 79 | this.tempAccessKeySecret = tempAccessKeySecret; 80 | } 81 | 82 | public MNSClient getClient() { 83 | return client; 84 | } 85 | 86 | public void setClient(MNSClient client) { 87 | this.client = client; 88 | } 89 | 90 | public CloudQueue getQueue() { 91 | return queue; 92 | } 93 | 94 | public void setQueue(CloudQueue queue) { 95 | this.queue = queue; 96 | } 97 | 98 | public void closeClient() { 99 | if (client != null) { 100 | this.client.close(); 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-sms-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-samples 11 | ${revision} 12 | ../pom.xml 13 | 14 | 15 | aliyun-sms-spring-boot-sample 16 | jar 17 | 18 | Aliyun Spring Boot :: Samples :: SMS 19 | Spring Boot Sample for Aliyun SMS 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-dependencies 29 | ${spring-boot.version} 30 | pom 31 | import 32 | 33 | 34 | 35 | 36 | com.alibaba.cloud 37 | aliyun-spring-boot-dependencies 38 | ${revision} 39 | pom 40 | import 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-web 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-actuator 58 | 59 | 60 | 61 | 62 | com.alibaba.cloud 63 | aliyun-sms-spring-boot-starter 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | ${spring-boot.version} 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-oss-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-samples 11 | ${revision} 12 | ../pom.xml 13 | 14 | 15 | aliyun-oss-spring-boot-sample 16 | jar 17 | 18 | Aliyun Spring Boot :: Samples :: OSS 19 | Spring Boot Sample for Aliyun OSS 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-dependencies 30 | ${spring-boot.version} 31 | pom 32 | import 33 | 34 | 35 | 36 | 37 | com.alibaba.cloud 38 | aliyun-spring-boot-dependencies 39 | ${revision} 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-web 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-starter-actuator 59 | 60 | 61 | 62 | 63 | com.alibaba.cloud 64 | aliyun-oss-spring-boot-starter 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-maven-plugin 74 | ${spring-boot.version} 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-sms-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-parent 10 | ${revision} 11 | ../../aliyun-spring-boot-parent/pom.xml 12 | 13 | 14 | aliyun-sms-spring-boot-starter 15 | jar 16 | 17 | Aliyun Spring Boot :: Starters :: SMS 18 | Spring Boot Starter for Aliyun SMS 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-actuator-autoconfigure 26 | true 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter 32 | true 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-configuration-processor 38 | true 39 | 40 | 41 | 42 | 43 | com.alibaba.cloud 44 | aliyun-context-spring-boot-starter 45 | 46 | 47 | 48 | 49 | com.aliyun 50 | aliyun-java-sdk-core 51 | 52 | 53 | 54 | com.aliyun 55 | aliyun-java-sdk-dysmsapi 56 | 57 | 58 | 59 | com.aliyun.mns 60 | aliyun-sdk-mns 61 | 62 | 63 | 64 | org.slf4j 65 | slf4j-api 66 | true 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-starter-test 73 | test 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-compileflow-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-parent 10 | ${revision} 11 | ../../aliyun-spring-boot-parent/pom.xml 12 | 13 | 14 | aliyun-compileflow-spring-boot-starter 15 | jar 16 | 17 | Aliyun Spring Boot :: Starters :: Compileflow 18 | Spring Boot Starter for Aliyun Compileflow 19 | 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-actuator-autoconfigure 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-configuration-processor 38 | true 39 | 40 | 41 | 45 | 46 | javax.annotation 47 | javax.annotation-api 48 | provided 49 | 50 | 51 | 52 | 53 | com.alibaba.compileflow 54 | compileflow 55 | 1.0.0-RC2 56 | 57 | 58 | 59 | org.slf4j 60 | slf4j-api 61 | true 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-test 68 | test 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-context-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/context/condition/OnRequiredPropertyCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.context.condition; 18 | 19 | import org.springframework.boot.autoconfigure.condition.ConditionOutcome; 20 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition; 21 | import org.springframework.context.annotation.ConditionContext; 22 | import org.springframework.context.annotation.Conditional; 23 | import org.springframework.core.env.PropertySources; 24 | import org.springframework.core.type.AnnotatedTypeMetadata; 25 | 26 | import java.util.Map; 27 | 28 | /** 29 | * {@link Conditional} checks the required property is present or not in the 30 | * {@link PropertySources}. 31 | * 32 | * @author Mercy 33 | * @since 1.0.0 34 | */ 35 | class OnRequiredPropertyCondition extends SpringBootCondition { 36 | 37 | private static final String annotationName = ConditionalOnRequiredProperty.class 38 | .getName(); 39 | 40 | @Override 41 | public ConditionOutcome getMatchOutcome(ConditionContext context, 42 | AnnotatedTypeMetadata metadata) { 43 | 44 | Map annotationAttributes = metadata 45 | .getAnnotationAttributes(annotationName); 46 | 47 | return doGetMatchOutcome(context, annotationAttributes); 48 | } 49 | 50 | protected static ConditionOutcome doGetMatchOutcome(ConditionContext context, 51 | Map annotationAttributes) { 52 | 53 | String propertyName = (String) annotationAttributes.get("value"); 54 | 55 | return doGetMatchOutcome(context, propertyName); 56 | } 57 | 58 | protected static ConditionOutcome doGetMatchOutcome(ConditionContext context, 59 | String propertyName) { 60 | return context.getEnvironment().containsProperty(propertyName) 61 | ? ConditionOutcome.match() : ConditionOutcome.noMatch("The property '" 62 | + propertyName + "' is abstract in the PropertySources"); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /aliyun-spring-boot-docs/asciidoc-zh/rds.adoc: -------------------------------------------------------------------------------- 1 | == Spring Cloud AliCloud RDS 2 | 3 | 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 4 | 5 | === 如何引入 Spring Cloud AliCloud RDS 6 | 7 | 我们推荐使用BOM的方式一次性解决aliyun-spring-boot的组件版本管理: 8 | 9 | [source,xml] 10 | ---- 11 | 12 | 13 | 14 | com.alibaba.cloud 15 | spring-cloud-alibaba-dependencies 16 | 1.0.0-SNAPSHOT 17 | pom 18 | import 19 | 20 | 21 | 22 | ---- 23 | 24 | 如果要在您的项目中引入 RDS,使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `aliyun-rds-spring-boot-starter` 的 starter。 25 | 26 | [source,xml] 27 | ---- 28 | 29 | com.alibaba.cloud 30 | aliyun-rds-spring-boot-starter 31 | 32 | ---- 33 | 34 | 除此之外,您还需要在您的工程中引入数据库驱动以及数据库连接池(可选),例如: 35 | 36 | Mysql 数据库驱动 37 | [source,xml] 38 | ---- 39 | 40 | mysql 41 | mysql-connector-java 42 | 5.1.31 43 | 44 | ---- 45 | 46 | Druid 连接池: 47 | [source,xml] 48 | ---- 49 | 50 | com.alibaba 51 | druid-spring-boot-starter 52 | 1.1.17 53 | 54 | ---- 55 | 56 | === 如何配置 Spring Cloud AliCloud RDS 57 | 58 | 配置阿里云账号授权信息 59 | [source,properties] 60 | ---- 61 | spring.cloud.alicloud.access-key=Your Alibaba Cloud AK 62 | spring.cloud.alicloud.secret-key=Your Alibaba Cloud SK 63 | ---- 64 | 如果不清楚自己的AK&SK,请在aliyun工作台的 https://usercenter.console.aliyun.com/#/manage/ak[安全信息管理] 中查看 65 | 66 | 67 | 配置数据源, 这里以mysql为例 68 | [source,properties] 69 | ---- 70 | # 数据源名称 71 | spring.datasource.name=defaultDataSource 72 | # 数据库连接地址: 73 | spring.datasource.url=jdbc:mysql://{host}:{port}/test_db?serverTimezone=UTC 74 | # 数据库用户名&密码: 75 | spring.datasource.username=****** 76 | spring.datasource.password=****** 77 | # 数据库驱动: 78 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 79 | ---- 80 | 您可以在阿里云工作台的 https://rdsnext.console.aliyun.com[数据库管理] 中查看自己数据库的链接地址、用户名&密码 81 | 82 | NOTE: 请一定注意,保持:服务端版本、驱动版本、驱动类名的一致;mysql5 和 mysql8的driver-class-name是不一样的,对应mysql8的driver-class-name为com.mysql.cj.jdbc.Driver。 83 | 84 | 配置数据库连接池 85 | [source,properties] 86 | ---- 87 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 88 | spring.datasource.druid.name=defaultDataSource 89 | spring.datasource.druid.max-active=20 90 | spring.datasource.druid.min-idle=2 91 | spring.datasource.druid.initial-size=2 92 | ---- 93 | 94 | === 参考资料 95 | https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/[Spring Boot 配置说明] 96 | 97 | https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE[Druid连接池典型配置样例] -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-redis-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/redis/actuate/endpoint/AbstractRedisEndpoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.alibaba.cloud.spring.boot.redis.actuate.endpoint; 18 | 19 | import com.alibaba.cloud.spring.boot.context.env.AliCloudProperties; 20 | import com.alibaba.cloud.spring.boot.redis.env.RedisProperties; 21 | import com.aliyuncs.DefaultAcsClient; 22 | import com.aliyuncs.IAcsClient; 23 | import com.aliyuncs.profile.DefaultProfile; 24 | 25 | import java.util.concurrent.Callable; 26 | 27 | import static com.aliyuncs.profile.DefaultProfile.getProfile; 28 | 29 | /** 30 | * The abstract implementation for Alibaba Cloud Redis 31 | * 32 | * @author Mercy 33 | * @since 1.0.0 34 | */ 35 | public abstract class AbstractRedisEndpoint { 36 | 37 | private final AliCloudProperties aliCloudProperties; 38 | 39 | private final RedisProperties redisProperties; 40 | 41 | public AbstractRedisEndpoint(AliCloudProperties aliCloudProperties, 42 | RedisProperties redisProperties) { 43 | this.aliCloudProperties = aliCloudProperties; 44 | this.redisProperties = redisProperties; 45 | } 46 | 47 | public AliCloudProperties getAliCloudProperties() { 48 | return aliCloudProperties; 49 | } 50 | 51 | public String getAccessKey() { 52 | return getAliCloudProperties().getAccessKey(); 53 | } 54 | 55 | public String getSecretKey() { 56 | return getAliCloudProperties().getSecretKey(); 57 | } 58 | 59 | protected IAcsClient createIAcsClient(String regionId) { 60 | DefaultProfile profile = getProfile(regionId, getAccessKey(), getSecretKey()); 61 | return new DefaultAcsClient(profile); 62 | } 63 | 64 | protected Object execute(Callable task) { 65 | Object result = null; 66 | try { 67 | result = task.call(); 68 | } 69 | catch (Exception e) { 70 | result = e; 71 | } 72 | return result; 73 | } 74 | 75 | public String getInstanceId() { 76 | return redisProperties.getInstanceId(); 77 | } 78 | 79 | public String getDefaultRegionID() { 80 | return redisProperties.getDefaultRegionId(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-samples 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | aliyun-compileflow-spring-boot-sample 15 | jar 16 | 17 | Aliyun Spring Boot :: Samples :: Compileflow 18 | Spring Boot Sample for Aliyun Compileflow 19 | 20 | 21 | 2.2.5.RELEASE 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-dependencies 32 | ${spring-boot.version} 33 | pom 34 | import 35 | 36 | 37 | 38 | 39 | com.alibaba.cloud 40 | aliyun-spring-boot-dependencies 41 | ${revision} 42 | pom 43 | import 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-web 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-starter-actuator 61 | 62 | 63 | 64 | 65 | com.alibaba.cloud 66 | aliyun-compileflow-spring-boot-starter 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | ${spring-boot.version} 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/BroadcastJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import java.util.Map; 20 | import java.util.Map.Entry; 21 | import java.util.Random; 22 | 23 | import org.springframework.stereotype.Component; 24 | 25 | import com.alibaba.schedulerx.common.domain.TaskStatus; 26 | import com.alibaba.schedulerx.worker.domain.JobContext; 27 | import com.alibaba.schedulerx.worker.processor.JavaProcessor; 28 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 29 | 30 | /** 31 | * 广播任务demo,分布式模型需要选择broadcast 32 | * 33 | * @author xiaomeng.hxm 34 | */ 35 | @Component 36 | public class BroadcastJob extends JavaProcessor { 37 | 38 | /** 39 | * 所有机器同时执行process方法 40 | */ 41 | @Override 42 | public ProcessResult process(JobContext context) throws Exception { 43 | int value = new Random().nextInt(10); 44 | System.out.println("分片总数=" + context.getShardingNum() + ", 分片号=" + context.getShardingId() + ", " 45 | + "taskId=" + context.getTaskId() + ", value=" + value); 46 | return new ProcessResult(true, String.valueOf(value)); 47 | } 48 | 49 | /** 50 | * 所有机器执行process方法之前,只有一台机器执行一次 51 | */ 52 | @Override 53 | public void preProcess(JobContext context) { 54 | System.out.println("this is preProcess"); 55 | } 56 | 57 | /** 58 | * 所有机器执行process之后,只有一台机器执行一次 59 | */ 60 | @Override 61 | public ProcessResult postProcess(JobContext context) { 62 | System.out.println("TestBroadcastJob.postProcess"); 63 | Map allTaskResults = context.getTaskResults(); 64 | Map allTaskStatuses = context.getTaskStatuses(); 65 | int num = 0; 66 | for (Entry entry : allTaskResults.entrySet()) { 67 | System.out.println(entry.getKey() + ":" + entry.getValue()); 68 | if (allTaskStatuses.get(entry.getKey()).equals(TaskStatus.SUCCESS)) { 69 | num += Integer.valueOf(entry.getValue()); 70 | } 71 | } 72 | System.out.println("TestBroadcastJob.postProcess(), num=" + num); 73 | return new ProcessResult(true, String.valueOf(num)); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-compileflow-spring-boot-sample/README_zh.md: -------------------------------------------------------------------------------- 1 | # Aliyun Spring Boot Compileflow 示例 2 | 3 | ## 1. 项目说明 4 | 5 | `compileflow`是一个非常轻量、高性能、可集成、可扩展的流程引擎。 6 | 7 | `compileflow Process`引擎是淘宝工作流`TBBPM`引擎之一,是专注于纯内存执行,无状态的流程引擎,通过将流程文件转换生成`java`代码编译执行,简洁高效。当前是阿里业务中台交易等多个核心系统的流程引擎。 8 | 9 | `compileflow`能让开发人员通过流程编辑器设计自己的业务流程,将复杂的业务逻辑可视化,为业务设计人员与开发工程师架起了一座桥梁。 10 | 11 | 更多相关信息,请参考 [compileflow](https://github.com/alibaba/compileflow)。 12 | 13 | ## 2. Quick Start 14 | 15 | ### Step1: 下载安装`IntelliJ IDEA`插件(可选) 16 | 17 | 插件下载地址:https://github.com/alibaba/compileflow-idea-designer 18 | 19 | *安装说明:请使用`IntelliJ IDEA`本地安装方法进行安装,重新启动`IntelliJ IDEA`就会生效。* 20 | 21 | ### Step2: 引入`POM`文件 22 | 23 | ```xml 24 | 25 | com.alibaba.cloud 26 | aliyun-compileflow-spring-boot-starter 27 | 28 | ``` 29 | 30 | **注意**: `compileflow`仅支持`JDK 1.8`及以上版本。 31 | 32 | ### Step3: 流程设计 33 | 34 | 下面以ktv demo为例,通过demo的演示和实践了解节点及属性的配置和`API`的使用。 35 | 36 | demo描述:N个人去ktv唱歌,每人唱首歌,ktv消费原价为30元/人,如果总价超过300打九折,小于300按原价付款。 37 | 38 | #### S3.1 39 | 40 | 创建`bpm`文件,如下图: 41 | ![ktv_demo_s1](https://github.com/alibaba/compileflow/blob/master/doc/image/ktv_demo_s1.png) 42 | 43 | *注:`bpm`文件路径要和`code`保持一致,在文件加载模式下流程引擎执行时会根据`code`找到文件。* 44 | 45 | #### S3.2 46 | 47 | 通过插件进行流程设计或者直接编写流程`xml`文件。 48 | 49 | #### S3.3 调用流程 50 | 51 | 编写如下单元测试: 52 | 53 | ```java 54 | public void testProcessEngine() { 55 | final String code = "bpm.ktv.ktvExample"; 56 | 57 | final Map context = new HashMap<>(); 58 | final List pList = new ArrayList<>(); 59 | pList.add("wuxiang"); 60 | pList.add("xuan"); 61 | pList.add("yusu"); 62 | context.put("pList", pList); 63 | 64 | final ProcessEngine processEngine = ProcessEngineFactory.getProcessEngine(); 65 | 66 | final TbbpmModel tbbpmModel = processEngine.load(code); 67 | final OutputStream outputStream = TbbpmModelConverter.getInstance().convertToStream(tbbpmModel); 68 | System.out.println(outputStream); 69 | System.out.println(processEngine.getTestCode(code)); 70 | 71 | processEngine.preCompile(code); 72 | 73 | System.out.println(processEngine.start(code, context)); 74 | } 75 | ``` 76 | 77 | **_`compileflow`原生只支持淘宝`BPM`规范,为兼容`BPMN 2.0`规范,做了一定适配,但仅支持部分`BPMN 2.0`元素,如需其他元素支持,可在原来基础上扩展。_** 78 | 79 | ## 3. 更多资料 80 | 81 | * [DEMO快速开始](https://github.com/alibaba/compileflow/wiki/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8BDEMO) 82 | * [原始淘宝BPM规范详细说明](https://github.com/alibaba/compileflow/wiki/%E5%8D%8F%E8%AE%AE%E8%AF%A6%E8%A7%A3) 83 | 84 | ## 4. 欢迎加入`compileflow`开发群 85 | 86 | 1. 请钉钉联系 @余苏 @徐工 @梵度 @哲良 @无相 87 | 88 | ## Known Users 89 | 90 | 如果您在使用,请让我们知道,您的使用对我们非常重要。请在下面链接的issue中回复:https://github.com/alibaba/compileflow/issues/9 91 | 92 | ![](doc/image/known_users/alibaba.png) 93 | ![](doc/image/known_users/alipay.png) 94 | ![](doc/image/known_users/aliyun.png) 95 | ![](doc/image/known_users/taobao.png) 96 | ![](doc/image/known_users/tmall.png) 97 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-redis-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.alibaba.cloud 9 | aliyun-spring-boot-samples 10 | ${revision} 11 | ../pom.xml 12 | 13 | 14 | aliyun-redis-spring-boot-sample 15 | jar 16 | 17 | Aliyun Spring Boot :: Samples :: Redis 18 | Spring Boot Sample for Aliyun Redis 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-dependencies 29 | ${spring-boot.version} 30 | pom 31 | import 32 | 33 | 34 | 35 | 36 | com.alibaba.cloud 37 | aliyun-spring-boot-dependencies 38 | ${revision} 39 | pom 40 | import 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-web 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-actuator 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-starter-data-redis 63 | 64 | 65 | 66 | 67 | com.alibaba.cloud 68 | aliyun-redis-spring-boot-starter 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | ${spring-boot.version} 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-schedulerx-spring-boot-sample/src/main/java/com/alibaba/cloud/examples/schedulerx/job/ParallelJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.examples.schedulerx.job; 18 | 19 | import java.util.LinkedList; 20 | import java.util.List; 21 | 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | import org.springframework.stereotype.Component; 25 | 26 | import com.alibaba.cloud.examples.schedulerx.domain.ParallelAccountInfo; 27 | import com.alibaba.fastjson.JSON; 28 | import com.alibaba.schedulerx.common.util.StringUtils; 29 | import com.alibaba.schedulerx.worker.domain.JobContext; 30 | import com.alibaba.schedulerx.worker.processor.MapReduceJobProcessor; 31 | import com.alibaba.schedulerx.worker.processor.ProcessResult; 32 | 33 | /** 34 | * 可视化的分布式任务,分布式模型需要选择并行计算 35 | * 可以看到每个子任务级别的状态、结果和日志 36 | * 可以给每个子任务定义label,支持通过label搜索,比如通过每个子任务是一个卡号,通过卡号搜索 37 | * 38 | * @author yaohui 39 | * @create 2021/10/21 下午8:12 40 | **/ 41 | @Component 42 | public class ParallelJob extends MapReduceJobProcessor { 43 | 44 | private static final Logger logger = LoggerFactory.getLogger("schedulerx"); 45 | 46 | @Override 47 | public ProcessResult reduce(JobContext context) throws Exception { 48 | return new ProcessResult(true); 49 | } 50 | 51 | @Override 52 | public ProcessResult process(JobContext context) throws Exception { 53 | if(isRootTask(context)){ 54 | logger.info("构建并行计算的子任务列表..."); 55 | List list = new LinkedList(); 56 | /** 57 | * 判断如果是rootTask的情况下,构建并行计算子任务对象列表 58 | * 在实际业务场景中,用户可自行根据业务场景加载子任务对象且该业务对象实现BizSubTask接口 59 | * 场景案例: 60 | * 1、从数据库中加载未被处理的客户账户信息 61 | * 2、构建省份城市地区信息列表,按区域分发任务处理 62 | * 3、根据业务标签作为子任务分类,如:电器、日用品、食品等 63 | * 4、可根据时间作为子任务分类,如:按月(1月、2月...) 64 | */ 65 | for(int i=0; i < 20; i++){ 66 | list.add(new ParallelAccountInfo(i, "CUS"+StringUtils.leftPad(i+"", 4, "0"), 67 | "AC"+StringUtils.leftPad(i+"", 12, "0"))); 68 | } 69 | return map(list, "transfer"); 70 | }else { 71 | /** 72 | * 非rootTask,用户可以获取对应的子任务信息进行相应的业务处理 73 | */ 74 | ParallelAccountInfo obj = (ParallelAccountInfo)context.getTask(); 75 | // 针对获取的 obj子任务信息,进行业务逻辑处理 76 | // do something 77 | logger.info("处理子任务信息:{}", JSON.toJSONString(obj)); 78 | return new ProcessResult(true); 79 | } 80 | } 81 | 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-oss-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/oss/resource/OssStorageProtocolResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.oss.resource; 18 | 19 | import com.aliyun.oss.OSS; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | import org.springframework.beans.BeansException; 23 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 24 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 25 | import org.springframework.context.ResourceLoaderAware; 26 | import org.springframework.core.io.DefaultResourceLoader; 27 | import org.springframework.core.io.ProtocolResolver; 28 | import org.springframework.core.io.Resource; 29 | import org.springframework.core.io.ResourceLoader; 30 | 31 | /** 32 | * A {@link ProtocolResolver} implementation for the {@code oss://} protocol. 33 | * 34 | * @author Jim 35 | */ 36 | public class OssStorageProtocolResolver 37 | implements ProtocolResolver, BeanFactoryPostProcessor, ResourceLoaderAware { 38 | 39 | /** 40 | * protocol of oss resource. 41 | */ 42 | public static final String PROTOCOL = "oss://"; 43 | 44 | private static final Logger log = LoggerFactory 45 | .getLogger(OssStorageProtocolResolver.class); 46 | 47 | private ConfigurableListableBeanFactory beanFactory; 48 | 49 | private OSS oss; 50 | 51 | private OSS getOSS() { 52 | if (this.oss == null) { 53 | if (this.beanFactory.getBeansOfType(OSS.class).size() > 1) { 54 | log.warn( 55 | "There are multiple OSS instances, consider marking one of them as @Primary to resolve oss " 56 | + "protocol."); 57 | } 58 | this.oss = this.beanFactory.getBean(OSS.class); 59 | } 60 | return this.oss; 61 | } 62 | 63 | @Override 64 | public Resource resolve(String location, ResourceLoader resourceLoader) { 65 | if (!location.startsWith(PROTOCOL)) { 66 | return null; 67 | } 68 | return new OssStorageResource(getOSS(), location, beanFactory); 69 | } 70 | 71 | @Override 72 | public void setResourceLoader(ResourceLoader resourceLoader) { 73 | if (DefaultResourceLoader.class.isAssignableFrom(resourceLoader.getClass())) { 74 | ((DefaultResourceLoader) resourceLoader).addProtocolResolver(this); 75 | } 76 | else { 77 | log.warn("The provided delegate resource loader is not an implementation " 78 | + "of DefaultResourceLoader. Custom Protocol using oss:// prefix will not be enabled."); 79 | } 80 | } 81 | 82 | @Override 83 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) 84 | throws BeansException { 85 | this.beanFactory = beanFactory; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /aliyun-spring-boot-samples/aliyun-rds-spring-boot-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 8 | 9 | com.alibaba.cloud 10 | aliyun-spring-boot-samples 11 | ${revision} 12 | ../pom.xml 13 | 14 | 15 | aliyun-rds-spring-boot-sample 16 | jar 17 | 18 | Aliyun Spring Boot :: Samples :: RDS 19 | Spring Boot Sample for Aliyun RDS 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-dependencies 30 | ${spring-boot.version} 31 | pom 32 | import 33 | 34 | 35 | 36 | 37 | com.alibaba.cloud 38 | aliyun-spring-boot-dependencies 39 | ${revision} 40 | pom 41 | import 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-starter-web 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-starter-actuator 58 | 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-starter-jdbc 64 | 65 | 66 | com.alibaba.cloud 67 | aliyun-rds-spring-boot-starter 68 | 69 | 70 | 71 | mysql 72 | mysql-connector-java 73 | 8.0.28 74 | 75 | 76 | com.alibaba 77 | druid-spring-boot-starter 78 | 1.1.17 79 | 80 | 81 | 82 | 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-maven-plugin 87 | ${spring-boot.version} 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /aliyun-spring-boot-starters/aliyun-fc-spring-boot-starter/src/main/java/com/alibaba/cloud/spring/boot/fc/HttpRequestFCSpringFunctionInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.alibaba.cloud.spring.boot.fc; 18 | 19 | import java.io.IOException; 20 | import java.util.Enumeration; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import java.util.Map.Entry; 24 | import javax.servlet.ServletInputStream; 25 | import javax.servlet.http.HttpServletRequest; 26 | import javax.servlet.http.HttpServletResponse; 27 | 28 | import org.springframework.messaging.Message; 29 | 30 | import com.aliyun.fc.runtime.Context; 31 | import com.aliyun.fc.runtime.HttpRequestHandler; 32 | 33 | /** 34 | * @author Jim 35 | */ 36 | public class HttpRequestFCSpringFunctionInvoker extends AbstractAliyunFCInvoker implements HttpRequestHandler { 37 | 38 | @Override 39 | public void handleRequest(HttpServletRequest request, HttpServletResponse response, Context context) throws IOException { 40 | this.initialize(context); 41 | 42 | Class paramTtype = getInputType(); 43 | 44 | if (RequestResponsePair.class.isAssignableFrom(paramTtype)) { 45 | doInvoke(new RequestResponsePair(request, response)); 46 | } else if (InputOutputPair.class.isAssignableFrom(paramTtype)) { 47 | doInvoke(new InputOutputPair(request.getInputStream(), response.getOutputStream())); 48 | } else { 49 | ServletInputStream input = request.getInputStream(); 50 | 51 | Map headers = generateHeader(request); 52 | 53 | Object result = doInvokeAsStream(input, headers); 54 | 55 | if (functionReturnsMessage(result)) { 56 | Message respMsg = (Message) result; 57 | response.setStatus(HttpServletResponse.SC_OK); 58 | response.getWriter().write(serializeBody(respMsg.getPayload())); 59 | for (Entry header : respMsg.getHeaders().entrySet()) { 60 | response.setHeader(header.getKey(), header.getValue().toString()); 61 | } 62 | } else { 63 | response.setStatus(HttpServletResponse.SC_OK); 64 | response.getWriter().write(serializeBody(result)); 65 | } 66 | } 67 | } 68 | 69 | private Map generateHeader(HttpServletRequest request) { 70 | Map map = new HashMap(); 71 | 72 | Enumeration enumeration = request.getHeaderNames(); 73 | 74 | while (enumeration.hasMoreElements()) { 75 | String key = enumeration.nextElement(); 76 | map.put(key, request.getHeader(key)); 77 | } 78 | return map; 79 | } 80 | } 81 | --------------------------------------------------------------------------------