├── docs ├── customer-onboarding-extended.png └── customer-onboarding-simple.png ├── .github └── dependabot.yml ├── src ├── main │ ├── resources │ │ ├── application.properties │ │ ├── static │ │ │ └── index.html │ │ └── customer-onboarding.bpmn │ └── java │ │ └── io │ │ └── berndruecker │ │ └── onboarding │ │ └── customer │ │ ├── process │ │ ├── ProcessConstants.java │ │ ├── ScoringAdapter.java │ │ └── CustomerOnboardingGlueCode.java │ │ ├── rest │ │ ├── RestConfiguration.java │ │ └── CustomerOnboardingRestController.java │ │ ├── CustomerOnboardingSpringbootApplication.java │ │ └── fakes │ │ └── CrmServiceRestController.java └── test │ └── java │ └── io │ └── berndruecker │ └── onboarding │ └── customer │ └── TestCustomerOnboardingProcess.java ├── .gitignore ├── README.md ├── pom.xml └── LICENSE /docs/customer-onboarding-extended.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berndruecker/customer-onboarding-camunda-8-springboot/HEAD/docs/customer-onboarding-extended.png -------------------------------------------------------------------------------- /docs/customer-onboarding-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berndruecker/customer-onboarding-camunda-8-springboot/HEAD/docs/customer-onboarding-simple.png -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Cloud Credentials 2 | zeebe.client.cloud.clusterId=ecfdea92-2eae-467c-bcdd-4a28120d0d5a 3 | zeebe.client.cloud.clientId=OwWI_Dn~f57LZTuuHpmpmgKBmp72b0v6 4 | zeebe.client.cloud.clientSecret=eMc3GfBrneJkC_.vhbTWyfn393YBU8KLSfc_KK-L2YHtbgtcQ~NwlRaWK_youvFx 5 | 6 | recipient.demo.email=demo@yourdoamin.com -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/process/ProcessConstants.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.process; 2 | 3 | public class ProcessConstants { 4 | 5 | public static final String VAR_SCORING_REQUEST_ID = "scoringRequestId"; 6 | public static final String VAR_SCORING_RETRY_COUNT = "scoringRetryCount"; 7 | public static final String VAR_SCORING_RESULT = "scoringResult"; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/rest/RestConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.rest; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.client.RestTemplate; 6 | 7 | @Configuration 8 | public class RestConfiguration { 9 | 10 | @Bean 11 | public RestTemplate restTemplate() { 12 | return new RestTemplate(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/CustomerOnboardingSpringbootApplication.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer; 2 | 3 | import io.camunda.zeebe.spring.client.EnableZeebeClient; 4 | import io.camunda.zeebe.spring.client.annotation.Deployment; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | @SpringBootApplication 9 | @Deployment(resources = "classpath:customer-onboarding.bpmn") 10 | public class CustomerOnboardingSpringbootApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(CustomerOnboardingSpringbootApplication.class, args); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Awesome website that allows to open a new bank account

5 | 6 |

Typically, some data would be collected here...

7 | 8 | 9 | 10 |
11 | 12 | 13 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/process/ScoringAdapter.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.process; 2 | 3 | import io.camunda.zeebe.spring.client.annotation.JobWorker; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | @Component 12 | public class ScoringAdapter { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(ScoringAdapter.class); 15 | 16 | @JobWorker 17 | public Map scoreCustomer() { 18 | HashMap resultVariables = new HashMap<>(); 19 | 20 | logger.info("score..."); 21 | resultVariables.put("score", 42); 22 | 23 | return resultVariables; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/fakes/CrmServiceRestController.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.fakes; 2 | 3 | import io.berndruecker.onboarding.customer.rest.CustomerOnboardingRestController; 4 | import io.camunda.zeebe.client.ZeebeClient; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.bind.annotation.PutMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.springframework.web.server.ServerWebExchange; 14 | 15 | @RestController 16 | public class CrmServiceRestController { 17 | 18 | private Logger logger = LoggerFactory.getLogger(CustomerOnboardingRestController.class); 19 | 20 | @PutMapping("/crm/customer") 21 | public ResponseEntity addCustomerToCrmFake(ServerWebExchange exchange) { 22 | logger.info("CRM REST API called"); 23 | return ResponseEntity.status(HttpStatus.OK).build(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/process/CustomerOnboardingGlueCode.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.process; 2 | 3 | import io.camunda.zeebe.spring.client.annotation.JobWorker; 4 | import io.camunda.zeebe.spring.client.annotation.Variable; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.client.RestTemplate; 10 | 11 | @Component 12 | public class CustomerOnboardingGlueCode { 13 | 14 | private static Logger logger = LoggerFactory.getLogger(CustomerOnboardingGlueCode.class); 15 | 16 | // This would be of course injected and depends on the environment. Hard coded for now 17 | public static String ENDPOINT_CRM = "http://localhost:8080/crm/customer"; 18 | 19 | @Autowired 20 | private RestTemplate restTemplate; 21 | 22 | @JobWorker(type = "addCustomerToCrm") 23 | public void addCustomerToCrm(@Variable String customerName) { 24 | System.out.println("Adding customer to CRM via REST: " + customerName); 25 | 26 | String request = "someData"; 27 | restTemplate.put(ENDPOINT_CRM, request); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/berndruecker/onboarding/customer/rest/CustomerOnboardingRestController.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer.rest; 2 | 3 | import java.util.HashMap; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.PutMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.server.ServerWebExchange; 12 | 13 | import io.camunda.zeebe.client.ZeebeClient; 14 | 15 | @RestController 16 | public class CustomerOnboardingRestController { 17 | 18 | @Autowired 19 | private ZeebeClient client; 20 | 21 | @Value("${recipient.demo.email}") 22 | private String recipientDemoEmail; 23 | 24 | @PutMapping("/customer") 25 | public ResponseEntity onboardCustomer(ServerWebExchange exchange) { 26 | onboardCustomer(); 27 | return ResponseEntity.status(HttpStatus.ACCEPTED).build(); 28 | } 29 | 30 | public void onboardCustomer() { 31 | HashMap variables = new HashMap(); 32 | variables.put("automaticProcessing", true); 33 | variables.put("someInput", "yeah"); 34 | variables.put("customerName", "Bernd Ruecker"); 35 | variables.put("customerEmail", recipientDemoEmail); 36 | 37 | client.newCreateInstanceCommand() // 38 | .bpmnProcessId("customer-onboarding") // 39 | .latestVersion() // 40 | .variables(variables) // 41 | .send().join(); 42 | } 43 | 44 | public static class CustomerOnboardingResponse { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Customer Onboarding Process 2 | 3 | *Process solution example for customer onboarding as used in the OReilly book [Practical Process Automation](https://processautomationbook.com/).* 4 | 5 | ![Customer Onboarding](docs/customer-onboarding-simple.png) 6 | 7 | This following stack is used: 8 | 9 | * Camunda Platform 8 10 | * Java 17 11 | * Spring Boot 3 12 | 13 | # Intro 14 | 15 | This simple onboarding process is meant to get started with process automation, workflow engines and BPMN. 16 | 17 | The process model contains three tasks: 18 | 19 | * A service task that executes Java Code to score customers (using the stateless Camunda DMN engine) 20 | * A user task so that humans can approve customer orders (or not) 21 | * A service task that executes glue code to call the REST API of a CRM system 22 | 23 | The process solution is a Maven project and contains: 24 | 25 | * The onboarding process model as BPMN 26 | * Source code to provide a REST endpoint for clients 27 | * Java code to do the customer scoring 28 | * Glue code to implement the REST call to the CRM system 29 | * Fake for CRM system providing a REST API that can be called (to allow running this example self-contained) 30 | 31 | 32 | # How To Run 33 | 34 | Walkthrough 35 | 36 | ## Create Camunda Platform 8 Cluster 37 | 38 | The easiest way to try out Camunda is to create a cluster in the SaaS environment: 39 | 40 | * Login to https://camunda.io/ (you can create an account on the fly) 41 | * Create a new cluster 42 | * Create a new set of API client credentials 43 | * Copy the client credentials into `src/main/resources/application.properties` 44 | 45 | 46 | ## Run Spring Boot Java Application 47 | 48 | The application will deploy the process model during startup 49 | 50 | `mvn package exec:java` 51 | 52 | 53 | ## Play 54 | 55 | You can easily use the application by requesting a new customer onboarding posting a PUT REST request to 56 | 57 | `curl -X PUT http://localhost:8080/customer` 58 | 59 | You can now see the process instance in Camunda Operate - linked via the Cloud Console. 60 | 61 | You can work on the user task using Camunda Tasklist, also linked via the Cloud Console. 62 | 63 | 64 | 65 | # Extended Process 66 | 67 | There is also an extended process model that adds some more tasks in the process: 68 | 69 | ![Customer Onboarding](docs/customer-onboarding-extended.png) 70 | 71 | You can find that in another repository on GitHub: https://github.com/berndruecker/customer-onboarding-camundacloud-springboot-extended -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.berndruecker 7 | customer-onboarding-camunda-8-springboot 8 | 0.0.1-SNAPSHOT 9 | 10 | Customer Onboarding Example Using Camunda 8 and Spring Boot 11 | 12 | 13 | 17 14 | 17 15 | 3.1.5 16 | 8.3.0 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-dependencies 24 | ${spring.boot.version} 25 | pom 26 | import 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-webflux 35 | 36 | 37 | io.camunda 38 | zeebe-client-java 39 | ${zeebe.version} 40 | 41 | 42 | io.camunda 43 | spring-zeebe-starter 44 | ${zeebe.version} 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | org.junit.vintage 54 | junit-vintage-engine 55 | 56 | 57 | 58 | 59 | io.camunda.spring 60 | spring-boot-starter-camunda-test 61 | ${zeebe.version} 62 | test 63 | 64 | 65 | 66 | 67 | 68 | org.webjars 69 | jquery 70 | 3.6.1 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.springframework.boot 78 | spring-boot-maven-plugin 79 | 80 | 81 | org.apache.maven.plugins 82 | maven-surefire-plugin 83 | 84 | 85 | org.codehaus.mojo 86 | exec-maven-plugin 87 | 88 | io.berndruecker.onboarding.customer.CustomerOnboardingSpringbootApplication 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/test/java/io/berndruecker/onboarding/customer/TestCustomerOnboardingProcess.java: -------------------------------------------------------------------------------- 1 | package io.berndruecker.onboarding.customer; 2 | 3 | import io.berndruecker.onboarding.customer.rest.CustomerOnboardingRestController; 4 | import io.camunda.zeebe.client.ZeebeClient; 5 | import io.camunda.zeebe.client.api.response.ActivatedJob; 6 | import io.camunda.zeebe.process.test.api.ZeebeTestEngine; 7 | import io.camunda.zeebe.process.test.inspections.InspectionUtility; 8 | import io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance; 9 | import io.camunda.zeebe.spring.test.ZeebeSpringTest; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.http.HttpMethod; 15 | import org.springframework.http.MediaType; 16 | import org.springframework.test.web.client.MockRestServiceServer; 17 | import org.springframework.web.client.RestTemplate; 18 | 19 | import java.time.Duration; 20 | import java.util.Collections; 21 | import java.util.HashMap; 22 | import java.util.List; 23 | import java.util.Map; 24 | import java.util.concurrent.TimeoutException; 25 | 26 | import static io.camunda.zeebe.process.test.assertions.BpmnAssert.assertThat; 27 | import static io.camunda.zeebe.protocol.Protocol.USER_TASK_JOB_TYPE; 28 | import static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.waitForProcessInstanceCompleted; 29 | import static org.junit.jupiter.api.Assertions.assertEquals; 30 | import static org.junit.jupiter.api.Assertions.assertTrue; 31 | import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; 32 | import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; 33 | import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; 34 | 35 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) 36 | @ZeebeSpringTest 37 | public class TestCustomerOnboardingProcess { 38 | 39 | @Autowired 40 | private CustomerOnboardingRestController customerOnboardingRestController; 41 | 42 | @Autowired 43 | private RestTemplate restTemplate; 44 | 45 | private MockRestServiceServer mockRestServer; 46 | 47 | @BeforeEach 48 | public void init() { 49 | // Class level @AutoConfigureMockRestServiceServer does not work for me, so initializing it manually 50 | mockRestServer = MockRestServiceServer.createServer(restTemplate); 51 | } 52 | 53 | @Test 54 | public void testAutomaticOnboarding() throws Exception { 55 | // Define expectations on the REST calls 56 | // 1. http://localhost:8080/crm/customer 57 | mockRestServer 58 | .expect(requestTo("http://localhost:8080/crm/customer")) // 59 | .andExpect(method(HttpMethod.PUT)) 60 | .andRespond(withSuccess("{\"customerId\": \"12345\"}", MediaType.APPLICATION_JSON)); 61 | 62 | // given a REST call 63 | customerOnboardingRestController.onboardCustomer(); 64 | 65 | // Retrieve process instances started because of the above call 66 | InspectedProcessInstance processInstance = InspectionUtility.findProcessInstances().findLastProcessInstance().get(); 67 | 68 | // We expect to have a user task 69 | waitForUserTaskAndComplete("TaskApproveCustomerOrder", Collections.singletonMap("approved", true)); 70 | 71 | // Now the process should run to the end 72 | waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(10)); 73 | 74 | // Let's assert that it passed certain BPMN elements (more to show off features here) 75 | assertThat(processInstance) 76 | .hasPassedElement("EndEventProcessed") 77 | .isCompleted(); 78 | 79 | // And verify it caused the right side effects on the REST endpoints 80 | mockRestServer.verify(); 81 | } 82 | 83 | /** 84 | * This code should eventually be provided by spring-zeebe-test 85 | */ 86 | 87 | @Autowired 88 | private ZeebeTestEngine zeebeTestEngine; 89 | @Autowired 90 | private ZeebeClient zeebeClient; 91 | 92 | public void waitForUserTaskAndComplete(String userTaskId) throws InterruptedException, TimeoutException { 93 | waitForUserTaskAndComplete(userTaskId, new HashMap<>()); 94 | } 95 | 96 | public void waitForUserTaskAndComplete(String userTaskId, Map variables) throws InterruptedException, TimeoutException { 97 | // Let the workflow engine do whatever it needs to do 98 | zeebeTestEngine.waitForIdleState(Duration.ofSeconds(10)); 99 | 100 | // Now get all user tasks 101 | List jobs = zeebeClient.newActivateJobsCommand().jobType(USER_TASK_JOB_TYPE).maxJobsToActivate(1).workerName("waitForUserTaskAndComplete").send().join().getJobs(); 102 | 103 | // Should be only one 104 | assertTrue(jobs.size()>0, "Job for user task '" + userTaskId + "' does not exist"); 105 | ActivatedJob userTaskJob = jobs.get(0); 106 | // Make sure it is the right one 107 | if (userTaskId!=null) { 108 | assertEquals(userTaskId, userTaskJob.getElementId()); 109 | } 110 | 111 | // And complete it passing the variables 112 | if (variables!=null && variables.size()>0) { 113 | zeebeClient.newCompleteCommand(userTaskJob.getKey()).variables(variables).send().join(); 114 | } else { 115 | zeebeClient.newCompleteCommand(userTaskJob.getKey()).send().join(); 116 | } 117 | } 118 | 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/main/resources/customer-onboarding.bpmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | { 6 | "components": [ 7 | { 8 | "label": "Some Input ", 9 | "type": "textfield", 10 | "id": "Field_1b2m8b7", 11 | "key": "someInput", 12 | "description": "Typically useful details about the application :-)", 13 | "disabled": true 14 | }, 15 | { 16 | "label": "Customer Score", 17 | "type": "textfield", 18 | "id": "Field_1fkt9v4", 19 | "key": "score", 20 | "disabled": true, 21 | "description": "Score derrived for this customer from out great scoring service" 22 | }, 23 | { 24 | "label": "Automatic Processing?", 25 | "type": "checkbox", 26 | "id": "Field_1n7851c", 27 | "key": "automaticProcessing", 28 | "description": "Can this application be processed automatically without further manual interaction?" 29 | } 30 | ], 31 | "type": "default", 32 | "id": "Form_0w8g0i0", 33 | "executionPlatform": "Camunda Cloud", 34 | "executionPlatformVersion": "8.0.0", 35 | "exporter": { 36 | "name": "Camunda Modeler", 37 | "version": "5.2.0" 38 | }, 39 | "schemaVersion": 4 40 | } 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Flow_015dit6 49 | 50 | 51 | 52 | 53 | 54 | Flow_015dit6 55 | Flow_0cxim98 56 | 57 | 58 | Flow_182g5kj 59 | SequenceFlowOrderAcceptedNo 60 | SequenceFlowOrderAcceptedYes 61 | 62 | 63 | SequenceFlowOrderAcceptedNo 64 | 65 | 66 | =(automaticProcessing = false) 67 | 68 | 69 | =( automaticProcessing=true ) 70 | 71 | 72 | Flow_0y7x6do 73 | 74 | 75 | 76 | 77 | 78 | 79 | SequenceFlowOrderAcceptedYes 80 | Flow_0y7x6do 81 | 82 | 83 | 84 | 85 | 86 | 87 | Flow_0cxim98 88 | Flow_182g5kj 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------