myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Jencks (JIRA)" <...@myfaces.apache.org>
Subject [jira] Commented: (MYFACES-1761) Handling PostConstruct annotations - wrong order
Date Tue, 06 Nov 2007 22:54:50 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-1761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540615
] 

David Jencks commented on MYFACES-1761:
---------------------------------------

I'm not sure you have your environment configured correctly to handle dependency injection.
 If I've located the post correctly the last few lines indicate that you are using

org.apache.myfaces.config.annotation.NoInjectionAnnotationLifecycleProvider.newInstance

which by its name is unlikely to do any dependency injection.  Also the text indicates tomcat
5 whereas the stack trace appears to show jetty.  I'm not sure either tomcat or jetty <
6 support any dependency injection under any circumstances.  I'm not sure of the level of
support for jsf dependency injection in tomcat and jetty 6 standalone either.  It's possible
you may need to run in a javaee 5 app server such as geronimo to have the jndi setup to support
the dependency injection.

In any case the intent of the LifecycleProvider interface is that newInstance
1. creates the object
2. injects dependencies
3. calls the PostConstruct lifecycle methods.

thus handling all aspects of making the bean ready for use.  This allows you to easily plug
in all sorts of strategies without making assumptions about exactly what is going on.  For
instance in geronimo we are using a library that can potentially support constructor dependency
injection, but does steps 1 and 2 in one  method call.  For this reason I am strongly against
separating 1 and 2 into separate calls.

> Handling PostConstruct annotations - wrong order
> ------------------------------------------------
>
>                 Key: MYFACES-1761
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1761
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions:  1.2.0, 1.2.1-SNAPSHOT
>            Reporter: Bernhard Huemer
>             Fix For: 1.2.1-SNAPSHOT
>
>         Attachments: MyFaces-1761.patch, postconstruct-demo.zip
>
>
> The specification states that managed bean methods annotated with @PostConstruct have
to be called after the object is initialized and after dependency injection is performed.
However, MyFaces calls those methods after the bean instance is created but before dependency
injection is performed (for example, see http://www.nabble.com/myfaces-1.2.0-postConstruct-tf4760326.html
). In order to resolve this bug the LifecycleProvider interface has to be changed. Currently
there's only one method responsible for creating/initializing a new bean: newInstance(). This
design choice implicates that there's no possibility to seperate the steps "creating the bean"
and "postconstructing the bean".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message