Skip to content

Commit 12745ef

Browse files
committed
Merge branch '2.3.x'
2 parents c85848f + 27ed261 commit 12745ef

File tree

24 files changed

+238
-249
lines changed

24 files changed

+238
-249
lines changed

api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerAutoConfiguration.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
88
import org.springframework.boot.context.properties.EnableConfigurationProperties;
99
import org.springframework.context.annotation.Bean;
10+
import org.springframework.data.redis.connection.RedisConnectionFactory;
11+
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
1012

1113
import java.util.List;
1214
import java.util.stream.Collectors;
@@ -16,7 +18,7 @@
1618
*
1719
* @author 恒宇少年
1820
*/
19-
@ConditionalOnClass(ServerConfiguration.class)
21+
@ConditionalOnClass({ServerConfiguration.class, RedisMessageListenerContainer.class})
2022
@EnableConfigurationProperties(MessagePipeServerProperties.class)
2123
public class MessagePipeServerAutoConfiguration {
2224
private MessagePipeServerProperties messagePipeServerProperties;
@@ -36,6 +38,22 @@ public ServerConfiguration serverConfiguration() {
3638
return messagePipeServerProperties.getConfiguration();
3739
}
3840

41+
/**
42+
* Instantiate {@link RedisMessageListenerContainer}
43+
* <p>
44+
* This instance is required by the message pipeline, but here is just the default configuration
45+
*
46+
* @param redisConnectionFactory The {@link RedisConnectionFactory} redis connectory factory instance
47+
* @return The {@link RedisMessageListenerContainer} instance
48+
*/
49+
@Bean
50+
@ConditionalOnMissingBean
51+
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory) {
52+
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
53+
container.setConnectionFactory(redisConnectionFactory);
54+
return container;
55+
}
56+
3957
/**
4058
* Instantiate the wrapper class of {@link MessagePipeConfigurationCustomizer}
4159
*

api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/oauth/ApiBootOauthProperties.java

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.minbox.framework.api.boot.autoconfigure.oauth.ApiBootOauthProperties.API_BOOT_OAUTH_PREFIX;
2828

2929
/**
30-
* 整合Oauth2 相关属性配置
30+
* Configure Oauth2 properties class
3131
*
3232
* @author 恒宇少年
3333
*/
@@ -36,11 +36,13 @@
3636
@ConfigurationProperties(prefix = API_BOOT_OAUTH_PREFIX)
3737
public class ApiBootOauthProperties {
3838
/**
39-
* 安全配置前缀
39+
* config prefix
4040
*/
4141
public static final String API_BOOT_OAUTH_PREFIX = "api.boot.oauth";
4242
/**
43-
* Oauth2认证存储方式,默认内存方式
43+
* Configure oauth authentication information storage mode
44+
* <p>
45+
* The default use {@link OAuthAway#memory}
4446
*
4547
* @see OAuthAway
4648
*/
@@ -59,89 +61,36 @@ public class ApiBootOauthProperties {
5961
@Deprecated
6062
private String clientSecret = "ApiBootSecret";
6163
/**
62-
* 客户端授权类型集合
64+
* Configure simple client grant types
6365
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
6466
*/
6567
@Deprecated
6668
private String[] grantTypes = new String[]{"password", "refresh_token"};
6769
/**
68-
* 客户端作用域集合
70+
* Configure simple client scopes
6971
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
7072
*/
7173
@Deprecated
7274
private String[] scopes = new String[]{"api"};
7375
/**
74-
* 资源编号
76+
* Configure simple client resource id
7577
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
7678
*/
7779
@Deprecated
7880
private String resourceId = "api";
7981

8082
/**
81-
* 配置JWT格式化Oauth2返回的token
83+
* Configure to use jwt to format oauth token
8284
*/
8385
private Jwt jwt = new Jwt();
8486
/**
8587
* configure multiple clients
88+
* <p>
89+
* Add a client information by default and use the default configuration
8690
*/
87-
private List<Client> clients = new ArrayList() {{
88-
add(new Client());
89-
}};
90-
91-
/**
92-
* Oauth2 Client
93-
* Used to configure multiple clients
94-
*/
95-
@Data
96-
public static class Client {
97-
/**
98-
* oauth2 client id
99-
*/
100-
private String clientId = "ApiBoot";
101-
/**
102-
* oauth2 client secret
103-
*/
104-
private String clientSecret = "ApiBootSecret";
105-
/**
106-
* oauth2 client grant types
107-
* default value is "password,refresh_token"
108-
*/
109-
private String[] grantTypes = new String[]{"password", "refresh_token"};
110-
/**
111-
* oauth2 client scope
112-
* default value is "api"
113-
*/
114-
private String[] scopes = new String[]{"api"};
115-
/**
116-
* oauth2 application resource id
117-
* default value is "api"
118-
*/
119-
private String[] resourceId = new String[]{"api"};
120-
/**
121-
* oauth2 access token validity seconds
122-
* default value is 2 hours (7200 second)
123-
*/
124-
private int accessTokenValiditySeconds = 60 * 60 * 2;
125-
/**
126-
* oauth2 refresh token validity seconds
127-
* <p>
128-
* The default value is 30 days(2592000 seconds)
129-
*/
130-
private int refreshTokenValiditySeconds = 60 * 60 * 24 * 30;
131-
}
132-
133-
/**
134-
* 自定义Jwt相关的配置
135-
*/
136-
@Data
137-
public static class Jwt {
138-
/**
139-
* 开启Jwt转换AccessToken
140-
*/
141-
private boolean enable = false;
142-
/**
143-
* Jwt转换时使用的秘钥key
144-
*/
145-
private String signKey = "ApiBoot";
146-
}
91+
private List<OAuthClient> clients = new ArrayList() {
92+
{
93+
add(new OAuthClient());
94+
}
95+
};
14796
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.minbox.framework.api.boot.autoconfigure.oauth;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* The json web token config properties
7+
*
8+
* @author 恒宇少年
9+
*/
10+
@Data
11+
public class Jwt {
12+
/**
13+
* Enable the use of jwt formatting token
14+
*/
15+
private boolean enable = false;
16+
/**
17+
* The secret key used during conversion
18+
*/
19+
private String signKey = "ApiBoot";
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.minbox.framework.api.boot.autoconfigure.oauth;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* oauth client configuration class
7+
*
8+
* @author 恒宇少年
9+
*/
10+
@Data
11+
public class OAuthClient {
12+
/**
13+
* oauth2 client id
14+
*/
15+
private String clientId = "ApiBoot";
16+
/**
17+
* oauth2 client secret
18+
*/
19+
private String clientSecret = "ApiBootSecret";
20+
/**
21+
* oauth2 client grant types
22+
* default value is "password,refresh_token"
23+
*/
24+
private String[] grantTypes = new String[]{"password", "refresh_token"};
25+
/**
26+
* oauth2 client scope
27+
* default value is "api"
28+
*/
29+
private String[] scopes = new String[]{"api"};
30+
/**
31+
* oauth2 application resource id
32+
* default value is "api"
33+
*/
34+
private String[] resourceId = new String[]{"api"};
35+
/**
36+
* oauth2 access token validity seconds
37+
* default value is 2 hours (7200 second)
38+
*/
39+
private int accessTokenValiditySeconds = 60 * 60 * 2;
40+
/**
41+
* oauth2 refresh token validity seconds
42+
* <p>
43+
* The default value is 30 days(2592000 seconds)
44+
*/
45+
private int refreshTokenValiditySeconds = 60 * 60 * 24 * 30;
46+
}

api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/pageable/ApiBootMyBatisPageableProperties.java

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,15 @@
2222
import org.springframework.boot.context.properties.ConfigurationProperties;
2323
import org.springframework.context.annotation.Configuration;
2424

25-
import java.lang.reflect.Field;
2625
import java.util.Properties;
2726

2827
import static org.minbox.framework.api.boot.autoconfigure.pageable.ApiBootMyBatisPageableProperties.API_BOOT_PAGEABLE_PREFIX;
2928

3029

3130
/**
32-
* mybatis-pageable自动化配置属性
31+
* Mybatis pageable properties
3332
*
34-
* @author:于起宇 ===============================
35-
* Created with IDEA.
36-
* Date:2018/8/4
37-
* Time:2:22 PM
38-
* 简书:http://www.jianshu.com/u/092df3f77bca
39-
* ================================
33+
* @author 恒宇少年
4034
*/
4135
@Data
4236
@Configuration
@@ -47,39 +41,20 @@ public class ApiBootMyBatisPageableProperties {
4741
*/
4842
public static final String API_BOOT_PAGEABLE_PREFIX = "api.boot.pageable";
4943
/**
50-
* 数据库方言
51-
* 默认使用mysql数据库方言
44+
* The database dialect
45+
* <p>
46+
* default use {@link DialectEnum#MYSQL}
5247
*/
5348
private DialectEnum dialect = DialectEnum.MYSQL;
5449

5550
/**
56-
* 获取属性配置
51+
* Convert this instance to {@link Properties}
5752
*
58-
* @return 配置文件对象
53+
* @return The {@link Properties} config instance
5954
*/
60-
public Properties getProperties() {
61-
62-
// 返回的配置对象
55+
public Properties convertProperties() {
6356
Properties properties = new Properties();
64-
/*
65-
* 获取本类内创建的field列表
66-
* 添加到配置对象集合内
67-
*/
68-
Field[] fields = this.getClass().getDeclaredFields();
69-
for (Field field : fields) {
70-
try {
71-
field.setAccessible(true);
72-
// 数据库方言
73-
if ("dialect".equals(field.getName())) {
74-
properties.setProperty(field.getName(), dialect.getValue().getName());
75-
} else {
76-
properties.setProperty(field.getName(), String.valueOf(field.get(this)));
77-
}
78-
} catch (Exception e) {
79-
e.printStackTrace();
80-
}
81-
}
82-
57+
properties.setProperty(PropertiesNames.DATABASE_DIALECT, dialect.getValue().getName());
8358
return properties;
8459
}
8560
}

api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/pageable/ApiBootMybatisPageableAutoConfiguration.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@
3131

3232
import javax.annotation.PostConstruct;
3333
import java.util.List;
34+
import java.util.Properties;
3435

3536
/**
3637
* ApiBoot Mybatis Pageable Auto Configuration
3738
*
38-
* @author:恒宇少年 - 于起宇
39-
* <p>
40-
* DateTime:2019-04-25 14:53
41-
* Blog:http://blog.yuqiyu.com
42-
* WebSite:http://www.jianshu.com/u/092df3f77bca
43-
* Gitee:https://gitee.com/hengboy
44-
* GitHub:https://github.com/hengboy
39+
* @author 恒宇少年
4540
*/
4641
@Configuration
4742
@ConditionalOnBean(SqlSessionFactory.class)
@@ -50,9 +45,9 @@
5045
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
5146
public class ApiBootMybatisPageableAutoConfiguration {
5247
/**
53-
* myabtis pageable properties
48+
* mybatis pageable properties
5449
*/
55-
private ApiBootMyBatisPageableProperties myBatisPageableProperties;
50+
private ApiBootMyBatisPageableProperties pageableProperties;
5651
/**
5752
* mybatis sqlSession factory
5853
*/
@@ -65,7 +60,7 @@ public class ApiBootMybatisPageableAutoConfiguration {
6560
public ApiBootMybatisPageableAutoConfiguration(ApiBootMyBatisPageableProperties myBatisPageableProperties,
6661
ObjectProvider<List<SqlSessionFactory>> interceptorsProvider,
6762
ObjectProvider<PageableConfigurer> pageableConfigurerObjectProvider) {
68-
this.myBatisPageableProperties = myBatisPageableProperties;
63+
this.pageableProperties = myBatisPageableProperties;
6964
this.sqlSessionFactoryList = interceptorsProvider.getIfAvailable();
7065
this.pageableConfigurer = pageableConfigurerObjectProvider.getIfAvailable();
7166
}
@@ -77,7 +72,8 @@ public ApiBootMybatisPageableAutoConfiguration(ApiBootMyBatisPageableProperties
7772
void addInterceptors() {
7873
Interceptor interceptor = new MyBatisExecutePageableInterceptor();
7974
// set properties to interceptor
80-
interceptor.setProperties(myBatisPageableProperties.getProperties());
75+
Properties properties = pageableProperties.convertProperties();
76+
interceptor.setProperties(properties);
8177

8278
for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
8379
// pre
@@ -90,9 +86,9 @@ void addInterceptors() {
9086
}
9187

9288
/**
93-
* pre interceptors
89+
* add pre interceptors
9490
*
95-
* @param sqlSessionFactory sqlSessionFactory对象实例
91+
* @param sqlSessionFactory The {@link SqlSessionFactory} instance
9692
*/
9793
void addPreInterceptors(SqlSessionFactory sqlSessionFactory) {
9894
if (allowPageableConfigurer() && pageableConfigurer.prePlugins() != null) {
@@ -101,9 +97,9 @@ void addPreInterceptors(SqlSessionFactory sqlSessionFactory) {
10197
}
10298

10399
/**
104-
* after interceptors
100+
* add after interceptors
105101
*
106-
* @param sqlSessionFactory sqlSessionFactory对象实例
102+
* @param sqlSessionFactory The {@link SqlSessionFactory} instance
107103
*/
108104
void addPostInterceptors(SqlSessionFactory sqlSessionFactory) {
109105
if (allowPageableConfigurer() && pageableConfigurer.postPlugins() != null) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.minbox.framework.api.boot.autoconfigure.pageable;
2+
3+
/**
4+
* The MyBatis pageable config properties names
5+
*
6+
* @author 恒宇少年
7+
*/
8+
public interface PropertiesNames {
9+
/**
10+
* The name of database dialect properties
11+
*/
12+
String DATABASE_DIALECT = "dialect";
13+
}

0 commit comments

Comments
 (0)