[picocontainer-scm] [jira] Commented: (PICO-383) Support @PostConstruct and @PreDestroy in base classes

"tobias mattsson (JIRA)" <jira-yCVjj/[email protected]> Wed, 15 Jun 2011 09:42:42 -0500 (CDT)
Newsgroups gmane.comp.java.picocontainer.cvs
Message-ID <9963134.1873.1308148962629.JavaMail.haus-jira@codehaus01.managed.contegix.com>
    [ http://jira.codehaus.org/browse/PICO-383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=270470#comment-270470 ] 

tobias mattsson commented on PICO-383:
--------------------------------------

The destruction sequence should be reverse compared to the construction sequence. The test case should test for "post()subPost()subPre()pre()".

It needs to handle overridden methods as well, sadly there's no good support for this in the reflection api, it has to be done manually by comparing methods. Consider this class:

{code}
    public static class ProPostAnnotationJava5Startable3 extends ProPostAnnotationJava5Startable {

        public ProPostAnnotationJava5Startable3(StringBuilder sb) {
            super(sb);
        }

        @PostConstruct
        @Override
        public void post() {
            sb.append("subPost3()");
        }

        @PreDestroy
        public void subPre() {
            sb.append("subPre3()");
        }
    }
{code}

With this test case:
{code}
    @Test public void testLifecycleOfSubclassWhichOverrides(){
        pico.removeComponent(ProPostAnnotationJava5Startable.class);
        pico.addComponent(ProPostAnnotationJava5Startable3.class);
        pico.start();
        pico.dispose();
        assertEquals("subPost3()subPre3()pre()", pico.getComponent(StringBuilder.class).toString());
    }
{code}

It fails since it returns: subPost3()subPost3()pre()subPre3()

Also, it should be able to invoke private methods. 

> Support @PostConstruct and @PreDestroy in base classes
> ------------------------------------------------------
>
>                 Key: PICO-383
>                 URL: http://jira.codehaus.org/browse/PICO-383
>             Project: PicoContainer
>          Issue Type: Improvement
>          Components: PicoContainer (Java)
>            Reporter: tobias mattsson
>
> The Java EE 5 lifecycle support should invoke methods annotated with @PostConstruct and @PreDestroy also in inherited classes.
> In the class JavaEE5LifecycleStrategy the methods hasLifeCycle() and doLifecycleMethod() should walk the type hierarchy and invoke methods in the proper order, taking into account if methods found has been overridden.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
    <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>