13 | * Created by zhezhiyong@163.com on 2017/9/25.
14 | */
15 | public class DBOperation {
16 |
17 | private DruidPooledConnection con = null;//数据库连接
18 |
19 | private void open() throws SQLException {
20 | con = DBPoolConnection.getInstance().getConnection();
21 | }
22 |
23 | public void close() {
24 | if (this.con != null) {
25 | try {
26 | this.con.close();
27 | } catch (SQLException e) {
28 | e.printStackTrace();
29 | }
30 | }
31 | }
32 |
33 |
34 | /**
35 | * sql语句参数转化
36 | *
37 | * @param sql sql语句
38 | * @param params 参数
39 | * @throws SQLException sql异常
40 | * @throws ClassNotFoundException sql异常
41 | */
42 | private PreparedStatement setPres(String sql, HashMap params) throws SQLException, ClassNotFoundException {
43 | if (null == params || params.size() < 1) {
44 | return null;
45 | }
46 | PreparedStatement pres = this.con.prepareStatement(sql);
47 | for (int i = 1; i <= params.size(); i++) {
48 | if (params.get(i) == null) {
49 | pres.setString(i, "");
50 | } else if (params.get(i).getClass() == Class.forName("java.lang.String")) {
51 | pres.setString(i, params.get(i).toString());
52 | } else if (params.get(i).getClass() == Class.forName("java.lang.Integer")) {
53 | pres.setInt(i, (Integer) params.get(i));
54 | } else if (params.get(i).getClass() == Class.forName("java.lang.Long")) {
55 | pres.setLong(i, (Long) params.get(i));
56 | } else if (params.get(i).getClass() == Class.forName("java.lang.Double")) {
57 | pres.setDouble(i, (Double) params.get(i));
58 | } else if (params.get(i).getClass() == Class.forName("java.lang.Flaot")) {
59 | pres.setFloat(i, (Float) params.get(i));
60 | } else if (params.get(i).getClass() == Class.forName("java.lang.Boolean")) {
61 | pres.setBoolean(i, (Boolean) params.get(i));
62 | } else if (params.get(i).getClass() == Class.forName("java.sql.Date")) {
63 | pres.setDate(i, java.sql.Date.valueOf(params.get(i).toString()));
64 | } else {
65 | return null;
66 | }
67 | }
68 | return pres;
69 | }
70 |
71 | /**
72 | * @param sql sql语句
73 | */
74 | public int executeUpdate(String sql) throws SQLException {
75 | this.open();
76 | Statement state = this.con.createStatement();
77 | return state.executeUpdate(sql);
78 | }
79 |
80 | /**
81 | * @param sql sql语句
82 | * @param params 参数
83 | */
84 | public int executeUpdate(String sql, HashMap params) throws SQLException, ClassNotFoundException {
85 | this.open();
86 | PreparedStatement pres = setPres(sql, params);
87 | if (null == pres) {
88 | return 0;
89 | }
90 | return pres.executeUpdate();
91 | }
92 |
93 | /**
94 | * @param sql sql语句
95 | */
96 | public ResultSet executeQuery(String sql) throws SQLException {
97 | this.open();
98 | Statement state = this.con.createStatement();
99 | return state.executeQuery(sql);
100 | }
101 |
102 | /**
103 | * @param sql sql语句
104 | */
105 | public ResultSet executeQuery(String sql, HashMap params) throws SQLException, ClassNotFoundException {
106 | this.open();
107 | PreparedStatement pres = setPres(sql, params);
108 | if (null == pres) {
109 | return null;
110 | }
111 | return pres.executeQuery();
112 | }
113 |
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/guava-cache/src/main/java/com/km/db/DBUtil.java:
--------------------------------------------------------------------------------
1 | package com.km.db;
2 |
3 | import java.sql.ResultSet;
4 | import java.sql.SQLException;
5 | import java.util.HashMap;
6 |
7 | /**
8 | *
9 | * Created by zhezhiyong@163.com on 2017/9/25.
10 | */
11 | public class DBUtil {
12 | private DBOperation dbOperation;
13 |
14 | public DBUtil() {
15 | dbOperation = new DBOperation();
16 | }
17 |
18 | /**
19 | * 关闭数据库连接
20 | */
21 | public void close() {
22 | dbOperation.close();
23 | }
24 |
25 | /**
26 | * 数据库新增操作
27 | */
28 | public int insert(String sql) throws SQLException {
29 | return dbOperation.executeUpdate(sql);
30 | }
31 |
32 | /**
33 | * 数据库新增操作
34 | *
35 | * @param tableName 表名
36 | * @param columns 字段名
37 | * @param params 参数
38 | */
39 | public int insert(String tableName, String columns, HashMap params) throws SQLException, ClassNotFoundException {
40 | String sql = insertSql(tableName, columns);
41 | return dbOperation.executeUpdate(sql, params);
42 | }
43 |
44 | /**
45 | * 数据库删除操作
46 | */
47 | public int delete(String sql) throws SQLException {
48 | return dbOperation.executeUpdate(sql);
49 | }
50 |
51 | /**
52 | * 数据库删除操作
53 | *
54 | * @param tableName 表名
55 | * @param condition 条件
56 | */
57 | public int delete(String tableName, String condition) throws SQLException {
58 | if (null == tableName) {
59 | return 0;
60 | }
61 | String sql = "delete from " + tableName + " " + condition;
62 | return dbOperation.executeUpdate(sql);
63 | }
64 |
65 | /**
66 | * 数据库更新操作
67 | */
68 | public int update(String sql) throws SQLException {
69 | return dbOperation.executeUpdate(sql);
70 | }
71 |
72 | /**
73 | * 数据库更新操作
74 | *
75 | * @param tableName 表名
76 | * @param columns 字段
77 | * @param condition 条件
78 | * @param params 参数
79 | */
80 | public int update(String tableName, String columns, String condition, HashMap params) throws SQLException, ClassNotFoundException {
81 | String sql = updateSql(tableName, columns, condition);
82 | return dbOperation.executeUpdate(sql, params);
83 | }
84 |
85 | /**
86 | * 数据库查询操作
87 | */
88 | public ResultSet select(String sql) throws SQLException {
89 | return dbOperation.executeQuery(sql);
90 | }
91 |
92 | /**
93 | * 数据库查询操作
94 | *
95 | * @param tableName 表名
96 | * @param columns 字段
97 | * @param condition 条件
98 | */
99 | public ResultSet select(String tableName, String columns, String condition) throws SQLException {
100 | String sql = "select " + columns + " from " + tableName + " " + condition;
101 | return dbOperation.executeQuery(sql);
102 | }
103 |
104 | /**
105 | * 组装 update sql eg: update tableName set column1=?,column2=? condition
106 | *
107 | * @param tableName 表名
108 | * @param columns 字段
109 | * @param condition 条件
110 | */
111 | private String updateSql(String tableName, String columns, String condition) {
112 | if (tableName == null || columns == null) {
113 | return "";
114 | }
115 | String[] column = columns.split(",");
116 | StringBuilder sb = new StringBuilder();
117 | sb.append("update ");
118 | sb.append(tableName);
119 | sb.append(" set ");
120 | sb.append(column[0]);
121 | sb.append("=?");
122 | for (int i = 1; i < column.length; i++) {
123 | sb.append(", ");
124 | sb.append(column[i]);
125 | sb.append("=?");
126 | }
127 | sb.append(" ");
128 | sb.append(condition);
129 | return sb.toString();
130 | }
131 |
132 | /**
133 | * 组装 insert sql eg: insert into tableName (column1, column2) values (?,?)
134 | *
135 | * @param tableName 表名
136 | * @param columns 字段
137 | */
138 | private String insertSql(String tableName, String columns) {
139 | if (tableName == null || columns == null) {
140 | return "";
141 | }
142 | int n = columns.split(",").length;
143 | StringBuilder sb = new StringBuilder("");
144 | sb.append("insert into ");
145 | sb.append(tableName);
146 | sb.append(" (");
147 | sb.append(columns);
148 | sb.append(") values (?");
149 | for (int i = 1; i < n; i++) {
150 | sb.append(",?");
151 | }
152 | sb.append(")");
153 | return sb.toString();
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/spring-boot2-multi-redis-cache/src/main/java/com/zy/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package com.zy.config;
2 |
3 | import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
4 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
5 | import com.fasterxml.jackson.annotation.PropertyAccessor;
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.beans.factory.annotation.Qualifier;
11 | import org.springframework.beans.factory.annotation.Value;
12 | import org.springframework.boot.context.properties.ConfigurationProperties;
13 | import org.springframework.cache.CacheManager;
14 | import org.springframework.cache.annotation.CachingConfigurerSupport;
15 | import org.springframework.cache.annotation.EnableCaching;
16 | import org.springframework.context.annotation.Bean;
17 | import org.springframework.context.annotation.Configuration;
18 | import org.springframework.context.annotation.Primary;
19 | import org.springframework.context.annotation.Scope;
20 | import org.springframework.data.redis.cache.RedisCacheConfiguration;
21 | import org.springframework.data.redis.cache.RedisCacheManager;
22 | import org.springframework.data.redis.connection.RedisConnectionFactory;
23 | import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
24 | import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
25 | import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
26 | import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
27 | import org.springframework.data.redis.core.StringRedisTemplate;
28 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
29 | import org.springframework.data.redis.serializer.RedisSerializationContext;
30 | import org.springframework.data.redis.serializer.RedisSerializer;
31 | import org.springframework.data.redis.serializer.StringRedisSerializer;
32 |
33 | import java.time.Duration;
34 |
35 | /**
36 | *
37 | * Created by @author zhezhiyong@163.com on 2019/3/29.
38 | */
39 | @Configuration
40 | @EnableCaching
41 | @Slf4j
42 | public class RedisConfig extends CachingConfigurerSupport {
43 |
44 | @Value("${spring.application.name:unknown}")
45 | private String appName;
46 | @Value("${spring.redis.timeToLive:15}")
47 | private Long timeToLive;
48 |
49 | @Bean
50 | @ConfigurationProperties(prefix = "spring.redis.lettuce.pool")
51 | @Scope(value = "prototype")
52 | public GenericObjectPoolConfig redisPool() {
53 | return new GenericObjectPoolConfig();
54 | }
55 |
56 | @Bean
57 | @ConfigurationProperties(prefix = "spring.redis.redis-a")
58 | public RedisStandaloneConfiguration redisConfigA() {
59 | return new RedisStandaloneConfiguration();
60 | }
61 |
62 | @Bean
63 | @ConfigurationProperties(prefix = "spring.redis.redis-b")
64 | public RedisStandaloneConfiguration redisConfigB() {
65 | return new RedisStandaloneConfiguration();
66 | }
67 |
68 | @Bean
69 | @Primary
70 | public LettuceConnectionFactory factoryA(GenericObjectPoolConfig config, RedisStandaloneConfiguration redisConfigA) {
71 | LettuceClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder()
72 | .poolConfig(config).commandTimeout(Duration.ofMillis(config.getMaxWaitMillis())).build();
73 | return new LettuceConnectionFactory(redisConfigA, clientConfiguration);
74 | }
75 |
76 | @Bean
77 | public LettuceConnectionFactory factoryB(GenericObjectPoolConfig config, RedisStandaloneConfiguration redisConfigB) {
78 | LettuceClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder()
79 | .poolConfig(config).commandTimeout(Duration.ofMillis(config.getMaxWaitMillis())).build();
80 | return new LettuceConnectionFactory(redisConfigB, clientConfiguration);
81 | }
82 |
83 | @Bean(name = "redisTemplateA")
84 | public StringRedisTemplate redisTemplateA(LettuceConnectionFactory factoryA) {
85 | StringRedisTemplate template = new StringRedisTemplate(factoryA);
86 | RedisSerializer redisSerializer = new StringRedisSerializer();
87 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
88 | ObjectMapper om = new ObjectMapper();
89 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
90 | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
91 | jackson2JsonRedisSerializer.setObjectMapper(om);
92 | template.setKeySerializer(redisSerializer);
93 | template.setValueSerializer(jackson2JsonRedisSerializer);
94 | template.setHashValueSerializer(jackson2JsonRedisSerializer);
95 | return template;
96 | }
97 |
98 | @Bean(name = "redisTemplateB")
99 | public StringRedisTemplate redisTemplateB(@Autowired @Qualifier("factoryB") LettuceConnectionFactory factoryB) {
100 | StringRedisTemplate template = new StringRedisTemplate(factoryB);
101 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
102 | ObjectMapper om = new ObjectMapper();
103 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
104 | // 将类名称序列化到json串中
105 | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
106 | jackson2JsonRedisSerializer.setObjectMapper(om);
107 | template.setValueSerializer(jackson2JsonRedisSerializer);
108 | template.afterPropertiesSet();
109 | return template;
110 | }
111 |
112 | @Bean
113 | public CacheManager cacheManager(RedisConnectionFactory factory) {
114 | RedisSerializer redisSerializer = new StringRedisSerializer();
115 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
116 | ObjectMapper om = new ObjectMapper();
117 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
118 | // 将类名称序列化到json串中
119 | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
120 | jackson2JsonRedisSerializer.setObjectMapper(om);
121 |
122 | // 配置序列化
123 | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
124 | .entryTtl(Duration.ofMinutes(timeToLive))
125 | .prefixKeysWith(appName + ":");
126 | RedisCacheConfiguration redisCacheConfiguration = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
127 | .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer));
128 | RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
129 | .cacheDefaults(redisCacheConfiguration)
130 | .build();
131 | return cacheManager;
132 | }
133 |
134 | // RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
135 | // configuration.prefixKeysWith("bda");
136 | // configuration = configuration.entryTtl(Duration.ofMinutes(30));
137 | // Set cacheNames = new HashSet<>();
138 | // cacheNames.add("test1");
139 | // cacheNames.add("test2");
140 | // Map configurationMap = new HashMap<>(10);
141 | // configurationMap.put("test1", configuration);
142 | // configurationMap.put("test2", configuration.entryTtl(Duration.ofMinutes(60)));
143 | // RedisCacheManager manager = RedisCacheManager.builder(factory)
144 | // .initialCacheNames(cacheNames)
145 | // .withInitialCacheConfigurations(configurationMap)
146 | // .build();
147 | // return manager;
148 |
149 | private StringRedisTemplate getRedisTemplate() {
150 | StringRedisTemplate template = new StringRedisTemplate();
151 | template.setValueSerializer(new GenericFastJsonRedisSerializer());
152 | template.setValueSerializer(new StringRedisSerializer());
153 | return template;
154 | }
155 |
156 | // @Bean
157 | // public CacheManager cacheManager(RedisConnectionFactory factory) {
158 | // RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
159 | // configuration.prefixKeysWith("bda");
160 | // configuration = configuration.entryTtl(Duration.ofMinutes(30));
161 | // Set cacheNames = new HashSet<>();
162 | // cacheNames.add("test1");
163 | // cacheNames.add("test2");
164 | // Map configurationMap = new HashMap<>(10);
165 | // configurationMap.put("test1", configuration);
166 | // configurationMap.put("test2", configuration.entryTtl(Duration.ofMinutes(60)));
167 | // RedisCacheManager manager = RedisCacheManager.builder(factory)
168 | // .initialCacheNames(cacheNames)
169 | // .withInitialCacheConfigurations(configurationMap)
170 | // .build();
171 | // return manager;
172 | // }
173 |
174 | // @Bean
175 | // public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
176 | // StringRedisTemplate template = new StringRedisTemplate(factory);
177 | // Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
178 | // ObjectMapper om = new ObjectMapper();
179 | // om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
180 | // om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
181 | // jackson2JsonRedisSerializer.setObjectMapper(om);
182 | // template.setValueSerializer(jackson2JsonRedisSerializer);
183 | // template.afterPropertiesSet();
184 | // return template;
185 | // }
186 | //
187 | // @Autowired
188 | // private RedisProperties redisProperties;
189 | //
190 | //
191 | // @Bean
192 | // @ConfigurationProperties(prefix = "spring.redis3")
193 | // public RedisStandaloneConfiguration redis3(){
194 | // return new RedisStandaloneConfiguration();
195 | // }
196 | //
197 | //
198 | // @Bean(name = "db3redisTemplate")
199 | // public RedisTemplate db3RedisTemplate() {
200 | // log.info("redisProperties:{}", JSON.toJSONString(redisProperties));
201 | // RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
202 | // configuration.setDatabase(3);
203 | // configuration.setHostName(redisProperties.getHost());
204 | // configuration.setPort(redisProperties.getPort());
205 | // LettuceClientConfiguration.LettuceClientConfigurationBuilder lettuceClientConfigurationBuilder = LettuceClientConfiguration.builder();
206 | // LettuceConnectionFactory factory = new LettuceConnectionFactory(configuration, lettuceClientConfigurationBuilder.build());
207 | //
208 | // StringRedisTemplate template = new StringRedisTemplate(factory);
209 | // Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
210 | // ObjectMapper om = new ObjectMapper();
211 | // om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
212 | // om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
213 | // jackson2JsonRedisSerializer.setObjectMapper(om);
214 | // template.setValueSerializer(jackson2JsonRedisSerializer);
215 | // template.afterPropertiesSet();
216 | // return template;
217 | // }
218 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------