Ok...thanks Scott and Simon....I have found another "trigger"... 

-----Ursprüngliche Nachricht-----
Von: Scott O'Bryan [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 20. November 2006 07:23
An: MyFaces Discussion
Betreff: Re: AW: PhaseListener behaviour

Simon,

Actually, while somewhat true, it really depends on the App server and 
the way that the app is deployed.  In general, if you deploy an 
application in it's own webapp, it's going to have it's own classloader 
and this will not be an issue.  It's generally only a problem if you 
deploy the config file and the phase listeners inside the App Server's 
classpath.

As for where this should be located, I would put it in the 
faces-config.xml.  The whole purpose of the meta-data layer is to allow 
you to change configuration easily.  Putting it in the Faces Config will 
allow you to add/remove it as necessary without mucking with your code.

Scott

Simon Kitching wrote:
> Pfau, Oliver wrote:
>> Another question...is there a difference is I register a phase 
>> listener in my backing bean constructor or in the faces-config.xml 
>
> Phase listeners are global for the webapp. When one is registered, it 
> goes into a global list of phase listeners. Every time ANY request is 
> processed by the JSF FacesServlet (that's *every* jsf request), all 
> the registered phase listeners are run. It doesn't matter how they are 
> registered, they still go into the global list. And they stay in that 
> list until explicitly removed. Because of this, it really doesn't make 
> sense to register Phase Listener objects dynamically; they should be 
> set up when the webapp starts. Registering one from a backing bean 
> constructor doesn't seem a good idea at all.
>
> And because a phase listener is global, if it has a hard reference to 
> a particular managed bean, then that bean will of course not be 
> garbage-collected. It really doesn't make much sense for a phase 
> listener to directly keep a reference to a managed bean instance 
> (well, maybe an application-scope one would be ok).
>
> A PhaseListener can obtain the current faces context (which will be 
> specific to the current request) then look up managed beans by name 
> (see the wiki), which does allow you to call a managed bean if you 
> know its name.
>
> I suggest you take a step back, and consider alternatives to a 
> PhaseListener for whatever it is you are trying to achieve; it may not 
> be the right tool.
>
> Regards,
>
> Simon
>

Reply via email to