@PostConstruct works for multiple private init methods of the same name in a hierarchy (SPR-5945)

This commit is contained in:
Juergen Hoeller
2009-07-22 12:52:47 +00:00
parent 9696c66517
commit 4deef3796e
2 changed files with 43 additions and 4 deletions

View File

@@ -113,11 +113,13 @@ public class CommonAnnotationBeanPostProcessorTests {
ResourceInjectionBean bean = (ResourceInjectionBean) bf.getBean("annotatedBean");
assertTrue(bean.initCalled);
assertTrue(bean.init2Called);
assertTrue(bean.init3Called);
assertSame(tb, bean.getTestBean());
assertSame(tb2, bean.getTestBean2());
bf.destroySingletons();
assertTrue(bean.destroyCalled);
assertTrue(bean.destroy2Called);
assertTrue(bean.destroy3Called);
}
@Test
@@ -338,8 +340,12 @@ public class CommonAnnotationBeanPostProcessorTests {
public boolean init2Called = false;
public boolean init3Called = false;
public boolean destroy2Called = false;
public boolean destroy3Called = false;
@Resource
private TestBean testBean;
@@ -356,6 +362,14 @@ public class CommonAnnotationBeanPostProcessorTests {
this.init2Called = true;
}
@PostConstruct
private void init() {
if (this.init3Called) {
throw new IllegalStateException("Already called");
}
this.init3Called = true;
}
@PreDestroy
protected void destroy2() {
if (this.destroy2Called) {
@@ -364,6 +378,14 @@ public class CommonAnnotationBeanPostProcessorTests {
this.destroy2Called = true;
}
@PreDestroy
private void destroy() {
if (this.destroy3Called) {
throw new IllegalStateException("Already called");
}
this.destroy3Called = true;
}
@Resource
public void setTestBean2(TestBean testBean2) {
if (this.testBean2 != null) {