Skip to content

Commit

Permalink
Merge pull request #5293 from eclipse-ee4j/mojarra_issue_5291
Browse files Browse the repository at this point in the history
jakarta.faces.NUMBER_OF_CLIENT_WINDOWS was not considered as context param
  • Loading branch information
arjantijms authored Sep 7, 2023
2 parents 479c9cc + e0cd6ec commit d216c10
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@

package com.sun.faces.cdi.clientwindow;

import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableDistributable;
import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.NumberOfClientWindows;
import static java.util.logging.Level.FINEST;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.sun.faces.config.WebConfiguration;
import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.LRUMap;

import jakarta.enterprise.context.spi.Contextual;
import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.PassivationCapable;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.faces.lifecycle.ClientWindow;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionEvent;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableDistributable;
import static java.util.logging.Level.FINEST;

/**
* The manager that deals with CDI ClientWindowScoped beans.
*/
Expand Down Expand Up @@ -141,12 +143,22 @@ private Map<String, ClientWindowScopeContextObject> getContextMap(FacesContext f
String clientWindowId = getCurrentClientWindowId(facesContext);

if (clientWindowScopeContexts == null && create) {
synchronized (session) {
Integer size = (Integer) sessionMap.get(ClientWindow.NUMBER_OF_CLIENT_WINDOWS_PARAM_NAME);
if (size == null) {
size = 10;
Integer numberOfClientWindows = null;

try {
numberOfClientWindows = Integer.parseInt(WebConfiguration.getInstance(externalContext).getOptionValue(NumberOfClientWindows));
} catch (NumberFormatException nfe) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "Unable to set number of client windows. Defaulting to {0}", NumberOfClientWindows.getDefaultValue());
}
sessionMap.put(CLIENT_WINDOW_CONTEXTS, Collections.synchronizedMap(new LRUMap<String, Object>(size)));
}

if (numberOfClientWindows == null) {
numberOfClientWindows = Integer.valueOf(NumberOfClientWindows.getDefaultValue());
}

synchronized (session) {
sessionMap.put(CLIENT_WINDOW_CONTEXTS, Collections.synchronizedMap(new LRUMap<String, Object>(numberOfClientWindows)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ public enum WebContextInitParameter {
JakartaFacesProjectStage(ProjectStage.PROJECT_STAGE_PARAM_NAME, "Production"),
AlternateLifecycleId(FacesServlet.LIFECYCLE_ID_ATTR, ""),
ResourceExcludes(ResourceHandler.RESOURCE_EXCLUDES_PARAM_NAME, ResourceHandler.RESOURCE_EXCLUDES_DEFAULT_VALUE),
NumberOfClientWindows(ClientWindow.NUMBER_OF_CLIENT_WINDOWS_PARAM_NAME, "10"),
NumberOfViews("com.sun.faces.numberOfViewsInSession", "15"),
NumberOfLogicalViews("com.sun.faces.numberOfLogicalViews", "15"),
NumberOfActiveViewMaps("com.sun.faces.numberOfActiveViewMaps", "25"),
Expand Down

0 comments on commit d216c10

Please sign in to comment.