1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -155,9 +155,9 @@ public void testJsr250AnnotationsWithCustomPrivateInitDestroyMethods() {
155
155
DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean (beanClass , "customInit1" , "customDestroy1" );
156
156
CustomAnnotatedPrivateInitDestroyBean bean =
157
157
(CustomAnnotatedPrivateInitDestroyBean ) beanFactory .getBean (LIFECYCLE_TEST_BEAN );
158
- assertMethodOrdering ("init-methods" , Arrays .asList ("privateCustomInit1" ,"afterPropertiesSet" ), bean .initMethods );
158
+ assertMethodOrdering (beanClass , "init-methods" , Arrays .asList ("@PostConstruct. privateCustomInit1" , "afterPropertiesSet" ), bean .initMethods );
159
159
beanFactory .destroySingletons ();
160
- assertMethodOrdering ("destroy-methods" , Arrays .asList ("privateCustomDestroy1" ,"destroy" ), bean .destroyMethods );
160
+ assertMethodOrdering (beanClass , "destroy-methods" , Arrays .asList ("@PreDestroy. privateCustomDestroy1" , "destroy" ), bean .destroyMethods );
161
161
}
162
162
163
163
@ Test
@@ -166,11 +166,11 @@ public void testJsr250AnnotationsWithCustomSameMethodNames() {
166
166
DefaultListableBeanFactory beanFactory = createBeanFactoryAndRegisterBean (beanClass , "customInit1" , "customDestroy1" );
167
167
CustomAnnotatedPrivateSameNameInitDestroyBean bean =
168
168
(CustomAnnotatedPrivateSameNameInitDestroyBean ) beanFactory .getBean (LIFECYCLE_TEST_BEAN );
169
- assertMethodOrdering ("init-methods" ,
170
- Arrays .asList ("privateCustomInit1" ,"afterPropertiesSet" , "sameNameCustomInit1 " ), bean .initMethods );
169
+ assertMethodOrdering (beanClass , "init-methods" ,
170
+ Arrays .asList ("@PostConstruct. privateCustomInit1" , "@PostConstruct.sameNameCustomInit1" , "afterPropertiesSet " ), bean .initMethods );
171
171
beanFactory .destroySingletons ();
172
- assertMethodOrdering ("destroy-methods" ,
173
- Arrays .asList ("privateCustomDestroy1" , "destroy" , "sameNameCustomDestroy1 " ), bean .destroyMethods );
172
+ assertMethodOrdering (beanClass , "destroy-methods" ,
173
+ Arrays .asList ("@PreDestroy.sameNameCustomDestroy1" , "@PreDestroy.privateCustomDestroy1" , "destroy " ), bean .destroyMethods );
174
174
}
175
175
176
176
@ Test
@@ -229,28 +229,32 @@ public void customDestroy() throws Exception {
229
229
}
230
230
}
231
231
232
- public static class CustomAnnotatedPrivateInitDestroyBean extends CustomInitializingDisposableBean {
232
+ public static class CustomAnnotatedPrivateInitDestroyBean extends CustomInitializingDisposableBean {
233
233
234
234
@ PostConstruct
235
235
private void customInit1 () throws Exception {
236
- this .initMethods .add ("privateCustomInit1" );
236
+ this .initMethods .add ("@PostConstruct. privateCustomInit1" );
237
237
}
238
238
239
239
@ PreDestroy
240
240
private void customDestroy1 () throws Exception {
241
- this .destroyMethods .add ("privateCustomDestroy1" );
241
+ this .destroyMethods .add ("@PreDestroy. privateCustomDestroy1" );
242
242
}
243
243
244
244
}
245
245
246
246
public static class CustomAnnotatedPrivateSameNameInitDestroyBean extends CustomAnnotatedPrivateInitDestroyBean {
247
247
248
+ @ PostConstruct
249
+ @ SuppressWarnings ("unused" )
248
250
private void customInit1 () throws Exception {
249
- this .initMethods .add ("sameNameCustomInit1" );
251
+ this .initMethods .add ("@PostConstruct. sameNameCustomInit1" );
250
252
}
251
253
254
+ @ PreDestroy
255
+ @ SuppressWarnings ("unused" )
252
256
private void customDestroy1 () throws Exception {
253
- this .destroyMethods .add ("sameNameCustomDestroy1" );
257
+ this .destroyMethods .add ("@PreDestroy. sameNameCustomDestroy1" );
254
258
}
255
259
256
260
}
0 commit comments