The Spring Framework

## org.springframework.web.jsf
Class DelegatingPhaseListenerMulticaster

    java.lang.Object
      org.springframework.web.jsf.DelegatingPhaseListenerMulticaster

All Implemented Interfaces:
  Serializable, EventListener, javax.faces.event.PhaseListener

    public class DelegatingPhaseListenerMulticaster

extends Object
implements javax.faces.event.PhaseListener

JSF PhaseListener implementation that delegates to one or more Spring-managed PhaseListener beans coming from the Spring root WebApplicationContext.

Configure this listener multicaster in your `faces-config.xml` file as follows:

     <application>
       ...
       <phase-listener>
         org.springframework.web.jsf.DelegatingPhaseListenerMulticaster
       </phase-listener>
       ...
     </application>

The multicaster will delegate all `beforePhase` and `afterPhase` events to all target PhaseListener beans. By default, those will simply be obtained by type: All beans in the Spring root WebApplicationContext that implement the PhaseListener interface will be fetched and invoked.

Note this multicaster's `getPhaseId()` method will always return `ANY_PHASE`. The phase id exposed by the target listener beans will be ignored; all events will be propagated to all listeners.

This multicaster may be subclassed to change the strategy used to obtain the listener beans, or to change the strategy used to access the ApplicationContext (normally obtained via `FacesContextUtils.getWebApplicationContext(FacesContext)`).

Since:
  1.2.7
Author:
  Juergen Hoeller, Colin Sampaleanu
See Also:
  Serialized Form

Constructor Summary
`DelegatingPhaseListenerMulticaster()`

Method Summary
`void` `afterPhase(javax.faces.event.PhaseEvent event)`
`void` `beforePhase(javax.faces.event.PhaseEvent event)`
`protected ListableBeanFactory` `getBeanFactory(javax.faces.context.FacesContext facesContext)` Retrieve the Spring BeanFactory to delegate bean name resolution to.
`protected Collection` `getDelegates(javax.faces.context.FacesContext facesContext)` Obtain the delegate PhaseListener beans from the Spring root WebApplicationContext.
`javax.faces.event.PhaseId` `getPhaseId()`
`protected WebApplicationContext` `getWebApplicationContext(javax.faces.context.FacesContext facesContext)` Retrieve the web application context to delegate bean name resolution to.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DelegatingPhaseListenerMulticaster

    public DelegatingPhaseListenerMulticaster()

Method Detail

### getPhaseId

    public javax.faces.event.PhaseId getPhaseId()

  Specified by:
    `getPhaseId` in interface `javax.faces.event.PhaseListener`

### beforePhase

    public void beforePhase(javax.faces.event.PhaseEvent event)

  Specified by:
    `beforePhase` in interface `javax.faces.event.PhaseListener`

### afterPhase

    public void afterPhase(javax.faces.event.PhaseEvent event)

  Specified by:
    `afterPhase` in interface `javax.faces.event.PhaseListener`

### getDelegates

    protected Collection getDelegates(javax.faces.context.FacesContext facesContext)

  Obtain the delegate PhaseListener beans from the Spring root WebApplicationContext.

  Parameters:
    `facesContext` - the current JSF context
  Returns:
    a Collection of PhaseListener objects
  See Also:
    `getBeanFactory(javax.faces.context.FacesContext)`, `ListableBeanFactory.getBeansOfType(Class)`

### getBeanFactory

    protected ListableBeanFactory getBeanFactory(javax.faces.context.FacesContext facesContext)

  Retrieve the Spring BeanFactory to delegate bean name resolution to.

  Default implementation delegates to `getWebApplicationContext`. Can be overridden to provide an arbitrary ListableBeanFactory reference to resolve against; usually, this will be a full Spring ApplicationContext.

  Parameters:
    `facesContext` - the current JSF context
  Returns:
    the Spring ListableBeanFactory (never `null`)
  See Also:
    `getWebApplicationContext(javax.faces.context.FacesContext)`

### getWebApplicationContext

    protected WebApplicationContext getWebApplicationContext(javax.faces.context.FacesContext facesContext)

  Retrieve the web application context to delegate bean name resolution to.

  Default implementation delegates to FacesContextUtils.

  Parameters:
    `facesContext` - the current JSF context
  Returns:
    the Spring web application context (never `null`)
  See Also:
    `FacesContextUtils.getRequiredWebApplicationContext(javax.faces.context.FacesContext)`

The Spring Framework

Copyright © 2002-2008 The Spring Framework.