use of com.sun.faces.config.WebConfiguration in project Payara by payara.
the class GlassFishInjectionProvider method enableHighAvailability.
/**
* Method to test with HA has been enabled. If so, then set the JSF context param
* com.sun.faces.enableAgressiveSessionDirtying to true
*
* @param ctx
*/
public void enableHighAvailability(ServletContext ctx) {
// look at the following values for the web app
// 1> has <distributable /> in the web.xml
// 2> Was deployed with --availabilityenabled --target <clustername>
WebConfiguration config = WebConfiguration.getInstance(ctx);
if (!config.isSet(EnableAgressiveSessionDirtying)) {
Object isDistributableObj = ctx.getAttribute(IS_DISTRIBUTABLE_ATTRIBUTE);
Object enableHAObj = ctx.getAttribute(ENABLE_HA_ATTRIBUTE);
if (isDistributableObj instanceof Boolean && enableHAObj instanceof Boolean) {
boolean isDistributable = (Boolean) isDistributableObj;
boolean enableHA = (Boolean) enableHAObj;
if (LOGGER.isLoggable(FINE)) {
LOGGER.log(FINE, "isDistributable = {0} enableHA = {1}", new Object[] { isDistributable, enableHA });
}
if (isDistributable && enableHA) {
LOGGER.fine("setting the EnableAgressiveSessionDirtying to true");
config.overrideContextInitParameter(EnableAgressiveSessionDirtying, TRUE);
}
}
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class JavaFlowLoaderHelper method enableClientWindowModeIfNecessary.
private void enableClientWindowModeIfNecessary(FacesContext context) {
WebConfiguration config = WebConfiguration.getInstance(context.getExternalContext());
String optionValue = config.getOptionValue(ClientWindowMode);
boolean clientWindowNeedsEnabling = false;
if ("none".equals(optionValue)) {
clientWindowNeedsEnabling = true;
LOGGER.log(WARNING, "{0} was set to none, but Faces Flows requires {0} is enabled. Setting to ''url''.", new Object[] { ClientWindowMode.getQualifiedName() });
} else if (optionValue == null) {
clientWindowNeedsEnabling = true;
}
if (clientWindowNeedsEnabling) {
config.setOptionValue(ClientWindowMode, "url");
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class Stage method fetchProjectStageFromConfig.
// ----------------------------------------------------------- Private methods
private String fetchProjectStageFromConfig() {
WebConfiguration webConfig = WebConfiguration.getInstance(FacesContext.getCurrentInstance().getExternalContext());
String value = webConfig.getEnvironmentEntry(WebConfiguration.WebEnvironmentEntry.ProjectStage);
if (value != null) {
if (LOGGER.isLoggable(FINE)) {
LOGGER.log(FINE, "ProjectStage configured via JNDI: {0}", value);
}
} else {
value = webConfig.getOptionValue(JakartaFacesProjectStage);
if (value != null && LOGGER.isLoggable(FINE)) {
LOGGER.log(FINE, "ProjectStage configured via servlet context init parameter: {0}", value);
}
}
return value;
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class FacesConfigExtensionProcessor method processFacesConfigExtensions.
// --------------------------------------------------------- Private Methods
private void processFacesConfigExtensions(NodeList facesConfigExtensions, String namespace, DocumentInfo info) {
WebConfiguration config = null;
for (int i = 0, size = facesConfigExtensions.getLength(); i < size; i++) {
Node facesConfigExtension = facesConfigExtensions.item(i);
NodeList children = ((Element) facesConfigExtension).getElementsByTagNameNS(namespace, "*");
for (int c = 0, csize = children.getLength(); c < csize; c++) {
Node n = children.item(c);
if (FACELETS_PROCESSING.equals(n.getLocalName())) {
Node faceletsProcessing = n;
NodeList faceletsProcessingChildren = ((Element) faceletsProcessing).getElementsByTagNameNS(namespace, "*");
String fileExtension = null, processAs = null;
for (int fp = 0, fpsize = faceletsProcessingChildren.getLength(); fp < fpsize; fp++) {
Node childOfInterset = faceletsProcessingChildren.item(fp);
if (null == fileExtension && FILE_EXTENSION.equals(childOfInterset.getLocalName())) {
fileExtension = getNodeText(childOfInterset);
} else if (null == processAs && PROCESS_AS.equals(childOfInterset.getLocalName())) {
processAs = getNodeText(childOfInterset);
} else {
if (LOGGER.isLoggable(WARNING)) {
LOGGER.log(WARNING, format("Processing faces-config-extension elements for document: ''{0}'', encountered unexpected configuration ''{1}'', ignoring and continuing", info.getSourceURI(), getNodeText(childOfInterset)));
}
}
}
if (null != fileExtension && null != processAs) {
if (null == config) {
config = WebConfiguration.getInstance();
}
Map<String, String> faceletsProcessingMappings = config.getFacesConfigOptionValue(WebConfiguration.WebContextInitParameter.FaceletsProcessingFileExtensionProcessAs, true);
faceletsProcessingMappings.put(fileExtension, processAs);
} else {
if (LOGGER.isLoggable(WARNING)) {
LOGGER.log(WARNING, MessageFormat.format("Processing faces-config-extension elements for document: ''{0}'', encountered <facelets-processing> elemnet without expected children", info.getSourceURI()));
}
}
}
}
}
}
use of com.sun.faces.config.WebConfiguration in project mojarra by eclipse-ee4j.
the class FacesFlowDefinitionConfigProcessor method process.
@Override
public void process(ServletContext sc, FacesContext facesContext, DocumentInfo[] documentInfos) throws Exception {
WebConfiguration config = WebConfiguration.getInstance(sc);
for (int i = 0; i < documentInfos.length; i++) {
URI definingDocumentURI = documentInfos[i].getSourceURI();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, MessageFormat.format("Processing factory elements for document: ''{0}''", definingDocumentURI));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement().getNamespaceURI();
NodeList flowDefinitions = document.getDocumentElement().getElementsByTagNameNS(namespace, FACES_FLOW_DEFINITION);
if (flowDefinitions != null && flowDefinitions.getLength() > 0) {
config.setHasFlows(true);
saveFlowDefinition(facesContext, definingDocumentURI, document);
}
}
if (config.isHasFlows()) {
String optionValue = config.getOptionValue(WebConfiguration.WebContextInitParameter.ClientWindowMode);
boolean clientWindowNeedsEnabling = false;
if ("none".equals(optionValue)) {
clientWindowNeedsEnabling = true;
String featureName = WebConfiguration.WebContextInitParameter.ClientWindowMode.getQualifiedName();
LOGGER.log(Level.WARNING, "{0} was set to none, but Faces Flows requires {0} is enabled. Setting to ''url''.", new Object[] { featureName });
} else if (null == optionValue) {
clientWindowNeedsEnabling = true;
}
if (clientWindowNeedsEnabling) {
config.setOptionValue(WebConfiguration.WebContextInitParameter.ClientWindowMode, "url");
}
facesContext.getApplication().subscribeToEvent(PostConstructApplicationEvent.class, Application.class, new PerformDeferredFlowProcessing());
}
}
Aggregations