Search in sources :

Example 1 with JakartaFacesProjectStage

use of com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage in project mojarra by eclipse-ee4j.

the class AbstractConfigProcessor method getProjectStage.

private ProjectStage getProjectStage(ServletContext sc, FacesContext facesContext) {
    final String projectStageKey = AbstractConfigProcessor.class.getName() + ".PROJECTSTAGE";
    ProjectStage projectStage = (ProjectStage) sc.getAttribute(projectStageKey);
    if (projectStage == null) {
        WebConfiguration webConfig = WebConfiguration.getInstance(facesContext.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) {
                if (LOGGER.isLoggable(FINE)) {
                    LOGGER.log(FINE, "ProjectStage configured via servlet context init parameter: {0}", value);
                }
            }
        }
        if (value != null) {
            try {
                projectStage = ProjectStage.valueOf(value);
            } catch (IllegalArgumentException iae) {
                if (LOGGER.isLoggable(INFO)) {
                    LOGGER.log(INFO, "Unable to discern ProjectStage for value {0}.", value);
                }
            }
        }
        if (projectStage == null) {
            projectStage = Production;
        }
        sc.setAttribute(projectStageKey, projectStage);
    }
    return projectStage;
}
Also used : ProjectStage(jakarta.faces.application.ProjectStage) JakartaFacesProjectStage(com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage) WebConfiguration(com.sun.faces.config.WebConfiguration)

Aggregations

WebConfiguration (com.sun.faces.config.WebConfiguration)1 JakartaFacesProjectStage (com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage)1 ProjectStage (jakarta.faces.application.ProjectStage)1