Search in sources :

Example 1 with WebConfiguration

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);
            }
        }
    }
}
Also used : WebConfiguration(com.sun.faces.config.WebConfiguration)

Example 2 with WebConfiguration

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");
    }
}
Also used : WebConfiguration(com.sun.faces.config.WebConfiguration)

Example 3 with WebConfiguration

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;
}
Also used : WebConfiguration(com.sun.faces.config.WebConfiguration)

Example 4 with WebConfiguration

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()));
                    }
                }
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) WebConfiguration(com.sun.faces.config.WebConfiguration)

Example 5 with WebConfiguration

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());
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) URI(java.net.URI) WebConfiguration(com.sun.faces.config.WebConfiguration)

Aggregations

WebConfiguration (com.sun.faces.config.WebConfiguration)25 IOException (java.io.IOException)4 URI (java.net.URI)4 VariableMapperWrapper (com.sun.faces.facelets.el.VariableMapperWrapper)3 VariableMapper (jakarta.el.VariableMapper)3 TagAttributeException (jakarta.faces.view.facelets.TagAttributeException)3 FaceletContextImplBase (com.sun.faces.facelets.FaceletContextImplBase)2 FacesMessage (jakarta.faces.application.FacesMessage)2 Resource (jakarta.faces.application.Resource)2 ResourceHandler (jakarta.faces.application.ResourceHandler)2 ExternalContext (jakarta.faces.context.ExternalContext)2 FacesContext (jakarta.faces.context.FacesContext)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 Matcher (java.util.regex.Matcher)2 NodeList (org.w3c.dom.NodeList)2 ANNOTATED_CLASSES (com.sun.faces.RIConstants.ANNOTATED_CLASSES)1 FaceletsConfiguration (com.sun.faces.config.FaceletsConfiguration)1 AnnotationScanPackages (com.sun.faces.config.WebConfiguration.WebContextInitParameter.AnnotationScanPackages)1