org.omnifaces.cdi.viewscope
Class ViewScopeManager

java.lang.Object
  extended by org.omnifaces.application.ViewScopeProvider
      extended by org.omnifaces.cdi.viewscope.ViewScopeManager
All Implemented Interfaces:
java.io.Serializable

@Named(value="omnifaces_ViewScopeProvider")
@SessionScoped
public class ViewScopeManager
extends ViewScopeProvider
implements java.io.Serializable

Manage the view scoped beans by listening on view scope and session scope creation and destroy. The view scope destroy is done externally with aid of ViewScopeEventListener which is registered in faces-config.xml.

Since:
1.6
Author:
Radu Creanga , Bauke Scholtz
See Also:
ViewScoped, ViewScopeContext, Serialized Form

Field Summary
static int DEFAULT_MAX_ACTIVE_VIEW_SCOPES
          Default value of maximum active view scopes in session.
static java.lang.String PARAM_NAME_MAX_ACTIVE_VIEW_SCOPES
          OmniFaces specific context parameter name of maximum active view scopes in session.
static java.lang.String PARAM_NAME_MOJARRA_NUMBER_OF_VIEWS
          Mojarra specific context parameter name of maximum number of logical views in session.
static java.lang.String PARAM_NAME_MYFACES_NUMBER_OF_VIEWS
          MyFaces specific context parameter name of maximum number of views in session.
 
Fields inherited from class org.omnifaces.application.ViewScopeProvider
NAME
 
Constructor Summary
ViewScopeManager()
           
 
Method Summary
<T> T
createBean(javax.enterprise.context.spi.Contextual<T> type, javax.enterprise.context.spi.CreationalContext<T> context)
          Create and returns the CDI view scoped managed bean from the current JSF view scope.
<T> T
getBean(javax.enterprise.context.spi.Contextual<T> type)
          Returns the CDI view scoped managed bean from the current JSF view scope.
 void postConstructSession()
          Create a new LRU map of active view scopes with maximum weighted capacity depending on several context params.
 void preDestroySession()
          This method is invoked during session destroy, in that case destroy all beans in all active view scopes.
 void preDestroyView()
          This method is invoked during view destroy by ViewScopeEventListener, in that case destroy all beans in current active view scope.
 
Methods inherited from class org.omnifaces.application.ViewScopeProvider
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_NAME_MAX_ACTIVE_VIEW_SCOPES

public static final java.lang.String PARAM_NAME_MAX_ACTIVE_VIEW_SCOPES
OmniFaces specific context parameter name of maximum active view scopes in session.

See Also:
Constant Field Values

PARAM_NAME_MOJARRA_NUMBER_OF_VIEWS

public static final java.lang.String PARAM_NAME_MOJARRA_NUMBER_OF_VIEWS
Mojarra specific context parameter name of maximum number of logical views in session.

See Also:
Constant Field Values

PARAM_NAME_MYFACES_NUMBER_OF_VIEWS

public static final java.lang.String PARAM_NAME_MYFACES_NUMBER_OF_VIEWS
MyFaces specific context parameter name of maximum number of views in session.

See Also:
Constant Field Values

DEFAULT_MAX_ACTIVE_VIEW_SCOPES

public static final int DEFAULT_MAX_ACTIVE_VIEW_SCOPES
Default value of maximum active view scopes in session.

See Also:
Constant Field Values
Constructor Detail

ViewScopeManager

public ViewScopeManager()
Method Detail

postConstructSession

@PostConstruct
public void postConstructSession()
Create a new LRU map of active view scopes with maximum weighted capacity depending on several context params. See javadoc of ViewScoped for details.


createBean

public <T> T createBean(javax.enterprise.context.spi.Contextual<T> type,
                        javax.enterprise.context.spi.CreationalContext<T> context)
Create and returns the CDI view scoped managed bean from the current JSF view scope.

Parameters:
type - The contextual type of the CDI managed bean.
context - The CDI context to create the CDI managed bean in.
Returns:
The created CDI view scoped managed bean from the current JSF view scope.

getBean

public <T> T getBean(javax.enterprise.context.spi.Contextual<T> type)
Returns the CDI view scoped managed bean from the current JSF view scope.

Parameters:
type - The contextual type of the CDI managed bean.
Returns:
The CDI view scoped managed bean from the current JSF view scope.

preDestroyView

public void preDestroyView()
This method is invoked during view destroy by ViewScopeEventListener, in that case destroy all beans in current active view scope.

Specified by:
preDestroyView in class ViewScopeProvider

preDestroySession

@PreDestroy
public void preDestroySession()
This method is invoked during session destroy, in that case destroy all beans in all active view scopes.