@@ -149,6 +149,30 @@ public void testJsr250AnnotationsWithShadowedMethods() {
149
149
bean .destroyMethods );
150
150
}
151
151
152
+ @ Test
153
+ public void testJsr250AnnotationsWithCustomPrivateInitDestroyMethods () {
154
+ Class <?> beanClass = CustomAnnotatedPrivateInitDestroyBean .class ;
155
+ DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean (beanClass , "customInit1" , "customDestroy1" );
156
+ CustomAnnotatedPrivateInitDestroyBean bean =
157
+ (CustomAnnotatedPrivateInitDestroyBean ) beanFactory .getBean (LIFECYCLE_TEST_BEAN );
158
+ assertMethodOrdering ("init-methods" , Arrays .asList ("privateCustomInit1" ,"afterPropertiesSet" ), bean .initMethods );
159
+ beanFactory .destroySingletons ();
160
+ assertMethodOrdering ("destroy-methods" , Arrays .asList ("privateCustomDestroy1" ,"destroy" ), bean .destroyMethods );
161
+ }
162
+
163
+ @ Test
164
+ public void testJsr250AnnotationsWithCustomSameMethodNames () {
165
+ Class <?> beanClass = CustomAnnotatedPrivateSameNameInitDestroyBean .class ;
166
+ DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean (beanClass , "customInit1" , "customDestroy1" );
167
+ CustomAnnotatedPrivateSameNameInitDestroyBean bean =
168
+ (CustomAnnotatedPrivateSameNameInitDestroyBean ) beanFactory .getBean (LIFECYCLE_TEST_BEAN );
169
+ assertMethodOrdering ("init-methods" ,
170
+ Arrays .asList ("privateCustomInit1" ,"afterPropertiesSet" ,"sameNameCustomInit1" ), bean .initMethods );
171
+ beanFactory .destroySingletons ();
172
+ assertMethodOrdering ("destroy-methods" ,
173
+ Arrays .asList ("privateCustomDestroy1" ,"destroy" ,"sameNameCustomDestroy1" ), bean .destroyMethods );
174
+ }
175
+
152
176
@ Test
153
177
public void testAllLifecycleMechanismsAtOnce () {
154
178
final Class <?> beanClass = AllInOneBean .class ;
@@ -205,6 +229,31 @@ public void customDestroy() throws Exception {
205
229
}
206
230
}
207
231
232
+ public static class CustomAnnotatedPrivateInitDestroyBean extends CustomInitializingDisposableBean {
233
+
234
+ @ PostConstruct
235
+ private void customInit1 () throws Exception {
236
+ this .initMethods .add ("privateCustomInit1" );
237
+ }
238
+
239
+ @ PreDestroy
240
+ private void customDestroy1 () throws Exception {
241
+ this .destroyMethods .add ("privateCustomDestroy1" );
242
+ }
243
+
244
+ }
245
+
246
+ public static class CustomAnnotatedPrivateSameNameInitDestroyBean extends CustomAnnotatedPrivateInitDestroyBean {
247
+
248
+ private void customInit1 () throws Exception {
249
+ this .initMethods .add ("sameNameCustomInit1" );
250
+ }
251
+
252
+ private void customDestroy1 () throws Exception {
253
+ this .destroyMethods .add ("sameNameCustomDestroy1" );
254
+ }
255
+
256
+ }
208
257
209
258
public static class CustomInitializingDisposableBean extends CustomInitDestroyBean
210
259
implements InitializingBean , DisposableBean {
0 commit comments