[ https://issues.apache.org/jira/browse/MYFACES-1761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541068 ]
Paul McMahan commented on MYFACES-1761: --------------------------------------- Bernhard, thanks for bringing this up and for the helpful sample which clearly demonstrates the issue. Can you please point me to the language in the spec that you are referring to? Specifically you said: "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." But the language I found in the spec says: "JSF implementations running in a Java EE 5 compliant container must support attaching the @PostConstruct and @PreDestroy annotations to aid in awareness of the managed-bean lifecycle." and "Methods on managed beans declared to be in request, session, or application scope, annotated with @PostConstruct, must be called by the JSF implementation after resource injection is performed (if any) but before the bean is placed into scope." Reading the spec literally, the @PostConstruct annotation is exclusively provided for the benefit of resource injection in a Java EE 5 container, which as you have pointed out doesn't necessarily know about managed bean properties. I don't see any discussion about the @PostConstuct annotation being related to managed bean properties, so initializing them before calling @PostConstrcut could arguably be non-compliant with the spec. (I'm not taking that position, just considering both sides) I agree that initializing managed properties before calling PostConstruct methods might be a useful feature worth further consideration. But I want to determine first whether we think it is actually required by the spec or its up to us to determine if/how this feature should be implemented. If it's not required by the spec then let's consider how the RI behaves. Something I read in a blog suggests that the RI does in fact provide this feature, which would make me lean towards also providing it in MyFaces. However, the LifeCycleProvider interface you modified is an existing integration point for servlet and Java EE containers, and there are very similar LifeCycleProvider interfaces for several other Java EE components. So let's investigate whether it's possible to provide this feature without changing the interface, perhaps by refactoring the ManagedBeanBuilder so that initialization can occur as an additional step within the LifeCycleProvider.newInstance(). Looking forward to your thoughts on all this! > 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.