Skip to content

Commit

Permalink
Merge pull request #1419 from Wechat-Group/develop
Browse files Browse the repository at this point in the history
合并Develop分支代码,发布3.7.0正式版
  • Loading branch information
binarywang authored Feb 29, 2020
2 parents 13a3f58 + 1b66e77 commit 7bd4726
Show file tree
Hide file tree
Showing 243 changed files with 9,337 additions and 991 deletions.
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
<packaging>pom</packaging>
<name>WxJava - Weixin/Wechat Java SDK</name>
<description>微信开发Java SDK</description>
Expand Down Expand Up @@ -99,6 +99,7 @@
</scm>

<modules>
<module>weixin-graal</module>
<module>weixin-java-common</module>
<module>weixin-java-cp</module>
<module>weixin-java-mp</module>
Expand Down Expand Up @@ -172,7 +173,7 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.11</version>
<version>1.4.11.1</version>
</dependency>
<!-- 由于guava较新的21.0版本需要jdk8,故而此处采用较低版本 -->
<dependency>
Expand Down Expand Up @@ -242,6 +243,12 @@
<version>2.9.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down Expand Up @@ -325,6 +332,14 @@
</plugins>
</build>
</profile>

<profile>
<id>native-image</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
</profile>

</profiles>

<build>
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-starters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
</parent>
<packaging>pom</packaging>
<artifactId>wx-java-spring-boot-starters</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.6.0</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
7 changes: 6 additions & 1 deletion spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.6.0</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,6 +24,11 @@
<artifactId>jedis</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
Expand All @@ -26,6 +27,9 @@ public class WxMpStorageAutoConfiguration {
@Autowired(required = false)
private JedisPool jedisPool;

@Autowired(required = false)
private RedissonClient redissonClient;

@Bean
@ConditionalOnMissingBean(WxMpConfigStorage.class)
public WxMpConfigStorage wxMpInMemoryConfigStorage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.6.0</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,6 +24,11 @@
<artifactId>jedis</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage;
import me.chanjar.weixin.open.api.impl.WxOpenInRedissonConfigStorage;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.TransportMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -28,6 +33,9 @@ public class WxOpenStorageAutoConfiguration {
@Autowired(required = false)
private JedisPool jedisPool;

@Autowired(required = false)
private RedissonClient redissonClient;

@Value("${wx.open.config-storage.redis.host:}")
private String redisHost;

Expand All @@ -40,12 +48,20 @@ public WxOpenConfigStorage wxOpenConfigStorage() {
if (type == WxOpenProperties.StorageType.redis) {
return getWxOpenInRedisConfigStorage();
}

if (type == WxOpenProperties.StorageType.jedis) {
return getWxOpenInRedisConfigStorage();
}

if (type == WxOpenProperties.StorageType.redisson) {
return getWxOpenInRedissonConfigStorage();
}
return getWxOpenInMemoryConfigStorage();
}

private WxOpenInMemoryConfigStorage getWxOpenInMemoryConfigStorage() {
WxOpenInMemoryConfigStorage config = new WxOpenInMemoryConfigStorage();
setWxOpenInfo(config);
config.setWxOpenInfo(properties.getAppId(), properties.getSecret(), properties.getToken(), properties.getAesKey());
return config;
}

Expand All @@ -54,18 +70,22 @@ private WxOpenInRedisConfigStorage getWxOpenInRedisConfigStorage() {
if (jedisPool == null || StringUtils.isNotEmpty(redisHost)) {
poolToUse = getJedisPool();
}
WxOpenInRedisConfigStorage config = new WxOpenInRedisConfigStorage(poolToUse);
setWxOpenInfo(config);
WxOpenInRedisConfigStorage config = new WxOpenInRedisConfigStorage(poolToUse, properties.getConfigStorage().getKeyPrefix());
config.setWxOpenInfo(properties.getAppId(), properties.getSecret(), properties.getToken(), properties.getAesKey());
return config;
}

private void setWxOpenInfo(WxOpenConfigStorage config) {
config.setComponentAppId(properties.getAppId());
config.setComponentAppSecret(properties.getSecret());
config.setComponentToken(properties.getToken());
config.setComponentAesKey(properties.getAesKey());
private WxOpenInRedissonConfigStorage getWxOpenInRedissonConfigStorage() {
RedissonClient redissonClientToUse = this.redissonClient;
if (redissonClient == null) {
redissonClientToUse = getRedissonClient();
}
WxOpenInRedissonConfigStorage config = new WxOpenInRedissonConfigStorage(redissonClientToUse, properties.getConfigStorage().getKeyPrefix());
config.setWxOpenInfo(properties.getAppId(), properties.getSecret(), properties.getToken(), properties.getAesKey());
return config;
}


private JedisPool getJedisPool() {
WxOpenProperties.ConfigStorage storage = properties.getConfigStorage();
RedisProperties redis = storage.getRedis();
Expand All @@ -90,4 +110,16 @@ private JedisPool getJedisPool() {
redis.getTimeout(), redis.getPassword(), redis.getDatabase());
return pool;
}

private RedissonClient getRedissonClient() {
WxOpenProperties.ConfigStorage storage = properties.getConfigStorage();
RedisProperties redis = storage.getRedis();

Config config = new Config();
config.useSingleServer()
.setAddress("redis://" + redis.getHost() + ":" + redis.getPort())
.setPassword(redis.getPassword());
config.setTransportMode(TransportMode.NIO);
return Redisson.create(config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static class ConfigStorage implements Serializable {

private RedisProperties redis = new RedisProperties();

private String keyPrefix;

}

public enum StorageType {
Expand All @@ -63,6 +65,14 @@ public enum StorageType {
/**
* redis.
*/
redis
redis,
/**
* jedis.
*/
jedis,
/**
* redisson.
*/
redisson
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>wx-java-spring-boot-starters</artifactId>
<groupId>com.github.binarywang</groupId>
<version>3.6.0</version>
<version>3.7.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
40 changes: 40 additions & 0 deletions weixin-graal/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java</artifactId>
<version>3.7.0</version>
</parent>

<artifactId>weixin-graal</artifactId>
<name>WxJava - Graal</name>
<description>微信开发Java内部配合graal以产生native-image配置的辅助工具, 可以通过项目的 native-image Profile 来启用: mvn -P native-image ...
</description>

<dependencies>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<proc>none</proc>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 7bd4726

Please sign in to comment.