-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17362 from pferraro/WFLY-18708
WFLY-18708 Disable counter-productive "distributable" behavior in Mojarra
- Loading branch information
Showing
3 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...tem/src/main/java/org/jboss/as/jsf/deployment/NonDistributableServletContextListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.jboss.as.jsf.deployment; | ||
|
||
import jakarta.faces.context.FacesContext; | ||
import jakarta.servlet.ServletContext; | ||
import jakarta.servlet.ServletContextEvent; | ||
import jakarta.servlet.ServletContextListener; | ||
|
||
import com.sun.faces.config.InitFacesContext; | ||
import com.sun.faces.config.WebConfiguration; | ||
|
||
/** | ||
* Workaround for counter-productive "distributable" logic in Mojarra. | ||
* This setting is used to trigger redundant calls to HttpSession.setAttribute(...) for mutated attributes. | ||
*/ | ||
public class NonDistributableServletContextListener implements ServletContextListener { | ||
|
||
@Override | ||
public void contextInitialized(ServletContextEvent event) { | ||
ServletContext context = event.getServletContext(); | ||
FacesContext facesContext = new InitFacesContext(context); | ||
try { | ||
WebConfiguration.getInstance(context).setOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.EnableDistributable, false); | ||
context.setAttribute(WebConfiguration.BooleanWebContextInitParameter.EnableDistributable.getQualifiedName(), Boolean.FALSE); | ||
} finally { | ||
facesContext.release(); | ||
} | ||
} | ||
} |