├── src └── main │ ├── resources │ └── META-INF │ │ ├── spring.provides │ │ └── spring.factories │ └── java │ └── io │ └── dubbo │ └── springboot │ ├── DubboConfigurationApplicationContextInitializer.java │ ├── DubboHolderListener.java │ ├── DubboProperties.java │ └── DubboAutoConfiguration.java ├── .gitignore ├── README.md ├── pom.xml └── LICENSE /src/main/resources/META-INF/spring.provides: -------------------------------------------------------------------------------- 1 | provides: spring-boot-starter-dubbo -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationContextInitializer=\ 2 | io.dubbo.springboot.DubboConfigurationApplicationContextInitializer 3 | org.springframework.context.ApplicationListener=\ 4 | io.dubbo.springboot.DubboHolderListener 5 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 6 | io.dubbo.springboot.DubboAutoConfiguration -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # maven ignore 2 | target/ 3 | *.jar 4 | *.war 5 | *.zip 6 | *.tar 7 | *.tar.gz 8 | 9 | # eclipse ignore 10 | .settings/ 11 | .project 12 | .classpath 13 | 14 | # idea ignore 15 | .idea/ 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # temp ignore 21 | *.log 22 | *.cache 23 | *.diff 24 | *.patch 25 | *.tmp 26 | 27 | # system ignore 28 | .DS_Store 29 | Thumbs.db 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/io/dubbo/springboot/DubboConfigurationApplicationContextInitializer.java: -------------------------------------------------------------------------------- 1 | package io.dubbo.springboot; 2 | 3 | import com.alibaba.dubbo.config.spring.AnnotationBean; 4 | import org.springframework.beans.BeanUtils; 5 | import org.springframework.context.ApplicationContextInitializer; 6 | import org.springframework.context.ConfigurableApplicationContext; 7 | import org.springframework.core.env.Environment; 8 | 9 | public class DubboConfigurationApplicationContextInitializer implements ApplicationContextInitializer { 10 | 11 | @Override 12 | public void initialize(ConfigurableApplicationContext applicationContext) { 13 | Environment env = applicationContext.getEnvironment(); 14 | String scan = env.getProperty("spring.dubbo.scan"); 15 | if (scan != null) { 16 | AnnotationBean scanner = BeanUtils.instantiate(AnnotationBean.class); 17 | scanner.setPackage(scan); 18 | scanner.setApplicationContext(applicationContext); 19 | applicationContext.addBeanFactoryPostProcessor(scanner); 20 | applicationContext.getBeanFactory().addBeanPostProcessor(scanner); 21 | applicationContext.getBeanFactory().registerSingleton("annotationBean", scanner); 22 | } 23 | 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/io/dubbo/springboot/DubboHolderListener.java: -------------------------------------------------------------------------------- 1 | package io.dubbo.springboot; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.context.event.ApplicationPreparedEvent; 6 | import org.springframework.context.ApplicationEvent; 7 | import org.springframework.context.ApplicationListener; 8 | import org.springframework.context.event.ContextClosedEvent; 9 | 10 | /** 11 | * @author xiaofei.wxf(teaey) 12 | * @since 0.0.0 13 | */ 14 | @SuppressWarnings("rawtypes") 15 | public class DubboHolderListener implements ApplicationListener { 16 | private static final Logger LOGGER = LoggerFactory.getLogger(DubboHolderListener.class); 17 | 18 | private static Thread holdThread; 19 | private static Boolean running = Boolean.FALSE; 20 | 21 | @Override 22 | public void onApplicationEvent(ApplicationEvent event) { 23 | if (event instanceof ApplicationPreparedEvent) { 24 | if (running == Boolean.FALSE) 25 | running = Boolean.TRUE; 26 | if (holdThread == null) { 27 | holdThread = new Thread(new Runnable() { 28 | @Override 29 | public void run() { 30 | if (LOGGER.isTraceEnabled()) { 31 | LOGGER.trace(Thread.currentThread().getName()); 32 | } 33 | while (running && !Thread.currentThread().isInterrupted()) { 34 | try { 35 | Thread.sleep(2000); 36 | } catch (InterruptedException e) { 37 | } 38 | } 39 | } 40 | }, "Dubbo-Holder"); 41 | holdThread.setDaemon(false); 42 | holdThread.start(); 43 | } 44 | } 45 | if (event instanceof ContextClosedEvent) { 46 | running = Boolean.FALSE; 47 | if (null != holdThread) { 48 | holdThread.interrupt(); 49 | holdThread = null; 50 | } 51 | } 52 | } 53 | 54 | public static void stopApplicationContext(Boolean stop){ 55 | running = stop.booleanValue(); 56 | if (null != holdThread) { 57 | holdThread.interrupt(); 58 | holdThread = null; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/io/dubbo/springboot/DubboProperties.java: -------------------------------------------------------------------------------- 1 | package io.dubbo.springboot; 2 | 3 | import com.alibaba.dubbo.config.ApplicationConfig; 4 | import com.alibaba.dubbo.config.ConsumerConfig; 5 | import com.alibaba.dubbo.config.MethodConfig; 6 | import com.alibaba.dubbo.config.ModuleConfig; 7 | import com.alibaba.dubbo.config.MonitorConfig; 8 | import com.alibaba.dubbo.config.ProtocolConfig; 9 | import com.alibaba.dubbo.config.ProviderConfig; 10 | import com.alibaba.dubbo.config.RegistryConfig; 11 | import org.springframework.boot.context.properties.ConfigurationProperties; 12 | 13 | @ConfigurationProperties(prefix = "spring.dubbo") 14 | public class DubboProperties { 15 | 16 | private String scan; 17 | 18 | private ApplicationConfig application; 19 | 20 | private RegistryConfig registry; 21 | 22 | private ProtocolConfig protocol; 23 | 24 | private MonitorConfig monitor; 25 | 26 | private ProviderConfig provider; 27 | 28 | private ModuleConfig module; 29 | 30 | private MethodConfig method; 31 | 32 | private ConsumerConfig consumer; 33 | 34 | public String getScan() { 35 | return scan; 36 | } 37 | 38 | public void setScan(String scan) { 39 | this.scan = scan; 40 | } 41 | 42 | public ApplicationConfig getApplication() { 43 | return application; 44 | } 45 | 46 | public void setApplication(ApplicationConfig application) { 47 | this.application = application; 48 | } 49 | 50 | public RegistryConfig getRegistry() { 51 | return registry; 52 | } 53 | 54 | public void setRegistry(RegistryConfig registry) { 55 | this.registry = registry; 56 | } 57 | 58 | public ProtocolConfig getProtocol() { 59 | return protocol; 60 | } 61 | 62 | public void setProtocol(ProtocolConfig protocol) { 63 | this.protocol = protocol; 64 | } 65 | 66 | public MonitorConfig getMonitor() { 67 | return monitor; 68 | } 69 | 70 | public void setMonitor(MonitorConfig monitor) { 71 | this.monitor = monitor; 72 | } 73 | 74 | public ProviderConfig getProvider() { 75 | return provider; 76 | } 77 | 78 | public void setProvider(ProviderConfig provider) { 79 | this.provider = provider; 80 | } 81 | 82 | public ModuleConfig getModule() { 83 | return module; 84 | } 85 | 86 | public void setModule(ModuleConfig module) { 87 | this.module = module; 88 | } 89 | 90 | public MethodConfig getMethod() { 91 | return method; 92 | } 93 | 94 | public void setMethod(MethodConfig method) { 95 | this.method = method; 96 | } 97 | 98 | public ConsumerConfig getConsumer() { 99 | return consumer; 100 | } 101 | 102 | public void setConsumer(ConsumerConfig consumer) { 103 | this.consumer = consumer; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/io/dubbo/springboot/DubboAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.dubbo.springboot; 2 | 3 | import com.alibaba.dubbo.config.ApplicationConfig; 4 | import com.alibaba.dubbo.config.ConsumerConfig; 5 | import com.alibaba.dubbo.config.MethodConfig; 6 | import com.alibaba.dubbo.config.ModuleConfig; 7 | import com.alibaba.dubbo.config.MonitorConfig; 8 | import com.alibaba.dubbo.config.ProtocolConfig; 9 | import com.alibaba.dubbo.config.ProviderConfig; 10 | import com.alibaba.dubbo.config.RegistryConfig; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | 16 | @Configuration 17 | @EnableConfigurationProperties(DubboProperties.class) 18 | public class DubboAutoConfiguration { 19 | 20 | @Autowired 21 | private DubboProperties dubboProperties; 22 | 23 | @Bean 24 | public ApplicationConfig requestApplicationConfig() { 25 | ApplicationConfig applicationConfig = dubboProperties.getApplication(); 26 | if (applicationConfig == null) { 27 | applicationConfig = new ApplicationConfig(); 28 | } 29 | return applicationConfig; 30 | } 31 | 32 | @Bean 33 | public RegistryConfig requestRegistryConfig() { 34 | RegistryConfig registryConfig = dubboProperties.getRegistry(); 35 | if (registryConfig == null) { 36 | registryConfig = new RegistryConfig(); 37 | } 38 | return registryConfig; 39 | } 40 | 41 | @Bean 42 | public ProtocolConfig requestProtocolConfig() { 43 | ProtocolConfig protocolConfig = dubboProperties.getProtocol(); 44 | if (protocolConfig == null) { 45 | protocolConfig = new ProtocolConfig(); 46 | } 47 | return protocolConfig; 48 | } 49 | 50 | @Bean 51 | public MonitorConfig requestMonitorConfig() { 52 | MonitorConfig monitorConfig = dubboProperties.getMonitor(); 53 | if (monitorConfig == null) { 54 | monitorConfig = new MonitorConfig(); 55 | } 56 | return monitorConfig; 57 | } 58 | 59 | @Bean 60 | public ProviderConfig requestProviderConfig() { 61 | ProviderConfig providerConfig = dubboProperties.getProvider(); 62 | if (providerConfig == null) { 63 | providerConfig = new ProviderConfig(); 64 | } 65 | return providerConfig; 66 | } 67 | 68 | @Bean 69 | public ModuleConfig requestModuleConfig() { 70 | ModuleConfig moduleConfig = dubboProperties.getModule(); 71 | if (moduleConfig == null) { 72 | moduleConfig = new ModuleConfig(); 73 | } 74 | return moduleConfig; 75 | } 76 | 77 | @Bean 78 | public MethodConfig requestMethodConfig() { 79 | MethodConfig methodConfig = dubboProperties.getMethod(); 80 | if (methodConfig == null) { 81 | methodConfig = new MethodConfig(); 82 | } 83 | return methodConfig; 84 | } 85 | 86 | @Bean 87 | public ConsumerConfig requestConsumerConfig() { 88 | ConsumerConfig consumerConfig = dubboProperties.getConsumer(); 89 | if (consumerConfig == null) { 90 | consumerConfig = new ConsumerConfig(); 91 | } 92 | return consumerConfig; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-starter-dubbo 2 | 3 | 4 | spring-boot-start-dubbo,让你可以使用spring-boot的方式开发dubbo程序。使dubbo开发变得如此简单。 5 | 6 | 让你可以使用`spring-boot`的方式开发`dubbo`程序。使`dubbo`开发变得如此简单。 7 | 8 | ## 如何使用 9 | 10 | ### 1. `clone`代码(可选,已经发布到中央仓库,可以直接依赖[中央仓库的稳定版本](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.dubbo.springboot%22%20AND%20a%3A%22spring-boot-starter-dubbo%22)) 11 | 12 | ```sh 13 | git clone git@github.com:teaey/spring-boot-starter-dubbo.git 14 | ``` 15 | 16 | ### 2. 编译安装(可选) 17 | 18 | ```sh 19 | cd spring-boot-starter-dubbo 20 | mvn clean install 21 | ``` 22 | 23 | ### 3. 修改`maven`配置文件(可以参考样例[`spring-boot-starter-dubbo-sample`](https://github.com/teaey/spring-boot-starter-dubbo-sample)) 24 | 25 | * 在`spring boot`项目的`pom.xml`增加`parent`: 26 | 27 | ```xml 28 | 29 | org.springframework.boot 30 | spring-boot-starter-parent 31 | 1.3.6.RELEASE 32 | 33 | ``` 34 | 35 | * 在`spring boot`项目的`pom.xml`中添加以下依赖: 36 | 37 | 根据实际情况依赖最新版本 38 | 39 | ```xml 40 | 41 | io.dubbo.springboot 42 | spring-boot-starter-dubbo 43 | 1.0.0 44 | 45 | ``` 46 | 47 | * `maven`插件用于打包成可执行的`uber-jar`文件,添加以下插件(这里一定要加载需要打包成`jar`的`mudule`的`pom`中) 48 | 49 | ```xml 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 1.3.6.RELEASE 54 | 55 | ``` 56 | 57 | ### 4. 发布服务 58 | 59 | 服务接口: 60 | 61 | ```java 62 | package cn.teaey.sprintboot.test; 63 | 64 | public interface EchoService { 65 | String echo(String str); 66 | } 67 | 68 | ``` 69 | 70 | 71 | 在`application.properties`添加`Dubbo`的版本信息和客户端超时信息,如下: 72 | 73 | ```properties 74 | spring.dubbo.application.name=provider 75 | spring.dubbo.registry.address=zookeeper://192.168.99.100:32770 76 | spring.dubbo.protocol.name=dubbo 77 | spring.dubbo.protocol.port=20880 78 | spring.dubbo.scan=cn.teaey.sprintboot.test 79 | ``` 80 | 81 | 82 | 在`Spring Application`的`application.properties`中添加`spring.dubbo.scan`即可支持`Dubbo`服务发布,其中`scan`表示要扫描的`package`目录。 83 | 84 | * `spring boot`启动 85 | 86 | ```java 87 | package cn.teaey.sprintboot.test; 88 | 89 | import org.springframework.boot.SpringApplication; 90 | import org.springframework.boot.autoconfigure.SpringBootApplication; 91 | 92 | @SpringBootApplication 93 | public class Server { 94 | public static void main(String[] args) { 95 | SpringApplication.run(Server.class, args); 96 | } 97 | } 98 | 99 | ``` 100 | 101 | * 编写你的`Dubbo`服务,只需要添加要发布的服务实现上添加`@Service`,如下: 102 | 103 | ```java 104 | package cn.teaey.sprintboot.test; 105 | 106 | import com.alibaba.dubbo.config.annotation.Service; 107 | 108 | @Service(version = "1.0.0") 109 | public class EchoServerImpl implements EchoService { 110 | 111 | public String echo(String str) { 112 | System.out.println(str); 113 | return str; 114 | } 115 | } 116 | 117 | ``` 118 | 119 | ### 5. 消费`Dubbo`服务 120 | 121 | * 在`application.properties`添加`Dubbo`的版本信息和客户端超时信息,如下: 122 | 123 | ```properties 124 | spring.dubbo.application.name=consumer 125 | spring.dubbo.registry.address=zookeeper://192.168.99.100:32770 126 | spring.dubbo.scan=cn.teaey.sprintboot.test 127 | ``` 128 | 129 | 在`Spring Application`的`application.properties`中添加`spring.dubbo.scan`即可支持`Dubbo`服务发布,其中`scan`表示要扫描的`package`目录。 130 | 131 | * `spring boot`启动 132 | 133 | ```java 134 | package cn.teaey.sprintboot.test; 135 | 136 | import org.springframework.boot.SpringApplication; 137 | import org.springframework.boot.autoconfigure.SpringBootApplication; 138 | import org.springframework.context.ConfigurableApplicationContext; 139 | 140 | @SpringBootApplication 141 | public class Client { 142 | public static void main(String[] args) { 143 | ConfigurableApplicationContext run = SpringApplication.run(Client.class, args); 144 | AbcService bean = run.getBean(AbcService.class); 145 | System.out.println(bean.echoService.echo("abccc")); 146 | } 147 | } 148 | 149 | ``` 150 | 151 | * 引用`Dubbo`服务,只需要添加要发布的服务实现上添加`@Reference`,如下: 152 | 153 | ```java 154 | package cn.teaey.sprintboot.test; 155 | 156 | import com.alibaba.dubbo.config.annotation.Reference; 157 | import org.springframework.stereotype.Component; 158 | 159 | @Component 160 | public class AbcService { 161 | @Reference(version = "1.0.0") 162 | public EchoService echoService; 163 | } 164 | ``` 165 | 166 | ### 6. `monitor`监控中心 167 | * 在`application.properties`添加`monitor`监控中心配置(服务端和消费端相同),如下: 168 | 169 | ```properties 170 | spring.dubbo.monitor.protocol=registry 171 | ``` 172 | 173 | ### 7. 打包 174 | 175 | - 可以直接执行`Server`或者`Client`启动 176 | - 可以通过`mvn clean package`打包成可执行的`uber-jar`文件 177 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.3.6.RELEASE 8 | 9 | 10 | io.dubbo.springboot 11 | spring-boot-starter-dubbo 12 | 1.0.0 13 | 14 | jar 15 | https://github.com/teaey/spring-boot-starter-dubbo 16 | spring-boot-starter-dubbo 17 | 18 | 19 | 1.8 20 | UTF-8 21 | UTF-8 22 | 23 | 1.5.3.RELEASE 24 | 2.5.4-SNAPSHOT 25 | 0.10 26 | 27 | 3.5.1 28 | 2.2.1 29 | 2.9.1 30 | 1.5 31 | 32 | 33 | 34 | 35 | teaey(Xiaofei.Wu) 36 | masfay@163.com 37 | teaey.github.com 38 | +8 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter 46 | 47 | 48 | com.alibaba 49 | dubbo 50 | ${dubbo.version} 51 | 52 | 53 | spring 54 | org.springframework 55 | 56 | 57 | 58 | 59 | com.101tec 60 | zkclient 61 | ${zkclient.version} 62 | 63 | 64 | slf4j-api 65 | org.slf4j 66 | 67 | 68 | log4j 69 | log4j 70 | 71 | 72 | slf4j-log4j12 73 | org.slf4j 74 | 75 | 76 | 77 | 78 | org.springframework.boot 79 | spring-boot-configuration-processor 80 | true 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-dependencies 88 | ${spring-boot.version} 89 | pom 90 | import 91 | 92 | 93 | 94 | 95 | 96 | 97 | release 98 | 99 | 100 | 101 | org.apache.maven.plugins 102 | maven-compiler-plugin 103 | ${version.compiler-plugin} 104 | 105 | ${java.version} 106 | ${java.version} 107 | ${java.version} 108 | 109 | 110 | 111 | org.apache.maven.plugins 112 | maven-source-plugin 113 | ${version.source-plugin} 114 | 115 | 116 | package 117 | 118 | jar-no-fork 119 | 120 | 121 | 122 | 123 | 124 | org.apache.maven.plugins 125 | maven-javadoc-plugin 126 | ${version.javadoc-plugin} 127 | 128 | 129 | package 130 | 131 | jar 132 | 133 | 134 | 135 | 136 | 137 | org.apache.maven.plugins 138 | maven-gpg-plugin 139 | ${version.maven-gpg-plugin} 140 | 141 | 142 | verify 143 | 144 | sign 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | ossrh 154 | https://oss.sonatype.org/content/repositories/snapshots/ 155 | 156 | 157 | ossrh 158 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /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 | 203 | --------------------------------------------------------------------------------