Skip to content

Commit

Permalink
Merge pull request #5039 from eclipse-ee4j/mojarra-issue-5038_add-mis…
Browse files Browse the repository at this point in the history
…sing-context-param-for-active-view-maps-size

Add com.sun.faces.numberOfActiveViewMaps
  • Loading branch information
BalusC authored Feb 19, 2022
2 parents a6c54e8 + 224bc6c commit f786e62
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
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

0 comments on commit f786e62

Please sign in to comment.