├── .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