@@ -79,6 +79,8 @@ public void vanilla() throws Exception {
79
79
assertThat (service .getCount ()).isEqualTo (3 );
80
80
service .expressionService ();
81
81
assertThat (service .getCount ()).isEqualTo (4 );
82
+ service .expressionService2 ();
83
+ assertThat (service .getCount ()).isEqualTo (5 );
82
84
Advised advised = (Advised ) service ;
83
85
Advisor advisor = advised .getAdvisors ()[0 ];
84
86
Map <?, ?> delegates = (Map <?, ?>) new DirectFieldAccessor (advisor ).getPropertyValue ("advice.delegates" );
@@ -92,6 +94,12 @@ public void vanilla() throws Exception {
92
94
assertThat (accessor .getPropertyValue ("retryOperations.retryPolicy.resetTimeout" )).isEqualTo (20000L );
93
95
assertThat (accessor .getPropertyValue ("retryOperations.retryPolicy.delegate.expression.expression" ))
94
96
.isEqualTo ("#root instanceof RuntimeExpression" );
97
+
98
+ interceptor = (MethodInterceptor ) methodMap .get (Service .class .getDeclaredMethod ("expressionService2" ));
99
+ accessor = new DirectFieldAccessor (interceptor );
100
+ assertThat (accessor .getPropertyValue ("retryOperations.retryPolicy.delegate.maxAttempts" )).isEqualTo (10 );
101
+ assertThat (accessor .getPropertyValue ("retryOperations.retryPolicy.openTimeout" )).isEqualTo (10000L );
102
+ assertThat (accessor .getPropertyValue ("retryOperations.retryPolicy.resetTimeout" )).isEqualTo (20000L );
95
103
context .close ();
96
104
}
97
105
@@ -104,6 +112,21 @@ public Service service() {
104
112
return new ServiceImpl ();
105
113
}
106
114
115
+ @ Bean
116
+ Configs configs () {
117
+ return new Configs ();
118
+ }
119
+
120
+ }
121
+
122
+ public static class Configs {
123
+
124
+ public int maxAttempts = 10 ;
125
+
126
+ public long openTimeout = 10000 ;
127
+
128
+ public long resetTimeout = 20000 ;
129
+
107
130
}
108
131
109
132
interface Service {
@@ -112,6 +135,8 @@ interface Service {
112
135
113
136
void expressionService ();
114
137
138
+ void expressionService2 ();
139
+
115
140
int getCount ();
116
141
117
142
RetryContext getContext ();
@@ -141,6 +166,13 @@ public void expressionService() {
141
166
this .count ++;
142
167
}
143
168
169
+ @ Override
170
+ @ CircuitBreaker (maxAttemptsExpression = "@configs.maxAttempts" , openTimeoutExpression = "@configs.openTimeout" ,
171
+ resetTimeoutExpression = "@configs.resetTimeout" )
172
+ public void expressionService2 () {
173
+ this .count ++;
174
+ }
175
+
144
176
@ Override
145
177
public RetryContext getContext () {
146
178
return this .context ;
0 commit comments