@@ -77,7 +77,7 @@ public WxMaConfig wxMaConfig() {
77
77
WxMaDefaultConfigImpl config ;
78
78
switch (wxMaProperties .getConfigStorage ().getType ()) {
79
79
case Jedis :
80
- config = wxMaJedisConfigStorage ( );
80
+ config = WxMaRedisBetterConfig . config ( wxMaProperties , applicationContext );
81
81
break ;
82
82
case RedisTemplate :
83
83
config = wxMaRedisTemplateConfigStorage ();
@@ -107,35 +107,39 @@ private WxMaDefaultConfigImpl wxMaDefaultConfigStorage() {
107
107
return new WxMaDefaultConfigImpl ();
108
108
}
109
109
110
- private WxMaDefaultConfigImpl wxMaJedisConfigStorage () {
111
- RedisProperties redisProperties = wxMaProperties .getConfigStorage ().getRedis ();
112
- JedisPool jedisPool ;
113
- if (StringUtils .isNotEmpty (redisProperties .getHost ())) {
114
- JedisPoolConfig config = new JedisPoolConfig ();
115
- if (redisProperties .getMaxActive () != null ) {
116
- config .setMaxTotal (redisProperties .getMaxActive ());
117
- }
118
- if (redisProperties .getMaxIdle () != null ) {
119
- config .setMaxIdle (redisProperties .getMaxIdle ());
120
- }
121
- if (redisProperties .getMaxWaitMillis () != null ) {
122
- config .setMaxWaitMillis (redisProperties .getMaxWaitMillis ());
123
- }
124
- if (redisProperties .getMinIdle () != null ) {
125
- config .setMinIdle (redisProperties .getMinIdle ());
126
- }
127
- config .setTestOnBorrow (true );
128
- config .setTestWhileIdle (true );
110
+ private static class WxMaRedisBetterConfig {
129
111
130
- jedisPool = new JedisPool (config , redisProperties .getHost (), redisProperties .getPort (),
131
- redisProperties .getTimeout (), redisProperties .getPassword (), redisProperties .getDatabase ());
132
- } else {
133
- jedisPool = applicationContext .getBean (JedisPool .class );
112
+ private static WxMaDefaultConfigImpl config (WxMaProperties wxMaProperties , ApplicationContext context ) {
113
+ RedisProperties redisProperties = wxMaProperties .getConfigStorage ().getRedis ();
114
+ JedisPool jedisPool ;
115
+ if (StringUtils .isNotEmpty (redisProperties .getHost ())) {
116
+ JedisPoolConfig config = new JedisPoolConfig ();
117
+ if (redisProperties .getMaxActive () != null ) {
118
+ config .setMaxTotal (redisProperties .getMaxActive ());
119
+ }
120
+ if (redisProperties .getMaxIdle () != null ) {
121
+ config .setMaxIdle (redisProperties .getMaxIdle ());
122
+ }
123
+ if (redisProperties .getMaxWaitMillis () != null ) {
124
+ config .setMaxWaitMillis (redisProperties .getMaxWaitMillis ());
125
+ }
126
+ if (redisProperties .getMinIdle () != null ) {
127
+ config .setMinIdle (redisProperties .getMinIdle ());
128
+ }
129
+ config .setTestOnBorrow (true );
130
+ config .setTestWhileIdle (true );
131
+
132
+ jedisPool = new JedisPool (config , redisProperties .getHost (), redisProperties .getPort (),
133
+ redisProperties .getTimeout (), redisProperties .getPassword (), redisProperties .getDatabase ());
134
+ } else {
135
+ jedisPool = context .getBean (JedisPool .class );
136
+ }
137
+ WxRedisOps redisOps = new JedisWxRedisOps (jedisPool );
138
+ return new WxMaRedisBetterConfigImpl (redisOps , wxMaProperties .getConfigStorage ().getKeyPrefix ());
134
139
}
135
- WxRedisOps redisOps = new JedisWxRedisOps (jedisPool );
136
- return new WxMaRedisBetterConfigImpl (redisOps , wxMaProperties .getConfigStorage ().getKeyPrefix ());
137
140
}
138
141
142
+
139
143
private WxMaDefaultConfigImpl wxMaRedisTemplateConfigStorage () {
140
144
StringRedisTemplate redisTemplate = applicationContext .getBean (StringRedisTemplate .class );
141
145
WxRedisOps redisOps = new RedisTemplateWxRedisOps (redisTemplate );
0 commit comments