Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add com.sun.faces.numberOfActiveViewMaps #5039

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@

package com.sun.faces.application.view;

import com.sun.faces.application.ApplicationAssociate;
import com.sun.faces.config.WebConfiguration;
import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableDistributable;
import com.sun.faces.mgbean.BeanManager;
import com.sun.faces.util.LRUMap;
import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.NumberOfActiveViewMaps;

import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.faces.application.FacesMessage;
import javax.faces.application.ProjectStage;
import javax.faces.component.UIViewRoot;
Expand All @@ -40,6 +39,11 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import com.sun.faces.application.ApplicationAssociate;
import com.sun.faces.config.WebConfiguration;
import com.sun.faces.mgbean.BeanManager;
import com.sun.faces.util.LRUMap;

/**
* The manager that deals with non-CDI and CDI ViewScoped beans.
*/
Expand Down Expand Up @@ -75,6 +79,8 @@ public class ViewScopeManager implements HttpSessionListener, ViewMapListener {
private ViewScopeContextManager contextManager;

private boolean distributable;

private Integer numberOfActiveViewMapsInWebXml;

/**
* Constructor.
Expand All @@ -94,6 +100,17 @@ public ViewScopeManager() {
WebConfiguration config = WebConfiguration.getInstance(context.getExternalContext());
distributable = config.isOptionEnabled(EnableDistributable);

String numberOfActiveViewMapsAsString = config.getOptionValue(NumberOfActiveViewMaps);
if (numberOfActiveViewMapsAsString != null) {
try {
numberOfActiveViewMapsInWebXml = Integer.parseInt(numberOfActiveViewMapsAsString);
}
catch (NumberFormatException e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "Cannot parse " + NumberOfActiveViewMaps.getQualifiedName(), e);
}
}
}
}

/**
Expand Down Expand Up @@ -297,7 +314,11 @@ private void processPostConstructViewMap(SystemEvent se) {
Map<String, Object> sessionMap = facesContext.getExternalContext().getSessionMap();
Integer size = (Integer) sessionMap.get(ACTIVE_VIEW_MAPS_SIZE);
if (size == null) {
size = 25;
size = numberOfActiveViewMapsInWebXml;

if (size == null) {
size = Integer.parseInt(NumberOfActiveViewMaps.getDefaultValue());
}
}

if (sessionMap.get(ACTIVE_VIEW_MAPS) == null) {
Expand Down
4 changes: 4 additions & 0 deletions impl/src/main/java/com/sun/faces/config/WebConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,10 @@ public enum WebContextInitParameter {
true,
NumberOfLogicalViews
),
NumberOfActiveViewMaps(
"com.sun.faces.numberOfActiveViewMaps",
"25"
),
NumberOfConcurrentFlashUsers(
"com.sun.faces.numberOfConcerrentFlashUsers",
"5000"
Expand Down