[
https://issues.apache.org/jira/browse/MYFACES-1761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541122
]
Bernhard Huemer commented on MYFACES-1761:
------------------------------------------
In fact, I've even quoted the specification - Page 11, Spec Issue 119:
"Specified that implementations running in a JSR-250 compliant container have
their managed bean methods annotated with @PostConstruct be called after the
object is instantiated, and after injection is performed, but before the bean
is placed into scope. Specified that methods annotated with @PreDestroy be
called when the scope for the bean is ending."
Additionally, the InjectionProvider interface, the RI's counterpart to our
LifecycleProvider, has always seperated injection and "postconstruction". There
is only one difference between those interfaces (of course, I'm referring to
the "patched" version of the LifecycleProvider interface), the
LifecycleProvider interface does support constructor injection whereas the
InjectionProvider interface doesn't. I've also tested the postconstruct-demo
using the RI and it behaves as I'd expect it - the method annotated with
@PostConstruct is called after all properties (including JSF managed ones) have
been injected.
However, I don't think that it's possible to fix this "bug" without changing
the LifecycleProvider interface. Of course, you could refactor some internal
classes in order to involve the ManagedBeanBuilder in initializing the bean,
but I wouldn't recommend it. The problem with this "fix" is that it wouldn't
work with 3rd party implementations as you're required to refactor all
implementations (i.e. you're introducing a breaking change even without
changing the interface itself).
> 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.