org.apache.myfaces.extensions.cdi.jsf2.impl.scope.view
Class ViewScopedExtension

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.jsf2.impl.scope.view.ViewScopedExtension
All Implemented Interfaces:
javax.enterprise.inject.spi.Extension, Deactivatable

public class ViewScopedExtension
extends Object
implements javax.enterprise.inject.spi.Extension, Deactivatable

This CDI extension enables support for the new JSF-2 @ViewScoped annotation.

2 steps are necessary:

  1. We have to manually add the @ViewScoped annotation as a passivating NormalScope, since this annotation is neither a JSR-330 annotation nor a JSR-299 annotation and therefor doesn't get picked up automatically. This has to be before the bean scanning starts.
  2. After the bean scanning succeeded, we register the Context for the ViewScoped. The ViewScopedContext is responsible for actually storing all our @ViewScoped contextual instances in the JSF ViewMap.

The extension automatically detects if we are in the ProjectStage.UnitTest and uses


Constructor Summary
ViewScopedExtension()
           
 
Method Summary
 void addViewScoped(javax.enterprise.inject.spi.BeforeBeanDiscovery beforeBeanDiscovery)
           
 boolean isActivated()
           
 void registerViewContext(javax.enterprise.inject.spi.AfterBeanDiscovery afterBeanDiscovery)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewScopedExtension

public ViewScopedExtension()
Method Detail

addViewScoped

public void addViewScoped(@Observes
                          javax.enterprise.inject.spi.BeforeBeanDiscovery beforeBeanDiscovery)

registerViewContext

public void registerViewContext(@Observes
                                javax.enterprise.inject.spi.AfterBeanDiscovery afterBeanDiscovery)

isActivated

public boolean isActivated()
Specified by:
isActivated in interface Deactivatable


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.