diff --git a/impl/src/main/java/com/sun/faces/application/ApplicationAssociate.java b/impl/src/main/java/com/sun/faces/application/ApplicationAssociate.java index 4bdabc4f1b..c288a4920c 100644 --- a/impl/src/main/java/com/sun/faces/application/ApplicationAssociate.java +++ b/impl/src/main/java/com/sun/faces/application/ApplicationAssociate.java @@ -18,10 +18,6 @@ import static com.sun.faces.RIConstants.FACES_CONFIG_VERSION; import static com.sun.faces.RIConstants.FACES_PREFIX; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.AutomaticExtensionlessMapping; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.FaceletsSkipComments; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsDecorators; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsDefaultRefreshPeriod; import static com.sun.faces.el.ELUtils.buildFacesResolver; import static com.sun.faces.el.FacesCompositeELResolver.ELResolverChainType.Faces; import static com.sun.faces.facelets.util.ReflectionUtil.forName; @@ -29,13 +25,10 @@ import static com.sun.faces.util.MessageUtils.getExceptionMessageString; import static com.sun.faces.util.Util.getFacesConfigXmlVersion; import static com.sun.faces.util.Util.getFacesServletRegistration; -import static com.sun.faces.util.Util.split; import static jakarta.faces.FactoryFinder.FACELET_CACHE_FACTORY; import static jakarta.faces.FactoryFinder.FLOW_HANDLER_FACTORY; import static jakarta.faces.application.ProjectStage.Development; -import static jakarta.faces.application.ProjectStage.Production; import static jakarta.faces.application.ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME; -import static java.lang.Long.parseLong; import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; import static java.util.logging.Level.FINE; @@ -61,7 +54,6 @@ import com.sun.faces.application.resource.ResourceManager; import com.sun.faces.component.search.SearchExpressionHandlerImpl; import com.sun.faces.config.ConfigManager; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.el.DemuxCompositeELResolver; import com.sun.faces.facelets.compiler.Compiler; import com.sun.faces.facelets.compiler.SAXCompiler; @@ -85,6 +77,7 @@ import jakarta.el.ExpressionFactory; import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; import jakarta.faces.application.NavigationCase; import jakarta.faces.application.ViewHandler; @@ -162,8 +155,6 @@ public class ApplicationAssociate { private final NamedEventManager namedEventManager; - private final WebConfiguration webConfig; - private FlowHandler flowHandler; private SearchExpressionHandler searchExpressionHandler; @@ -245,7 +236,6 @@ public ApplicationAssociate(ApplicationImpl appImpl) { navigationMap = new ConcurrentHashMap<>(); injectionProvider = (InjectionProvider) facesContext.getAttributes().get(ConfigManager.INJECTION_PROVIDER_KEY); - webConfig = WebConfiguration.getInstance(externalContext); annotationManager = new AnnotationManager(); @@ -313,7 +303,7 @@ public void processEvent(SystemEvent event) { String facesConfigVersion = getFacesConfigXmlVersion(context); context.getExternalContext().getApplicationMap().put(FACES_CONFIG_VERSION, facesConfigVersion); - if (webConfig.isOptionEnabled(AutomaticExtensionlessMapping)) { + if (ContextParam.AUTOMATIC_EXTENSIONLESS_MAPPING.isSet(context)) { getFacesServletRegistration(context) .ifPresent(registration -> viewHandler.getViews(context, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME) @@ -331,9 +321,8 @@ public void initializeFacelets() { FacesContext ctx = FacesContext.getCurrentInstance(); - Map appMap = ctx.getExternalContext().getApplicationMap(); - compiler = createCompiler(appMap, webConfig); - faceletFactory = createFaceletFactory(ctx, compiler, webConfig); + compiler = createCompiler(ctx); + faceletFactory = createFaceletFactory(ctx, compiler); } public long getTimeOfInstantiation() { @@ -620,20 +609,10 @@ public void relateUrlToDefiningDocumentInJar(URL url, String definingDocumentId) definingDocumentIdsToTruncatedJarUrls.put(definingDocumentId, candidate); } - protected DefaultFaceletFactory createFaceletFactory(FacesContext context, Compiler compiler, WebConfiguration webConfig) { + protected DefaultFaceletFactory createFaceletFactory(FacesContext context, Compiler compiler) { // refresh period - boolean isProduction = applicationImpl.getProjectStage() == Production; - String refreshPeriod; - if (webConfig.isSet(FaceletsDefaultRefreshPeriod)) { - refreshPeriod = webConfig.getOptionValue(FaceletsDefaultRefreshPeriod); - } else if (isProduction) { - refreshPeriod = "-1"; - } else { - refreshPeriod = FaceletsDefaultRefreshPeriod.getDefaultValue(); - } - - long period = parseLong(refreshPeriod); + int period = ContextParam.FACELETS_REFRESH_PERIOD.getValue(context); // resource resolver DefaultResourceResolver resolver = new DefaultResourceResolver(applicationImpl.getResourceHandler()); @@ -647,35 +626,33 @@ protected DefaultFaceletFactory createFaceletFactory(FacesContext context, Compi return toReturn; } - protected Compiler createCompiler(Map appMap, WebConfiguration webConfig) { + protected Compiler createCompiler(FacesContext context) { Compiler newCompiler = new SAXCompiler(); - loadDecorators(appMap, newCompiler); + loadDecorators(context, newCompiler); // Skip params? - newCompiler.setTrimmingComments(webConfig.isOptionEnabled(FaceletsSkipComments)); + newCompiler.setTrimmingComments(ContextParam.FACELETS_SKIP_COMMENTS.isSet(context)); addTagLibraries(newCompiler); return newCompiler; } - protected void loadDecorators(Map appMap, Compiler newCompiler) { - String decoratorsParamValue = webConfig.getOptionValue(FaceletsDecorators); + protected void loadDecorators(FacesContext context, Compiler newCompiler) { + String[] decorators = ContextParam.FACELETS_DECORATORS.getValue(context); - if (decoratorsParamValue != null) { - for (String decorator : split(appMap, decoratorsParamValue.trim(), ";")) { - try { - newCompiler - .addTagDecorator((TagDecorator) forName(decorator).getDeclaredConstructor().newInstance()); + for (String decorator : decorators) { + try { + newCompiler + .addTagDecorator((TagDecorator) forName(decorator).getDeclaredConstructor().newInstance()); - if (LOGGER.isLoggable(FINE)) { - LOGGER.log(FINE, "Successfully Loaded Decorator: {0}", decorator); - } - } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { - if (LOGGER.isLoggable(SEVERE)) { - LOGGER.log(SEVERE, "Error Loading Decorator: " + decorator, e); - } + if (LOGGER.isLoggable(FINE)) { + LOGGER.log(FINE, "Successfully Loaded Decorator: {0}", decorator); + } + } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { + if (LOGGER.isLoggable(SEVERE)) { + LOGGER.log(SEVERE, "Error Loading Decorator: " + decorator, e); } } } diff --git a/impl/src/main/java/com/sun/faces/application/JavaFlowLoaderHelper.java b/impl/src/main/java/com/sun/faces/application/JavaFlowLoaderHelper.java index 99d95114de..051c06dc88 100644 --- a/impl/src/main/java/com/sun/faces/application/JavaFlowLoaderHelper.java +++ b/impl/src/main/java/com/sun/faces/application/JavaFlowLoaderHelper.java @@ -16,7 +16,6 @@ package com.sun.faces.application; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.ClientWindowMode; import static com.sun.faces.util.Util.getCdiBeanManager; import static java.util.logging.Level.SEVERE; import static java.util.logging.Level.WARNING; @@ -32,12 +31,13 @@ import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.Producer; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.context.FacesContext; import jakarta.faces.flow.Flow; import jakarta.faces.flow.FlowHandler; import jakarta.faces.flow.builder.FlowDefinition; -class JavaFlowLoaderHelper { +public class JavaFlowLoaderHelper { private static final Logger LOGGER = FacesLogger.APPLICATION.getLogger(); @@ -70,24 +70,26 @@ synchronized void loadFlows(FacesContext context, FlowHandler flowHandler) throw } } - private void enableClientWindowModeIfNecessary(FacesContext context) { - WebConfiguration config = WebConfiguration.getInstance(context.getExternalContext()); - - String optionValue = config.getOptionValue(ClientWindowMode); + public static void enableClientWindowModeIfNecessary(FacesContext context) { + String optionValue = ContextParam.CLIENT_WINDOW_MODE.getValue(context); 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() }); + new Object[] { ContextParam.CLIENT_WINDOW_MODE.getName() }); } else if (optionValue == null) { clientWindowNeedsEnabling = true; } if (clientWindowNeedsEnabling) { - config.setOptionValue(ClientWindowMode, "url"); + context.getExternalContext().getApplicationMap().put(JavaFlowLoaderHelper.class.getName(), Boolean.TRUE); } } + + public static boolean isClientWindowModeForciblyEnabled(FacesContext context) { + return context.getExternalContext().getApplicationMap().get(JavaFlowLoaderHelper.class.getName()) == Boolean.TRUE; + } } diff --git a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java index bb69fc98f4..b67ebf92e3 100644 --- a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java +++ b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java @@ -17,7 +17,6 @@ package com.sun.faces.application.applicationimpl; import static com.sun.faces.application.ApplicationImpl.THIS_LIBRARY; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.DateTimeConverterUsesSystemTimezone; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.RegisterConverterPropertyEditors; import static com.sun.faces.util.Util.isEmpty; import static com.sun.faces.util.Util.loadClass; @@ -60,6 +59,7 @@ import jakarta.el.ValueExpression; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; import jakarta.faces.application.Resource; import jakarta.faces.component.UIComponent; @@ -164,10 +164,11 @@ public InstanceFactory(ApplicationAssociate applicationAssociate) { defaultValidatorIds = new LinkedHashSet<>(); behaviorMap = new ViewMemberInstanceFactoryMetadataMap<>(new ConcurrentHashMap<>()); - WebConfiguration webConfig = WebConfiguration.getInstance(FacesContext.getCurrentInstance().getExternalContext()); + FacesContext context = FacesContext.getCurrentInstance(); + WebConfiguration webConfig = WebConfiguration.getInstance(context.getExternalContext()); registerPropertyEditors = webConfig.isOptionEnabled(RegisterConverterPropertyEditors); - passDefaultTimeZone = webConfig.isOptionEnabled(DateTimeConverterUsesSystemTimezone); + passDefaultTimeZone = ContextParam.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE.getValue(context); if (passDefaultTimeZone) { systemTimeZone = TimeZone.getDefault(); } diff --git a/impl/src/main/java/com/sun/faces/application/applicationimpl/Stage.java b/impl/src/main/java/com/sun/faces/application/applicationimpl/Stage.java index 8859d0a9ab..2a51e45cb8 100644 --- a/impl/src/main/java/com/sun/faces/application/applicationimpl/Stage.java +++ b/impl/src/main/java/com/sun/faces/application/applicationimpl/Stage.java @@ -16,11 +16,8 @@ package com.sun.faces.application.applicationimpl; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage; import static jakarta.faces.application.ProjectStage.Development; -import static jakarta.faces.application.ProjectStage.Production; import static java.util.logging.Level.FINE; -import static java.util.logging.Level.INFO; import java.util.logging.Logger; @@ -28,6 +25,7 @@ import com.sun.faces.config.WebConfiguration; import com.sun.faces.util.FacesLogger; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; import jakarta.faces.application.ProjectStage; import jakarta.faces.context.FacesContext; @@ -45,9 +43,7 @@ public class Stage { public ProjectStage getProjectStage(Application application) { if (projectStage == null) { - String value = fetchProjectStageFromConfig(); - - setProjectStageFromValue(value, Production); + projectStage = fetchProjectStageFromConfig(); if (projectStage == Development) { application.subscribeToEvent(PostAddToViewEvent.class, new ValidateComponentNesting()); @@ -59,38 +55,24 @@ public ProjectStage getProjectStage(Application application) { // ----------------------------------------------------------- Private methods - private String fetchProjectStageFromConfig() { - WebConfiguration webConfig = WebConfiguration.getInstance(FacesContext.getCurrentInstance().getExternalContext()); + private ProjectStage fetchProjectStageFromConfig() { + FacesContext context = FacesContext.getCurrentInstance(); + WebConfiguration webConfig = WebConfiguration.getInstance(context.getExternalContext()); String value = webConfig.getEnvironmentEntry(WebConfiguration.WebEnvironmentEntry.ProjectStage); if (value != null) { + projectStage = ProjectStage.valueOf(value); if (LOGGER.isLoggable(FINE)) { LOGGER.log(FINE, "ProjectStage configured via JNDI: {0}", value); } } else { - value = webConfig.getOptionValue(JakartaFacesProjectStage); - if (value != null && LOGGER.isLoggable(FINE)) { + projectStage = ContextParam.PROJECT_STAGE.getValue(context); + if (LOGGER.isLoggable(FINE)) { LOGGER.log(FINE, "ProjectStage configured via servlet context init parameter: {0}", value); } } - return value; - } - - private void setProjectStageFromValue(String value, ProjectStage defaultStage) { - 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 = defaultStage; - } + return projectStage; } } diff --git a/impl/src/main/java/com/sun/faces/application/resource/FaceletWebappResourceHelper.java b/impl/src/main/java/com/sun/faces/application/resource/FaceletWebappResourceHelper.java index 33f708b208..b86b8ab123 100644 --- a/impl/src/main/java/com/sun/faces/application/resource/FaceletWebappResourceHelper.java +++ b/impl/src/main/java/com/sun/faces/application/resource/FaceletWebappResourceHelper.java @@ -18,7 +18,7 @@ import static com.sun.faces.RIConstants.FLOW_IN_JAR_PREFIX; import static com.sun.faces.config.WebConfiguration.META_INF_CONTRACTS_DIR; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsSuffix; +import static com.sun.faces.util.Util.ensureLeadingSlash; import static jakarta.faces.application.ResourceVisitOption.TOP_LEVEL_VIEWS_ONLY; import static java.util.Spliterator.DISTINCT; import static java.util.Spliterators.spliteratorUnknownSize; @@ -35,11 +35,11 @@ import java.util.stream.Stream; import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.util.Util; import jakarta.enterprise.inject.Any; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.annotation.View; import jakarta.faces.application.ResourceVisitOption; import jakarta.faces.context.ExternalContext; @@ -55,8 +55,8 @@ public class FaceletWebappResourceHelper extends ResourceHelper { public FaceletWebappResourceHelper(WebappResourceHelper webappResourceHelper) { this.webappResourceHelper = webappResourceHelper; - WebConfiguration webConfig = WebConfiguration.getInstance(); - configuredExtensions = webConfig.getOptionValue(FaceletsSuffix, " "); + FacesContext context = FacesContext.getCurrentInstance(); + configuredExtensions = new String[] { ContextParam.FACELETS_SUFFIX.getValue(context) }; } @Override diff --git a/impl/src/main/java/com/sun/faces/application/resource/ResourceHandlerImpl.java b/impl/src/main/java/com/sun/faces/application/resource/ResourceHandlerImpl.java index a285638129..31c2c94d3f 100644 --- a/impl/src/main/java/com/sun/faces/application/resource/ResourceHandlerImpl.java +++ b/impl/src/main/java/com/sun/faces/application/resource/ResourceHandlerImpl.java @@ -18,7 +18,6 @@ import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.DefaultResourceMaxAge; import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.ResourceBufferSize; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.ResourceExcludes; import static com.sun.faces.util.RequestStateManager.RESOURCE_REQUEST; import static com.sun.faces.util.Util.getFacesMapping; import static com.sun.faces.util.Util.notNegative; @@ -51,8 +50,8 @@ import com.sun.faces.config.WebConfiguration; import com.sun.faces.util.FacesLogger; import com.sun.faces.util.RequestStateManager; -import com.sun.faces.util.Util; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Resource; import jakarta.faces.application.ResourceHandler; import jakarta.faces.application.ResourceVisitOption; @@ -81,9 +80,10 @@ public class ResourceHandlerImpl extends ResourceHandler { public ResourceHandlerImpl() { creationTime = System.currentTimeMillis(); webconfig = WebConfiguration.getInstance(); - ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext(); + FacesContext context = FacesContext.getCurrentInstance(); + ExternalContext extContext = context.getExternalContext(); manager = ApplicationAssociate.getInstance(extContext).getResourceManager(); - initExclusions(extContext.getApplicationMap()); + initExclusions(context); initMaxAge(); } @@ -559,9 +559,8 @@ private boolean isExcluded(String resourceId) { *
    * will be used. */ - private void initExclusions(Map appMap) { - String excludesParam = webconfig.getOptionValue(ResourceExcludes); - String[] patterns = Util.split(appMap, excludesParam, " "); + private void initExclusions(FacesContext context) { + String[] patterns = ContextParam.RESOURCE_EXCLUDES.getValue(context); excludePatterns = new ArrayList<>(patterns.length); for (String pattern : patterns) { diff --git a/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java b/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java index 702b42ddbb..965cb61c0e 100644 --- a/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java +++ b/impl/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java @@ -34,6 +34,7 @@ import com.sun.faces.util.FacesLogger; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.ProjectStage; import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.FacesContext; @@ -61,9 +62,10 @@ public class WebappResourceHelper extends ResourceHelper { public WebappResourceHelper() { WebConfiguration webconfig = WebConfiguration.getInstance(); + FacesContext context = FacesContext.getCurrentInstance(); cacheTimestamp = webconfig.isOptionEnabled(CacheResourceModificationTimestamp); - BASE_RESOURCE_PATH = ensureLeadingSlash(webconfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppResourcesDirectory)); - BASE_CONTRACTS_PATH = ensureLeadingSlash(webconfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory)); + BASE_RESOURCE_PATH = ensureLeadingSlash(ContextParam.WEBAPP_RESOURCES_DIRECTORY.getValue(context)); + BASE_CONTRACTS_PATH = ensureLeadingSlash(ContextParam.WEBAPP_CONTRACTS_DIRECTORY.getValue(context)); } diff --git a/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java b/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java index ded8fb2df2..91275480c7 100644 --- a/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java +++ b/impl/src/main/java/com/sun/faces/application/view/FaceletViewHandlingStrategy.java @@ -19,8 +19,6 @@ import static com.sun.faces.RIConstants.DYNAMIC_COMPONENT; import static com.sun.faces.RIConstants.FACELETS_ENCODING_KEY; import static com.sun.faces.RIConstants.FLOW_DEFINITION_ID_SUFFIX; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsBufferSize; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsViewMappings; import static com.sun.faces.context.StateContext.getStateContext; import static com.sun.faces.facelets.tag.ui.UIDebug.debugRequest; import static com.sun.faces.renderkit.RenderKitUtils.getResponseStateManager; @@ -36,7 +34,6 @@ import static com.sun.faces.util.Util.saveDOCTYPEToFacesContextAttributes; import static com.sun.faces.util.Util.saveXMLDECLToFacesContextAttributes; import static com.sun.faces.util.Util.setViewPopulated; -import static com.sun.faces.util.Util.split; import static jakarta.faces.FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY; import static jakarta.faces.application.ProjectStage.Development; import static jakarta.faces.application.Resource.COMPONENT_RESOURCE_KEY; @@ -77,8 +74,6 @@ import java.util.stream.Stream; import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.config.WebConfiguration.WebContextInitParameter; import com.sun.faces.context.StateContext; import com.sun.faces.facelets.compiler.FaceletDoctype; import com.sun.faces.facelets.el.ContextualCompositeMethodExpression; @@ -104,6 +99,7 @@ import jakarta.el.VariableMapper; import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Resource; import jakarta.faces.application.StateManager.StateSavingMethod; import jakarta.faces.application.ViewHandler; @@ -411,7 +407,7 @@ public void renderView(FacesContext ctx, UIViewRoot viewToRender) throws IOExcep } // If the buffer size is -1, use the default buffer size - final int bufferSize = responseBufferSize != -1 ? responseBufferSize : Integer.parseInt(FaceletsBufferSize.getDefaultValue()); + final int bufferSize = responseBufferSize != -1 ? responseBufferSize : ViewHandler.FACELETS_BUFFER_SIZE_DEFAULT_VALUE; stateWriter = new WriteBehindStateWriter(extContext.getResponseOutputWriter(), ctx, bufferSize); ResponseWriter writer = origWriter.cloneWithWriter(stateWriter); @@ -777,8 +773,8 @@ public Stream getViews(FacesContext context, String path, int maxDepth, * @return true if assuming a default configuration and the view ID's extension in {@link ViewHandler#FACELETS_SUFFIX_PARAM_NAME} * Otherwise try to match the view ID based on the configured extensions and prefixes in {@link ViewHandler#FACELETS_VIEW_MAPPINGS_PARAM_NAME} * - * @see com.sun.faces.config.WebConfiguration.WebContextInitParameter#FaceletsSuffix - * @see com.sun.faces.config.WebConfiguration.WebContextInitParameter#FaceletsViewMappings + * @see ContextParam#FACELETS_SUFFIX + * @see ContextParam#FACELETS_VIEW_MAPPINGS */ @Override public boolean handlesViewId(String viewId) { @@ -818,11 +814,7 @@ protected void initialize() { return FaceletViewHandlingStrategy.this.createComponentMetadata(context, ccResource); }); - try { - responseBufferSize = Integer.parseInt(webConfig.getOptionValue(FaceletsBufferSize)); - } catch (NumberFormatException nfe) { - responseBufferSize = Integer.parseInt(FaceletsBufferSize.getDefaultValue()); - } + responseBufferSize = ContextParam.FACELETS_BUFFER_SIZE.getValue(FacesContext.getCurrentInstance()); LOGGER.fine("Initialization Successful"); @@ -849,12 +841,9 @@ protected void initialize() { * Initialize mappings, during the first request. */ protected void initializeMappings() { - String viewMappings = webConfig.getOptionValue(FaceletsViewMappings); - if (viewMappings != null && viewMappings.length() > 0) { - Map appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap(); - - String[] mappingsArray = split(appMap, viewMappings, ";"); - + FacesContext context = FacesContext.getCurrentInstance(); + String[] mappingsArray = ContextParam.FACELETS_VIEW_MAPPINGS.getValue(context); + if (mappingsArray.length > 0) { List extensionsList = new ArrayList<>(mappingsArray.length); List prefixesList = new ArrayList<>(mappingsArray.length); @@ -1805,7 +1794,7 @@ private void reapplyDynamicRemove(FacesContext context, ComponentStruct struct) * @return true if we are, false otherwise. */ private boolean isServerStateSaving() { - if (StateSavingMethod.SERVER.name().equalsIgnoreCase(webConfig.getOptionValue(WebContextInitParameter.StateSavingMethod))) { + if (StateSavingMethod.SERVER == ContextParam.STATE_SAVING_METHOD.getValue(FacesContext.getCurrentInstance())) { return true; } @@ -1842,22 +1831,18 @@ private DefaultFaceletFactory getFaceletFactory() { } private boolean isMatchedWithFaceletsSuffix(String viewId) { - String[] defaultsuffixes = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsSuffix, " "); - for (String suffix : defaultsuffixes) { - if (viewId.endsWith(suffix)) { - return true; - } + String suffix = ContextParam.FACELETS_SUFFIX.getValue(FacesContext.getCurrentInstance()); + if (viewId.endsWith(suffix)) { + return true; } return false; } private String getMatchedWithFaceletsSuffix(String viewId) { - String[] defaultsuffixes = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsSuffix, " "); - for (String suffix : defaultsuffixes) { - if (viewId.endsWith(suffix)) { - return suffix; - } + String suffix = ContextParam.FACELETS_SUFFIX.getValue(FacesContext.getCurrentInstance()); + if (viewId.endsWith(suffix)) { + return suffix; } return null; diff --git a/impl/src/main/java/com/sun/faces/application/view/MultiViewHandler.java b/impl/src/main/java/com/sun/faces/application/view/MultiViewHandler.java index 9055268f4c..439265168d 100644 --- a/impl/src/main/java/com/sun/faces/application/view/MultiViewHandler.java +++ b/impl/src/main/java/com/sun/faces/application/view/MultiViewHandler.java @@ -34,6 +34,7 @@ import static jakarta.servlet.http.MappingMatch.EXACT; import static jakarta.servlet.http.MappingMatch.EXTENSION; import static jakarta.servlet.http.MappingMatch.PATH; +import static java.util.Arrays.asList; import static java.util.Collections.unmodifiableSet; import static java.util.Objects.requireNonNull; import static java.util.logging.Level.SEVERE; @@ -56,12 +57,12 @@ import java.util.logging.Logger; import java.util.stream.Stream; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.util.FacesLogger; import com.sun.faces.util.Util; import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.ViewHandler; import jakarta.faces.application.ViewVisitOption; import jakarta.faces.component.UIViewParameter; @@ -90,9 +91,8 @@ public class MultiViewHandler extends ViewHandler { // ------------------------------------------------------------ Constructors public MultiViewHandler() { - WebConfiguration config = WebConfiguration.getInstance(); - - configuredExtensions = config.getConfiguredExtensions(); + String faceletsSuffix = ContextParam.FACELETS_SUFFIX.getValue(FacesContext.getCurrentInstance()); + configuredExtensions = asList(faceletsSuffix); vdlFactory = (ViewDeclarationLanguageFactory) FactoryFinder.getFactory(VIEW_DECLARATION_LANGUAGE_FACTORY); protectedViews = new CopyOnWriteArraySet<>(); } diff --git a/impl/src/main/java/com/sun/faces/cdi/clientwindow/ClientWindowScopeContextManager.java b/impl/src/main/java/com/sun/faces/cdi/clientwindow/ClientWindowScopeContextManager.java index 6f6d234681..4498624a65 100644 --- a/impl/src/main/java/com/sun/faces/cdi/clientwindow/ClientWindowScopeContextManager.java +++ b/impl/src/main/java/com/sun/faces/cdi/clientwindow/ClientWindowScopeContextManager.java @@ -18,14 +18,12 @@ 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 com.sun.faces.context.SessionMap.getMutex; 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; @@ -35,6 +33,7 @@ import jakarta.enterprise.context.spi.Contextual; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.PassivationCapable; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; import jakarta.servlet.http.HttpSession; @@ -144,19 +143,7 @@ private Map getContextMap(FacesContext f String clientWindowId = getCurrentClientWindowId(facesContext); if (clientWindowScopeContexts == null && create) { - 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()); - } - } - - if (numberOfClientWindows == null) { - numberOfClientWindows = Integer.valueOf(NumberOfClientWindows.getDefaultValue()); - } + int numberOfClientWindows = ContextParam.NUMBER_OF_CLIENT_WINDOWS.getValue(facesContext); synchronized (getMutex(session)) { sessionMap.put(CLIENT_WINDOW_CONTEXTS, Collections.synchronizedMap(new LRUMap(numberOfClientWindows))); diff --git a/impl/src/main/java/com/sun/faces/config/ConfigureListener.java b/impl/src/main/java/com/sun/faces/config/ConfigureListener.java index 9e654bbe0b..8122611911 100644 --- a/impl/src/main/java/com/sun/faces/config/ConfigureListener.java +++ b/impl/src/main/java/com/sun/faces/config/ConfigureListener.java @@ -22,10 +22,8 @@ import static com.sun.faces.RIConstants.FACES_SERVLET_REGISTRATION; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableLazyBeanValidation; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableThreading; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableWebsocketEndpoint; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.ForceLoadFacesConfigFiles; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.VerifyFacesConfigObjects; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage; import static com.sun.faces.context.SessionMap.createMutex; import static com.sun.faces.context.SessionMap.removeMutex; import static com.sun.faces.push.WebsocketEndpoint.URI_TEMPLATE; @@ -73,7 +71,9 @@ import jakarta.el.ELManager; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; +import jakarta.faces.application.ProjectStage; import jakarta.faces.context.FacesContext; import jakarta.faces.event.PreDestroyApplicationEvent; import jakarta.servlet.ServletContext; @@ -215,7 +215,7 @@ public void contextInitialized(ServletContextEvent servletContextEvent) { // Register websocket endpoint if explicitly enabled. // Note: websocket channel filter is registered in FacesInitializer. - if (webConfig.isOptionEnabled(EnableWebsocketEndpoint)) { + if (ContextParam.ENABLE_WEBSOCKET_ENDPOINT.isSet(initFacesContext)) { ServerContainer serverContainer = (ServerContainer) servletContext.getAttribute(ServerContainer.class.getName()); if (serverContainer == null) { @@ -399,7 +399,7 @@ private void initConfigMonitoring(ServletContext context) { private boolean isDevModeEnabled() { // interrogate the init parameter directly vs looking up the application - return "Development".equals(webConfig.getOptionValue(JakartaFacesProjectStage)); + return ContextParam.PROJECT_STAGE.getValue(FacesContext.getCurrentInstance()) == ProjectStage.Development; } /** diff --git a/impl/src/main/java/com/sun/faces/config/FacesInitializer.java b/impl/src/main/java/com/sun/faces/config/FacesInitializer.java index b5e0b16352..342e65e144 100644 --- a/impl/src/main/java/com/sun/faces/config/FacesInitializer.java +++ b/impl/src/main/java/com/sun/faces/config/FacesInitializer.java @@ -21,7 +21,6 @@ import static com.sun.faces.RIConstants.FACES_SERVLET_MAPPINGS; import static com.sun.faces.RIConstants.FACES_SERVLET_REGISTRATION; import static com.sun.faces.util.Util.isEmpty; -import static java.lang.Boolean.parseBoolean; import static java.util.logging.Level.WARNING; import java.util.HashSet; @@ -33,11 +32,13 @@ import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.FacesConfig; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.ResourceDependencies; import jakarta.faces.application.ResourceDependency; import jakarta.faces.component.FacesComponent; import jakarta.faces.component.UIComponent; import jakarta.faces.component.behavior.FacesBehavior; +import jakarta.faces.context.FacesContext; import jakarta.faces.convert.Converter; import jakarta.faces.convert.FacesConverter; import jakarta.faces.event.ListenerFor; @@ -51,7 +52,6 @@ import jakarta.faces.model.DataModel; import jakarta.faces.model.FacesDataModel; import jakarta.faces.push.Push; -import jakarta.faces.push.PushContext; import jakarta.faces.render.FacesBehaviorRenderer; import jakarta.faces.render.FacesRenderer; import jakarta.faces.render.Renderer; @@ -115,12 +115,12 @@ public void onStartup(Set> classes, ServletContext servletContext) thro try { if (appHasFacesContent) { // Only look at mapping concerns if there is Faces content - handleMappingConcerns(servletContext); + handleMappingConcerns(servletContext, initFacesContext); } // Other concerns also handled if there is an existing Faces Servlet mapping handleCdiConcerns(servletContext); - handleWebSocketConcerns(servletContext); + handleWebSocketConcerns(servletContext, initFacesContext); // The Configure listener will do the bulk of initializing (configuring) Faces in a later phase. servletContext.addListener(ConfigureListener.class); @@ -186,7 +186,7 @@ private static ServletRegistration getExistingFacesServletRegistration(ServletCo return null; } - private static void handleMappingConcerns(ServletContext servletContext) throws ServletException { + private static void handleMappingConcerns(ServletContext servletContext, FacesContext facesContext) throws ServletException { ServletRegistration existingFacesServletRegistration = getExistingFacesServletRegistration(servletContext); if (existingFacesServletRegistration != null) { @@ -197,7 +197,7 @@ private static void handleMappingConcerns(ServletContext servletContext) throws ServletRegistration newFacesServletRegistration = servletContext.addServlet(FacesServlet.class.getSimpleName(), FACES_SERVLET_CLASS_NAME); - if (parseBoolean(servletContext.getInitParameter(FacesServlet.DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME))) { + if (ContextParam.DISABLE_FACESSERVLET_TO_XHTML.isSet(facesContext)) { newFacesServletRegistration.addMapping(FACES_SERVLET_MAPPINGS_WITHOUT_XHTML); } else { @@ -243,13 +243,13 @@ private static void handleCdiConcerns(ServletContext context) throws ServletExce } } - private static void handleWebSocketConcerns(ServletContext context) throws ServletException { + private static void handleWebSocketConcerns(ServletContext context, FacesContext facesContext) throws ServletException { if (context.getAttribute(ServerContainer.class.getName()) != null) { // Already initialized return; } - if (!parseBoolean(context.getInitParameter(PushContext.ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME))) { + if (!ContextParam.ENABLE_WEBSOCKET_ENDPOINT.isSet(facesContext)) { // Register websocket endpoint is not enabled return; } diff --git a/impl/src/main/java/com/sun/faces/config/WebConfiguration.java b/impl/src/main/java/com/sun/faces/config/WebConfiguration.java index 28c3aa4c65..46b2fd3903 100644 --- a/impl/src/main/java/com/sun/faces/config/WebConfiguration.java +++ b/impl/src/main/java/com/sun/faces/config/WebConfiguration.java @@ -17,9 +17,7 @@ package com.sun.faces.config; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsSuffix; import static com.sun.faces.util.Util.split; -import static java.util.Arrays.asList; import static java.util.Collections.emptyMap; import static java.util.logging.Level.FINE; import static java.util.regex.Pattern.CASE_INSENSITIVE; @@ -33,7 +31,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -54,22 +51,13 @@ import com.sun.faces.util.Util; import jakarta.faces.FactoryFinder; -import jakarta.faces.application.ProjectStage; import jakarta.faces.application.ResourceHandler; import jakarta.faces.application.StateManager; -import jakarta.faces.application.ViewHandler; -import jakarta.faces.component.UIInput; -import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; -import jakarta.faces.convert.Converter; import jakarta.faces.event.PhaseListener; -import jakarta.faces.lifecycle.ClientWindow; import jakarta.faces.lifecycle.Lifecycle; import jakarta.faces.lifecycle.LifecycleFactory; -import jakarta.faces.push.PushContext; -import jakarta.faces.validator.BeanValidator; -import jakarta.faces.webapp.FacesServlet; import jakarta.servlet.ServletContext; /** @@ -86,7 +74,7 @@ public class WebConfiguration { // Key under which we store our WebConfiguration instance. private static final String WEB_CONFIG_KEY = "com.sun.faces.config.WebConfiguration"; - public static final String META_INF_CONTRACTS_DIR = "META-INF" + WebContextInitParameter.WebAppContractsDirectory.getDefaultValue(); + public static final String META_INF_CONTRACTS_DIR = "META-INF" + ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_DEFAULT_VALUE; private static final int META_INF_CONTRACTS_DIR_LEN = META_INF_CONTRACTS_DIR.length(); @@ -103,7 +91,7 @@ public class WebConfiguration { private final Map envEntries = new EnumMap<>(WebEnvironmentEntry.class); - private final Map cachedListParams; + private final Map cachedListParams = new HashMap<>(); private final Set setParams = new HashSet<>(); @@ -130,12 +118,6 @@ private WebConfiguration(ServletContext servletContext) { if (canProcessJndiEntries()) { processJndiEntries(contextName); } - - // build the cache of list type params - cachedListParams = new HashMap<>(3); - getOptionValue(WebContextInitParameter.ResourceExcludes, " "); - getOptionValue(WebContextInitParameter.FaceletsViewMappings, ";"); - getOptionValue(WebContextInitParameter.FaceletsSuffix, " "); specificationVersion = getClass().getPackage().getSpecificationVersion(); } @@ -330,17 +312,6 @@ public void overrideContextInitParameter(BooleanWebContextInitParameter param, b } - /** - * @return the facelet suffixes. - */ - public List getConfiguredExtensions() { - String[] faceletsSuffix = getOptionValue(FaceletsSuffix, " "); - - Set deduplicatedFaceletsSuffixes = new LinkedHashSet<>(asList(faceletsSuffix)); - - return new ArrayList<>(deduplicatedFaceletsSuffixes); - } - public void overrideContextInitParameter(WebContextInitParameter param, String value) { if (param == null || value == null || value.length() == 0) { return; @@ -748,13 +719,6 @@ public enum WebContextInitParameter { // if a parameter is to be deprecated, then the Deprecated enum element *must* appear after the one that is taking // its place. The reporting logic depends on this. - StateSavingMethod(StateManager.STATE_SAVING_METHOD_PARAM_NAME, "server"), - FaceletsSuffix(ViewHandler.FACELETS_SUFFIX_PARAM_NAME, ViewHandler.DEFAULT_FACELETS_SUFFIX), - JakartaFacesConfigFiles(FacesServlet.CONFIG_FILES_ATTR, ""), - 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"), @@ -762,7 +726,6 @@ public enum WebContextInitParameter { NumberOfFlashesBetweenFlashReapings("com.sun.faces.numberOfFlashesBetweenFlashReapings", "5000"), InjectionProviderClass("com.sun.faces.injectionProvider", ""), SerializationProviderClass("com.sun.faces.serializationProvider", ""), - FaceletsBufferSize(ViewHandler.FACELETS_BUFFER_SIZE_PARAM_NAME, "1024"), ClientStateWriteBufferSize("com.sun.faces.clientStateWriteBufferSize", "8192"), ResourceBufferSize("com.sun.faces.resourceBufferSize", "2048"), ClientStateTimeout("com.sun.faces.clientStateTimeout", ""), @@ -770,18 +733,10 @@ public enum WebContextInitParameter { ResourceUpdateCheckPeriod("com.sun.faces.resourceUpdateCheckPeriod", "5"), // in minutes CompressableMimeTypes("com.sun.faces.compressableMimeTypes", ""), DisableUnicodeEscaping("com.sun.faces.disableUnicodeEscaping", "auto"), - FaceletsDefaultRefreshPeriod(ViewHandler.FACELETS_REFRESH_PERIOD_PARAM_NAME, "0"), // this is default for non-prod; default for prod is set in WebConfiguration - FaceletsViewMappings(ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME, ""), - FaceletsLibraries(ViewHandler.FACELETS_LIBRARIES_PARAM_NAME, ""), - FaceletsDecorators(ViewHandler.FACELETS_DECORATORS_PARAM_NAME, ""), DuplicateJARPattern("com.sun.faces.duplicateJARPattern", ""), - ValidateEmptyFields(UIInput.VALIDATE_EMPTY_FIELDS_PARAM_NAME, "auto"), FullStateSavingViewIds(StateManager.FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME, ""), AnnotationScanPackages("com.sun.faces.annotationScanPackages", ""), FaceletsProcessingFileExtensionProcessAs("", ""), - ClientWindowMode(ClientWindow.CLIENT_WINDOW_MODE_PARAM_NAME, "none"), - WebAppResourcesDirectory(ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME, "/resources"), - WebAppContractsDirectory(ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, "/contracts"), ; private final String defaultValue; @@ -847,14 +802,11 @@ public enum BooleanWebContextInitParameter { // *must* appear after the one that is taking // its place. The reporting logic depends on this - AlwaysPerformValidationWhenRequiredTrue(UIInput.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, false), DisplayConfiguration("com.sun.faces.displayConfiguration", false), ValidateFacesConfigFiles("com.sun.faces.validateXml", false), VerifyFacesConfigObjects("com.sun.faces.verifyObjects", false), ForceLoadFacesConfigFiles("com.sun.faces.forceLoadConfiguration", false), DisableClientStateEncryption("com.sun.faces.disableClientStateEncryption", false), - DisableFacesServletAutomaticMapping(FacesServlet.DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME, false), - AutomaticExtensionlessMapping(FacesServlet.AUTOMATIC_EXTENSIONLESS_MAPPING_PARAM_NAME, false), EnableClientStateDebugging("com.sun.faces.enableClientStateDebugging", false), PreferXHTMLContentType("com.sun.faces.preferXHTML", false), CompressViewState("com.sun.faces.compressViewState", true), @@ -862,28 +814,20 @@ public enum BooleanWebContextInitParameter { EnableScriptInAttributeValue("com.sun.faces.enableScriptsInAttributeValues", true), WriteStateAtFormEnd("com.sun.faces.writeStateAtFormEnd", true), EnableLazyBeanValidation("com.sun.faces.enableLazyBeanValidation", true), - SerializeServerState(StateManager.SERIALIZE_SERVER_STATE_PARAM_NAME, false), EnableViewStateIdRendering("com.sun.faces.enableViewStateIdRendering", true), RegisterConverterPropertyEditors("com.sun.faces.registerConverterPropertyEditors", false), - DisableDefaultBeanValidator(BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME, false), - DateTimeConverterUsesSystemTimezone(Converter.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE_PARAM_NAME, false), EnableHttpMethodRestrictionPhaseListener("com.sun.faces.ENABLE_HTTP_METHOD_RESTRICTION_PHASE_LISTENER", false), - FaceletsSkipComments(ViewHandler.FACELETS_SKIP_COMMENTS_PARAM_NAME, false), PartialStateSaving(StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, true), GenerateUniqueServerStateIds("com.sun.faces.generateUniqueServerStateIds", true), - InterpretEmptyStringSubmittedValuesAsNull(UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME, false), AutoCompleteOffOnViewState("com.sun.faces.autoCompleteOffOnViewState", true), EnableThreading("com.sun.faces.enableThreading", false), AllowTextChildren("com.sun.faces.allowTextChildren", false), CacheResourceModificationTimestamp("com.sun.faces.cacheResourceModificationTimestamp", false), - EnableDistributable("com.sun.faces.enableDistributable", false), + EnableDistributable("com.sun.faces.enableDistributable", false), // NOTE: this is indeed implicitly set to true when web.xml distributable is also set, see ConfigureListener. EnableMissingResourceLibraryDetection("com.sun.faces.enableMissingResourceLibraryDetection", false), DisableIdUniquenessCheck("com.sun.faces.disableIdUniquenessCheck", false), EnableTransitionTimeNoOpFlash("com.sun.faces.enableTransitionTimeNoOpFlash", false), ForceAlwaysWriteFlashCookie("com.sun.faces.forceAlwaysWriteFlashCookie", false), - ViewRootPhaseListenerQueuesException(UIViewRoot.VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS_PARAM_NAME, false), - EnableValidateWholeBean(BeanValidator.ENABLE_VALIDATE_WHOLE_BEAN_PARAM_NAME, false), - EnableWebsocketEndpoint(PushContext.ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME, false), DisallowDoctypeDecl("com.sun.faces.disallowDoctypeDecl", false), UseFaceletsID("com.sun.faces.useFaceletsID",false), ; diff --git a/impl/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigResourceProvider.java b/impl/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigResourceProvider.java index 70615c9edc..c434c6b232 100644 --- a/impl/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigResourceProvider.java +++ b/impl/src/main/java/com/sun/faces/config/configprovider/BaseWebConfigResourceProvider.java @@ -16,8 +16,6 @@ package com.sun.faces.config.configprovider; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesConfigFiles; -import static com.sun.faces.util.Util.split; import static java.util.Arrays.binarySearch; import static java.util.logging.Level.WARNING; @@ -30,12 +28,12 @@ import java.util.Set; import java.util.logging.Logger; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.config.WebConfiguration.WebContextInitParameter; import com.sun.faces.spi.ConfigurationResourceProvider; import com.sun.faces.util.FacesLogger; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; +import jakarta.faces.context.FacesContext; import jakarta.servlet.ServletContext; /** @@ -50,24 +48,19 @@ public abstract class BaseWebConfigResourceProvider implements ConfigurationReso @Override public Collection getResources(ServletContext context) { - WebConfiguration webConfig = WebConfiguration.getInstance(context); - String paths = webConfig.getOptionValue(getParameter()); + String[] paths = getParameter().getValue(FacesContext.getCurrentInstance()); Set urls = new LinkedHashSet<>(6); - if (paths != null) { - for (String token : split(context, paths.trim(), getSeparatorRegex())) { - String path = token.trim(); - if (!isExcluded(path) && path.length() != 0) { - URI u = getContextURLForPath(context, path); - if (u != null) { - urls.add(u); - } else { - if (LOGGER.isLoggable(WARNING)) { - LOGGER.log(WARNING, "faces.config.web_resource_not_found", new Object[] { path, JakartaFacesConfigFiles.getQualifiedName() }); - } + for (String path : paths) { + if (!isExcluded(path) && path.length() != 0) { + URI u = getContextURLForPath(context, path); + if (u != null) { + urls.add(u); + } else { + if (LOGGER.isLoggable(WARNING)) { + LOGGER.log(WARNING, "faces.config.web_resource_not_found", new Object[] { path, getParameter().getName() }); } } - } } @@ -76,7 +69,7 @@ public Collection getResources(ServletContext context) { // ------------------------------------------------------- Protected Methods - protected abstract WebContextInitParameter getParameter(); + protected abstract ContextParam getParameter(); protected abstract String[] getExcludedResources(); diff --git a/impl/src/main/java/com/sun/faces/config/configprovider/WebFaceletTaglibResourceProvider.java b/impl/src/main/java/com/sun/faces/config/configprovider/WebFaceletTaglibResourceProvider.java index 9e5356ee23..0604cb02af 100644 --- a/impl/src/main/java/com/sun/faces/config/configprovider/WebFaceletTaglibResourceProvider.java +++ b/impl/src/main/java/com/sun/faces/config/configprovider/WebFaceletTaglibResourceProvider.java @@ -16,9 +16,7 @@ package com.sun.faces.config.configprovider; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.FaceletsLibraries; - -import com.sun.faces.config.WebConfiguration.WebContextInitParameter; +import jakarta.faces.annotation.FacesConfig.ContextParam; /** * @@ -31,8 +29,8 @@ public class WebFaceletTaglibResourceProvider extends BaseWebConfigResourceProvi // ------------------------------ Methods from BaseWebConfigResourceProvider @Override - protected WebContextInitParameter getParameter() { - return FaceletsLibraries; + protected ContextParam getParameter() { + return ContextParam.FACELETS_LIBRARIES; } @Override diff --git a/impl/src/main/java/com/sun/faces/config/configprovider/WebFacesConfigResourceProvider.java b/impl/src/main/java/com/sun/faces/config/configprovider/WebFacesConfigResourceProvider.java index d14cdef62c..f699a22380 100644 --- a/impl/src/main/java/com/sun/faces/config/configprovider/WebFacesConfigResourceProvider.java +++ b/impl/src/main/java/com/sun/faces/config/configprovider/WebFacesConfigResourceProvider.java @@ -16,13 +16,10 @@ package com.sun.faces.config.configprovider; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesConfigFiles; - import java.net.URI; import java.util.Collection; -import com.sun.faces.config.WebConfiguration.WebContextInitParameter; - +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.servlet.ServletContext; /** @@ -66,8 +63,8 @@ public Collection getResources(ServletContext context) { // ------------------------------ Methods from BaseWebConfigResourceProvider @Override - protected WebContextInitParameter getParameter() { - return JakartaFacesConfigFiles; + protected ContextParam getParameter() { + return ContextParam.CONFIG_FILES; } @Override diff --git a/impl/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java b/impl/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java index b75123fab8..135a915305 100644 --- a/impl/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java +++ b/impl/src/main/java/com/sun/faces/config/processor/AbstractConfigProcessor.java @@ -18,7 +18,6 @@ import static com.sun.faces.application.ApplicationResourceBundle.DEFAULT_KEY; import static com.sun.faces.config.ConfigManager.INJECTION_PROVIDER_KEY; -import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.JakartaFacesProjectStage; import static com.sun.faces.util.ReflectionUtils.lookupConstructor; import static jakarta.faces.FactoryFinder.APPLICATION_FACTORY; import static jakarta.faces.application.ProjectStage.Development; @@ -53,6 +52,7 @@ import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; import jakarta.faces.application.ApplicationFactory; import jakarta.faces.application.ProjectStage; @@ -324,16 +324,6 @@ private ProjectStage getProjectStage(ServletContext sc, FacesContext facesContex 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) { @@ -341,6 +331,13 @@ private ProjectStage getProjectStage(ServletContext sc, FacesContext facesContex LOGGER.log(INFO, "Unable to discern ProjectStage for value {0}.", value); } } + } else { + projectStage = ContextParam.PROJECT_STAGE.getValue(facesContext); + if (projectStage != null) { + if (LOGGER.isLoggable(FINE)) { + LOGGER.log(FINE, "ProjectStage configured via servlet context init parameter: {0}", value); + } + } } if (projectStage == null) { diff --git a/impl/src/main/java/com/sun/faces/config/processor/ApplicationConfigProcessor.java b/impl/src/main/java/com/sun/faces/config/processor/ApplicationConfigProcessor.java index 5af54f0b58..8960587cb1 100644 --- a/impl/src/main/java/com/sun/faces/config/processor/ApplicationConfigProcessor.java +++ b/impl/src/main/java/com/sun/faces/config/processor/ApplicationConfigProcessor.java @@ -48,13 +48,13 @@ import com.sun.faces.application.ApplicationAssociate; import com.sun.faces.application.ApplicationResourceBundle; import com.sun.faces.config.ConfigurationException; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.config.manager.documents.DocumentInfo; import com.sun.faces.util.FacesLogger; import com.sun.faces.util.Util; import jakarta.el.ELResolver; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; import jakarta.faces.application.ConfigurableNavigationHandler; import jakarta.faces.application.NavigationHandler; @@ -341,8 +341,7 @@ private void registerDefaultValidatorIds(FacesContext facesContext, Application if (defaultValidatorIds == null) { defaultValidatorIds = new LinkedHashSet<>(); if (isBeanValidatorAvailable(facesContext)) { - WebConfiguration webConfig = WebConfiguration.getInstance(); - if (!webConfig.isOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.DisableDefaultBeanValidator)) { + if (!ContextParam.DISABLE_DEFAULT_BEAN_VALIDATOR.isSet(facesContext)) { defaultValidatorIds.add(BeanValidator.VALIDATOR_ID); } } diff --git a/impl/src/main/java/com/sun/faces/config/processor/FacesFlowDefinitionConfigProcessor.java b/impl/src/main/java/com/sun/faces/config/processor/FacesFlowDefinitionConfigProcessor.java index 294e737125..2aca9b68bc 100644 --- a/impl/src/main/java/com/sun/faces/config/processor/FacesFlowDefinitionConfigProcessor.java +++ b/impl/src/main/java/com/sun/faces/config/processor/FacesFlowDefinitionConfigProcessor.java @@ -47,6 +47,7 @@ import com.sun.faces.RIConstants; import com.sun.faces.application.ApplicationAssociate; +import com.sun.faces.application.JavaFlowLoaderHelper; import com.sun.faces.config.WebConfiguration; import com.sun.faces.config.manager.documents.DocumentInfo; import com.sun.faces.facelets.util.ReflectionUtil; @@ -177,19 +178,7 @@ public void process(ServletContext sc, FacesContext facesContext, DocumentInfo[] } 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"); - } - + JavaFlowLoaderHelper.enableClientWindowModeIfNecessary(facesContext); facesContext.getApplication().subscribeToEvent(PostConstructApplicationEvent.class, Application.class, new PerformDeferredFlowProcessing()); } diff --git a/impl/src/main/java/com/sun/faces/context/ContextParam.java b/impl/src/main/java/com/sun/faces/context/ContextParam.java index e4cd1830f8..d921da4206 100644 --- a/impl/src/main/java/com/sun/faces/context/ContextParam.java +++ b/impl/src/main/java/com/sun/faces/context/ContextParam.java @@ -16,8 +16,6 @@ package com.sun.faces.context; -import jakarta.faces.push.PushContext; - /** * The enumeration of all our context-param entries. */ @@ -30,11 +28,7 @@ public enum ContextParam { /** * Send the "X-Powered-By" header. */ - SendPoweredByHeader("com.sun.faces.sendPoweredByHeader", Boolean.class, false), - /** - * The websocket endpoint port (default 0 means the code will take the port from the request) - */ - WebsocketEndpointPort(PushContext.WEBSOCKET_ENDPOINT_PORT_PARAM_NAME, Integer.class, 0); + SendPoweredByHeader("com.sun.faces.sendPoweredByHeader", Boolean.class, false); /** * Stores the default value. diff --git a/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java b/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java index 227335764a..86ce3ba5d7 100644 --- a/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java +++ b/impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java @@ -53,6 +53,7 @@ import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; +import jakarta.faces.annotation.FacesConfig; import jakarta.faces.application.ProjectStage; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -568,7 +569,7 @@ public String encodeWebsocketURL(String url) { Util.notNull("url", url); HttpServletRequest request = (HttpServletRequest) getRequest(); - int port = ContextParamUtils.getValue(servletContext, ContextParam.WebsocketEndpointPort, Integer.class); + int port = FacesConfig.ContextParam.WEBSOCKET_ENDPOINT_PORT.getValue(FacesContext.getCurrentInstance()); try { final URL requestURL = new URL(request.getRequestURL().toString()); diff --git a/impl/src/main/java/com/sun/faces/context/FacesContextFactoryImpl.java b/impl/src/main/java/com/sun/faces/context/FacesContextFactoryImpl.java index 2d65ad7b42..7bb42ed560 100644 --- a/impl/src/main/java/com/sun/faces/context/FacesContextFactoryImpl.java +++ b/impl/src/main/java/com/sun/faces/context/FacesContextFactoryImpl.java @@ -16,11 +16,8 @@ package com.sun.faces.context; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.AlwaysPerformValidationWhenRequiredTrue; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableValidateWholeBean; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.ForceAlwaysWriteFlashCookie; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.PartialStateSaving; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.ViewRootPhaseListenerQueuesException; import java.util.Map; @@ -30,7 +27,7 @@ import jakarta.faces.FacesException; import jakarta.faces.FactoryFinder; -import jakarta.faces.component.UIInput; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.context.ExceptionHandlerFactory; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.ExternalContextFactory; @@ -81,15 +78,11 @@ private void savePerRequestInitParams(FacesContext context, WebConfiguration web ExternalContext extContext = context.getExternalContext(); Map appMap = extContext.getApplicationMap(); Map attrs = context.getAttributes(); - attrs.put(UIInput.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, - webConfig.isOptionEnabled(AlwaysPerformValidationWhenRequiredTrue) ? Boolean.TRUE : Boolean.FALSE); + attrs.put(ContextParam.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE.getName(), ContextParam.ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE.getValue(context)); attrs.put(PartialStateSaving, webConfig.isOptionEnabled(PartialStateSaving) ? Boolean.TRUE : Boolean.FALSE); attrs.put(ForceAlwaysWriteFlashCookie, webConfig.isOptionEnabled(ForceAlwaysWriteFlashCookie) ? Boolean.TRUE : Boolean.FALSE); - // We must use getQualifiedName here because the consumer is in faces-api - // and thus cannot import the enum. - attrs.put(ViewRootPhaseListenerQueuesException.getQualifiedName(), - webConfig.isOptionEnabled(ViewRootPhaseListenerQueuesException) ? Boolean.TRUE : Boolean.FALSE); - attrs.put(EnableValidateWholeBean.getQualifiedName(), webConfig.isOptionEnabled(EnableValidateWholeBean) ? Boolean.TRUE : Boolean.FALSE); + attrs.put(ContextParam.VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS.getName(), ContextParam.VIEWROOT_PHASE_LISTENER_QUEUES_EXCEPTIONS.getValue(context)); + attrs.put(ContextParam.ENABLE_VALIDATE_WHOLE_BEAN.getName(), ContextParam.ENABLE_VALIDATE_WHOLE_BEAN.getValue(context)); String facesConfigVersion = String.valueOf(appMap.get(RIConstants.FACES_CONFIG_VERSION)); attrs.put(RIConstants.FACES_CONFIG_VERSION, facesConfigVersion); diff --git a/impl/src/main/java/com/sun/faces/el/ELUtils.java b/impl/src/main/java/com/sun/faces/el/ELUtils.java index aa5d7ba303..e8f3ed2039 100644 --- a/impl/src/main/java/com/sun/faces/el/ELUtils.java +++ b/impl/src/main/java/com/sun/faces/el/ELUtils.java @@ -17,7 +17,6 @@ package com.sun.faces.el; import static com.sun.faces.RIConstants.EMPTY_CLASS_ARGS; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.InterpretEmptyStringSubmittedValuesAsNull; import static com.sun.faces.util.MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID; import static com.sun.faces.util.MessageUtils.getExceptionMessageString; import static com.sun.faces.util.ReflectionUtils.lookupMethod; @@ -26,7 +25,6 @@ import static java.lang.Boolean.FALSE; import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.context.flash.FlashELResolver; import com.sun.faces.util.Cache; import com.sun.faces.util.LRUCache; @@ -40,6 +38,7 @@ import jakarta.el.MapELResolver; import jakarta.el.ResourceBundleELResolver; import jakarta.el.ValueExpression; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; import java.lang.reflect.Method; @@ -158,7 +157,7 @@ public static void buildFacesResolver(FacesCompositeELResolver composite, Applic addELResolvers(composite, associate.getELResolversFromFacesConfig()); composite.add(associate.getApplicationELResolvers()); - if (WebConfiguration.getInstance().isOptionEnabled(InterpretEmptyStringSubmittedValuesAsNull)) { + if (ContextParam.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL.isSet(FacesContext.getCurrentInstance())) { composite.addPropertyELResolver(EMPTY_STRING_TO_NULL_RESOLVER); } diff --git a/impl/src/main/java/com/sun/faces/facelets/impl/FaceletCacheFactoryImpl.java b/impl/src/main/java/com/sun/faces/facelets/impl/FaceletCacheFactoryImpl.java index ceac74dacc..5475257c4a 100644 --- a/impl/src/main/java/com/sun/faces/facelets/impl/FaceletCacheFactoryImpl.java +++ b/impl/src/main/java/com/sun/faces/facelets/impl/FaceletCacheFactoryImpl.java @@ -16,8 +16,8 @@ package com.sun.faces.facelets.impl; -import com.sun.faces.config.WebConfiguration; - +import jakarta.faces.annotation.FacesConfig.ContextParam; +import jakarta.faces.context.FacesContext; import jakarta.faces.view.facelets.FaceletCache; import jakarta.faces.view.facelets.FaceletCacheFactory; @@ -32,9 +32,7 @@ public FaceletCacheFactoryImpl() { @Override public FaceletCache getFaceletCache() { - WebConfiguration webConfig = WebConfiguration.getInstance(); - String refreshPeriod = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsDefaultRefreshPeriod); - long period = Long.parseLong(refreshPeriod) * 1000; + int period = ContextParam.FACELETS_REFRESH_PERIOD.getValue(FacesContext.getCurrentInstance()); FaceletCache result = new DefaultFaceletCache(period); return result; diff --git a/impl/src/main/java/com/sun/faces/facelets/tag/ui/CompositionHandler.java b/impl/src/main/java/com/sun/faces/facelets/tag/ui/CompositionHandler.java index cf004f77a4..09a6f73323 100644 --- a/impl/src/main/java/com/sun/faces/facelets/tag/ui/CompositionHandler.java +++ b/impl/src/main/java/com/sun/faces/facelets/tag/ui/CompositionHandler.java @@ -32,6 +32,7 @@ import com.sun.faces.util.FacesLogger; import jakarta.el.VariableMapper; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; import jakarta.faces.view.facelets.FaceletContext; diff --git a/impl/src/main/java/com/sun/faces/facelets/tag/ui/DecorateHandler.java b/impl/src/main/java/com/sun/faces/facelets/tag/ui/DecorateHandler.java index 7af0fbf184..41996a3ea0 100644 --- a/impl/src/main/java/com/sun/faces/facelets/tag/ui/DecorateHandler.java +++ b/impl/src/main/java/com/sun/faces/facelets/tag/ui/DecorateHandler.java @@ -32,6 +32,7 @@ import com.sun.faces.util.FacesLogger; import jakarta.el.VariableMapper; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.component.UIComponent; import jakarta.faces.view.facelets.FaceletContext; import jakarta.faces.view.facelets.TagAttribute; diff --git a/impl/src/main/java/com/sun/faces/facelets/tag/ui/IncludeHandler.java b/impl/src/main/java/com/sun/faces/facelets/tag/ui/IncludeHandler.java index 0704901d5d..b7e1ea912a 100644 --- a/impl/src/main/java/com/sun/faces/facelets/tag/ui/IncludeHandler.java +++ b/impl/src/main/java/com/sun/faces/facelets/tag/ui/IncludeHandler.java @@ -25,6 +25,7 @@ import com.sun.faces.util.FacesLogger; import jakarta.el.VariableMapper; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.component.UIComponent; import jakarta.faces.view.facelets.FaceletContext; import jakarta.faces.view.facelets.TagAttribute; diff --git a/impl/src/main/java/com/sun/faces/lifecycle/ClientWindowFactoryImpl.java b/impl/src/main/java/com/sun/faces/lifecycle/ClientWindowFactoryImpl.java index 20d099e0f6..96954b56e3 100644 --- a/impl/src/main/java/com/sun/faces/lifecycle/ClientWindowFactoryImpl.java +++ b/impl/src/main/java/com/sun/faces/lifecycle/ClientWindowFactoryImpl.java @@ -16,10 +16,10 @@ package com.sun.faces.lifecycle; -import com.sun.faces.config.WebConfiguration; +import com.sun.faces.application.JavaFlowLoaderHelper; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.application.Application; -import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; import jakarta.faces.event.AbortProcessingException; import jakarta.faces.event.PostConstructApplicationEvent; @@ -31,7 +31,6 @@ public class ClientWindowFactoryImpl extends ClientWindowFactory { private boolean isClientWindowEnabled = false; - private WebConfiguration config = null; public ClientWindowFactoryImpl() { super(null); @@ -60,11 +59,8 @@ public void processEvent(SystemEvent event) throws AbortProcessingException { private void postConstructApplicationInitialization() { FacesContext context = FacesContext.getCurrentInstance(); - ExternalContext extContext = context.getExternalContext(); - config = WebConfiguration.getInstance(extContext); - String optionValue = config.getOptionValue(WebConfiguration.WebContextInitParameter.ClientWindowMode); - - isClientWindowEnabled = null != optionValue && "url".equals(optionValue); + String optionValue = ContextParam.CLIENT_WINDOW_MODE.getValue(context); + isClientWindowEnabled = "url".equals(optionValue) || JavaFlowLoaderHelper.isClientWindowModeForciblyEnabled(context); } @Override diff --git a/impl/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java b/impl/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java index e77efe6aa3..9f885f27f4 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java +++ b/impl/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java @@ -41,7 +41,6 @@ import com.sun.faces.RIConstants; import com.sun.faces.application.ApplicationAssociate; -import com.sun.faces.config.WebConfiguration; import com.sun.faces.el.ELUtils; import com.sun.faces.facelets.util.DevTools; import com.sun.faces.util.FacesLogger; @@ -1293,8 +1292,7 @@ public static String getImageSource(FacesContext context, UIComponent component, if (value == null || value.length() == 0) { return ""; } - WebConfiguration webConfig = WebConfiguration.getInstance(); - if (value.startsWith(webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.WebAppContractsDirectory))) { + if (ApplicationAssociate.getInstance(context).getResourceManager().isContractsResource(value)) { if (context.isProjectStage(ProjectStage.Development)) { String msg = "Illegal path, direct contract references are not allowed: " + value; context.addMessage(component.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg)); diff --git a/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java b/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java index 8125c8de7d..0737a1e82b 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java +++ b/impl/src/main/java/com/sun/faces/renderkit/ResponseStateManagerImpl.java @@ -20,13 +20,11 @@ import java.io.IOException; -import com.sun.faces.config.WebConfiguration; -import com.sun.faces.config.WebConfiguration.WebContextInitParameter; import com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter; import com.sun.faces.util.RequestStateManager; import jakarta.faces.FacesException; -import jakarta.faces.application.StateManager.StateSavingMethod; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.context.FacesContext; import jakarta.faces.render.ResponseStateManager; @@ -39,9 +37,8 @@ public class ResponseStateManagerImpl extends ResponseStateManager { private StateHelper helper; public ResponseStateManagerImpl() { - WebConfiguration webConfig = WebConfiguration.getInstance(); - String stateMode = webConfig.getOptionValue(WebContextInitParameter.StateSavingMethod); - helper = StateSavingMethod.CLIENT.name().equalsIgnoreCase(stateMode) ? new ClientSideStateHelper() : new ServerSideStateHelper(); + FacesContext context = FacesContext.getCurrentInstance(); + helper = ContextParam.STATE_SAVING_METHOD.isDefault(context) ? new ClientSideStateHelper() : new ServerSideStateHelper(); } // --------------------------------------- Methods from ResponseStateManager diff --git a/impl/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java b/impl/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java index 5c96f298aa..d788008752 100644 --- a/impl/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java +++ b/impl/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java @@ -19,7 +19,6 @@ import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.AutoCompleteOffOnViewState; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.EnableViewStateIdRendering; import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.GenerateUniqueServerStateIds; -import static com.sun.faces.config.WebConfiguration.BooleanWebContextInitParameter.SerializeServerState; import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.NumberOfLogicalViews; import static com.sun.faces.config.WebConfiguration.WebContextInitParameter.NumberOfViews; import static com.sun.faces.context.SessionMap.getMutex; @@ -51,6 +50,7 @@ import com.sun.faces.util.Util; import jakarta.faces.FacesException; +import jakarta.faces.annotation.FacesConfig.ContextParam; import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -326,7 +326,7 @@ protected Integer getIntegerConfigValue(WebContextInitParameter param) { * @return If option SerializeServerState is true, serialize and return the state, otherwise, return state unchanged. */ protected Object handleSaveState(Object state) { - if (!webConfig.isOptionEnabled(SerializeServerState)) { + if (!ContextParam.SERIALIZE_SERVER_STATE.isSet(FacesContext.getCurrentInstance())) { return state; } @@ -357,7 +357,7 @@ protected Object handleSaveState(Object state) { * de-serialize the state prior to returning it, otherwise return state as is. */ protected Object handleRestoreState(Object state) { - if (!webConfig.isOptionEnabled(SerializeServerState)) { + if (!ContextParam.SERIALIZE_SERVER_STATE.isSet(FacesContext.getCurrentInstance())) { return state; } diff --git a/impl/src/test/java/com/sun/faces/mock/MockBeanManager.java b/impl/src/test/java/com/sun/faces/mock/MockBeanManager.java index 7fbc3e1ad1..73e6d796ee 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockBeanManager.java +++ b/impl/src/test/java/com/sun/faces/mock/MockBeanManager.java @@ -161,12 +161,12 @@ public boolean isPassivatingScope(Class annotationType) { @Override public Set getInterceptorBindingDefinition(Class bindingType) { - return null; + return emptySet(); } @Override public Set getStereotypeDefinition(Class stereotype) { - return null; + return emptySet(); } @Override diff --git a/impl/src/test/java/com/sun/faces/mock/MockFacesContext.java b/impl/src/test/java/com/sun/faces/mock/MockFacesContext.java index 8d1893d42a..d4f0e3318e 100644 --- a/impl/src/test/java/com/sun/faces/mock/MockFacesContext.java +++ b/impl/src/test/java/com/sun/faces/mock/MockFacesContext.java @@ -24,6 +24,7 @@ import java.util.Locale; import java.util.Map; +import com.sun.faces.RIConstants; import com.sun.faces.context.ExceptionHandlerFactoryImpl; import com.sun.faces.renderkit.RenderKitUtils; @@ -62,6 +63,7 @@ public class MockFacesContext extends FacesContext { public MockFacesContext() { super(); setCurrentInstance(this); + getAttributes().put(RIConstants.CDI_BEAN_MANAGER, new MockBeanManager()); } public MockFacesContext(ExternalContext externalContext) {