Most of the JSF listener tags supports 'bind' attribute that allows to use any JSF beans as  listeners, that could have any scope and where injection library could make any necessary work.
Because narrow listener objects are saved in the components tree, in addition to the injection we should also define some addition lifecycle methods ( e.g. activate/passivate ), otherwise status of injected objects will be unpredictable. I suggest to check only is all listener could be defined as binding to the JSF beans. 

On 07/22/2009 06:54 AM, Dan Allen wrote:
On Wed, Jul 22, 2009 at 9:11 AM, Steve Roy <> wrote:

It would be nice if the design made it easy for resources to be released when the beforePhase/afterPhase processing completes so developers don't inadvertently forget to release expensive resources.

I can see the need for the feature. There is a danger though, that it makes it too easy for developers to implement time & resource expensive operations for invocations of the JSF lifecycle, which should be considered time sensitive.

My focus was not necessarily on hooks to cleanup expensive resources. To clarify, my focus is to get listeners to tie in better with the EE platform. For instance, if I am developing an extension to JSF, and I want to manipulate the JSR-299 conversation or perhaps wrap one or more phases in a UserTransaction, there is no portable way to inject the necessary components. Another use case is that I want to store state in a JSR-299 contextual object or a stateful EJB session bean (or a hybrid of the two). Again, no portable way to access this bean. What I am looking for are injections like the following:

@Resource UserTransaction transaction;
@Current Conversation conversation;
@EJB Cart cart;
@Current StatusMessages statusMessages;

Right now phase and system event listeners have to use JNDI to get at any of those resources, with subsequent calls necessary in some cases (such as to get a contextual instance from the BeanManager).

My point is that managed objects in the Java EE platform should be able to receive injections. I see phase listeners and system event listeners as managed objects.


Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597