74
74
* <li>{@link RedisClusterConfiguration}</li>
75
75
* </ul>
76
76
* <p>
77
- * This connection factory must be {@link #afterPropertiesSet() initialized} and {@link SmartLifecycle#start() started}
78
- * prior to {@link #getConnection obtaining connections}. You can {@link SmartLifecycle#stop()} and
79
- * {@link SmartLifecycle#start() restart} this connection factory if needed.
77
+ * This connection factory implements {@link InitializingBean} and {@link SmartLifecycle} for flexible lifecycle
78
+ * control. It must be {@link #afterPropertiesSet() initialized} and {@link #start() started} before you can obtain a
79
+ * connection. {@link #afterPropertiesSet() Initialization} {@link SmartLifecycle#start() starts} this bean
80
+ * {@link #isAutoStartup() by default}. You can {@link SmartLifecycle#stop()} and {@link SmartLifecycle#start() restart}
81
+ * this connection factory if needed.
80
82
*
81
83
* @author Costin Leau
82
84
* @author Thomas Darimont
@@ -96,12 +98,15 @@ public class JedisConnectionFactory
96
98
97
99
private final JedisClientConfiguration clientConfiguration ;
98
100
99
- private boolean convertPipelineAndTxResults = true ;
100
101
private RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration ("localhost" ,
101
102
Protocol .DEFAULT_PORT );
102
103
103
104
private @ Nullable RedisConfiguration configuration ;
104
105
106
+ private int phase = 0 ; // in between min and max values
107
+
108
+ private boolean convertPipelineAndTxResults = true ;
109
+
105
110
/**
106
111
* Lifecycle state of this factory.
107
112
*/
@@ -118,8 +123,6 @@ enum State {
118
123
private @ Nullable ClusterTopologyProvider topologyProvider ;
119
124
private @ Nullable ClusterCommandExecutor clusterCommandExecutor ;
120
125
121
- private int phase = DEFAULT_PHASE - 10 ;
122
-
123
126
/**
124
127
* Constructs a new {@link JedisConnectionFactory} instance with default settings (default connection pooling).
125
128
*/
@@ -266,7 +269,8 @@ public JedisConnectionFactory(RedisClusterConfiguration clusterConfig, JedisClie
266
269
public void afterPropertiesSet () {
267
270
268
271
clientConfig = createClientConfig (getDatabase (), getRedisUsername (), getRedisPassword ());
269
- if (isAutoStartup ()) {
272
+
273
+ if (isAutoStartup ()) {
270
274
start ();
271
275
}
272
276
}
@@ -368,6 +372,21 @@ public void stop() {
368
372
}
369
373
}
370
374
375
+ @ Override
376
+ public int getPhase () {
377
+ return phase ;
378
+ }
379
+
380
+ /**
381
+ * Specify the lifecycle phase for pausing and resuming this executor. The default is {@code 0}.
382
+ *
383
+ * @since 3.2
384
+ * @see SmartLifecycle#getPhase()
385
+ */
386
+ public void setPhase (int phase ) {
387
+ this .phase = phase ;
388
+ }
389
+
371
390
@ Override
372
391
public boolean isRunning () {
373
392
return State .STARTED .equals (state .get ());
@@ -859,21 +878,6 @@ public boolean isRedisClusterAware() {
859
878
return RedisConfiguration .isClusterConfiguration (configuration );
860
879
}
861
880
862
- @ Override
863
- public int getPhase () {
864
- return phase ;
865
- }
866
-
867
- /**
868
- * Specify the lifecycle phase for pausing and resuming this executor.
869
- * The default is {@link #DEFAULT_PHASE} - 10.
870
- * @since 3.2
871
- * @see SmartLifecycle#getPhase()
872
- */
873
- public void setPhase (int phase ) {
874
- this .phase = phase ;
875
- }
876
-
877
881
@ Override
878
882
public RedisSentinelConnection getSentinelConnection () {
879
883
0 commit comments