You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by me...@apache.org on 2022/04/01 12:38:23 UTC
[myfaces] branch master updated: MYFACES-4431 - 4.x (#241)
This is an automated email from the ASF dual-hosted git repository.
melloware pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/master by this push:
new 5ffe144 MYFACES-4431 - 4.x (#241)
5ffe144 is described below
commit 5ffe144f823053190ca1901e3011a25087aef7a5
Author: Melloware <me...@gmail.com>
AuthorDate: Fri Apr 1 08:38:18 2022 -0400
MYFACES-4431 - 4.x (#241)
---
.../myfaces/application/NavigationHandlerImpl.java | 4 +
.../config/annotation/AnnotationConfigurator.java | 784 +++----
.../apache/myfaces/config/element/Behavior.java | 66 +-
.../apache/myfaces/config/element/Component.java | 80 +-
.../apache/myfaces/config/element/Converter.java | 80 +-
.../apache/myfaces/config/element/FacesConfig.java | 236 +--
.../myfaces/config/element/FacesConfigData.java | 666 +++---
.../config/impl/FacesConfigDispenserImpl.java | 2212 ++++++++++----------
.../config/impl/FacesConfigUnmarshallerImpl.java | 1530 +++++++-------
.../myfaces/config/impl/element/ComponentImpl.java | 212 +-
.../config/impl/element/FacesConfigImpl.java | 1088 +++++-----
11 files changed, 3481 insertions(+), 3477 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
index 5abba82..b759cb0 100755
--- a/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
@@ -934,6 +934,10 @@ public class NavigationHandlerImpl extends ConfigurableNavigationHandler
Set<NavigationCase> casesSet = null;
NavigationCase navigationCase = null;
+ if (flowNavigationStructure == null)
+ {
+ return navigationCase;
+ }
if (viewId != null)
{
casesSet = flowNavigationStructure.getNavigationCases().get(viewId);
diff --git a/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java b/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
index 0647416..0f70874 100644
--- a/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
@@ -1,392 +1,392 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.annotation;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import jakarta.faces.FacesException;
-import jakarta.faces.component.FacesComponent;
-import jakarta.faces.component.behavior.FacesBehavior;
-import jakarta.faces.context.ExternalContext;
-import jakarta.faces.convert.FacesConverter;
-import jakarta.faces.event.ComponentSystemEvent;
-import jakarta.faces.event.NamedEvent;
-import jakarta.faces.render.FacesBehaviorRenderer;
-import jakarta.faces.render.FacesRenderer;
-import jakarta.faces.render.RenderKitFactory;
-import jakarta.faces.validator.FacesValidator;
-import jakarta.faces.view.facelets.FaceletsResourceResolver;
-
-import org.apache.myfaces.config.impl.element.ApplicationImpl;
-import org.apache.myfaces.config.impl.element.BehaviorImpl;
-import org.apache.myfaces.config.impl.element.ComponentImpl;
-import org.apache.myfaces.config.impl.element.ComponentTagDeclarationImpl;
-import org.apache.myfaces.config.impl.element.ConverterImpl;
-import org.apache.myfaces.config.impl.element.FacesConfigImpl;
-import org.apache.myfaces.spi.AnnotationProvider;
-import org.apache.myfaces.spi.AnnotationProviderFactory;
-import org.apache.myfaces.util.lang.StringUtils;
-
-/**
- * Configure all annotations that needs to be defined at startup.
- *
- * <ul>
- * <li>{@link jakarta.faces.component.FacesComponent}</li>
- * <li>{@link jakarta.faces.convert.FacesConverter}</li>
- * <li>{@link jakarta.faces.validator.FacesValidator}</li>
- * <li>{@link jakarta.faces.render.FacesRenderer}</li>
- * <li>{@link jakarta.faces.render.FacesBehaviorRenderer}</li>
- * </ul>
- * <p>
- * Some parts copied from org.apache.shale.tiger.view.faces.LifecycleListener2
- * </p>
- *
- * @since 2.0
- * @author Leonardo Uribe (latest modification by $Author$)
- * @version $Revision$ $Date$
- */
-public class AnnotationConfigurator
-{
- private static final Logger log = Logger.getLogger(AnnotationConfigurator.class.getName());
-
- public AnnotationConfigurator()
- {
- }
-
- public FacesConfigImpl createFacesConfig(ExternalContext externalcontext, boolean metadataComplete)
- {
- if (!metadataComplete)
- {
- AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(externalcontext).
- getAnnotationProvider(externalcontext);
- Map<Class<? extends Annotation>, Set<Class<?>>> map = provider.getAnnotatedClasses(externalcontext);
- return createFacesConfig(map);
- }
- return null;
- }
-
- /**
- * TODO: Implement strategy pattern over this method.
- *
- * @param map
- * @return
- */
- protected FacesConfigImpl createFacesConfig(Map<Class<? extends Annotation>, Set<Class<?>>> map)
- {
- FacesConfigImpl facesConfig = new FacesConfigImpl();
-
- Set<Class<?>> classes = map.get(FacesComponent.class);
-
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesComponent comp = (FacesComponent) clazz.getAnnotation(FacesComponent.class);
- if (comp != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addComponent(" + comp.value() + ',' + clazz.getName() + ')');
- }
-
- String value = comp.value();
- if (StringUtils.isEmpty(value))
- {
- String simpleName = clazz.getSimpleName();
- value = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
- }
- facesConfig.addComponent(new ComponentImpl(value, clazz.getName()));
-
- if (comp.createTag())
- {
- String tagName = comp.tagName();
- if (StringUtils.isEmpty(tagName))
- {
- tagName = clazz.getSimpleName();
- tagName = Character.toLowerCase(tagName.charAt(0)) + tagName.substring(1);
- }
-
- facesConfig.addComponentTagDeclaration(value,
- new ComponentTagDeclarationImpl(value, comp.namespace(), tagName));
- }
- }
- }
- }
-
- classes = map.get(FacesConverter.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesConverter conv = (FacesConverter) clazz.getAnnotation(FacesConverter.class);
- if (conv != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addConverter(" + conv.value() + ',' + clazz.getName() + ')');
- }
-
- //If there is a previous entry on Application Configuration Resources,
- //the entry there takes precedence
- boolean hasForClass = !Object.class.equals(conv.forClass());
- boolean hasValue = conv.value().length() > 0;
- if (hasForClass || hasValue)
- {
- ConverterImpl converter = new ConverterImpl();
- if (hasForClass)
- {
- converter.setForClass(conv.forClass().getName());
- }
- if (hasValue)
- {
- converter.setConverterId(conv.value());
- }
- converter.setConverterClass(clazz.getName());
- facesConfig.addConverter(converter);
- }
- else
- {
- throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation "
- + "@FacesConverter on class: " + clazz.getName());
- }
- }
- }
- }
-
- classes = map.get(FacesValidator.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesValidator val = (FacesValidator) clazz.getAnnotation(FacesValidator.class);
- if (val != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addValidator(" + val.value() + ',' + clazz.getName() + ')');
- }
-
- String value = val.value();
- if (value == null || value.isEmpty())
- {
- String simpleName = clazz.getSimpleName();
- value = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
- }
- facesConfig.addValidator(value, clazz.getName());
- if (val.isDefault())
- {
- ApplicationImpl app = null;
- if (facesConfig.getApplications().isEmpty())
- {
- app = new ApplicationImpl();
- }
- else
- {
- app = (ApplicationImpl) facesConfig.getApplications().get(0);
- }
- app.addDefaultValidatorId(value);
- }
- }
- }
- }
-
- classes = map.get(FacesRenderer.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesRenderer rend = (FacesRenderer) clazz.getAnnotation(FacesRenderer.class);
- if (rend != null)
- {
- String renderKitId = rend.renderKitId();
- if (renderKitId == null)
- {
- renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addRenderer(" + renderKitId + ", "
- + rend.componentFamily() + ", " + rend.rendererType()
- + ", " + clazz.getName() + ')');
- }
-
- org.apache.myfaces.config.impl.element.RenderKitImpl renderKit =
- (org.apache.myfaces.config.impl.element.RenderKitImpl)
- facesConfig.getRenderKit(renderKitId);
- if (renderKit == null)
- {
- renderKit = new org.apache.myfaces.config.impl.element.RenderKitImpl();
- renderKit.setId(renderKitId);
- facesConfig.addRenderKit(renderKit);
- }
-
- org.apache.myfaces.config.impl.element.RendererImpl renderer =
- new org.apache.myfaces.config.impl.element.RendererImpl();
- renderer.setComponentFamily(rend.componentFamily());
- renderer.setRendererClass(clazz.getName());
- renderer.setRendererType(rend.rendererType());
- renderKit.addRenderer(renderer);
- }
- }
- }
-
- classes = map.get(NamedEvent.class);
- if (classes != null && !classes.isEmpty())
- {
- handleNamedEvent(facesConfig, classes);
- }
-
- classes = map.get(FacesBehavior.class);
- if (classes != null && !classes.isEmpty())
- {
- handleFacesBehavior(facesConfig, classes);
- }
-
- classes = map.get(FacesBehaviorRenderer.class);
- if (classes != null && !classes.isEmpty())
- {
- handleFacesBehaviorRenderer(facesConfig, classes);
- }
-
- classes = map.get(FaceletsResourceResolver.class);
- if (classes != null && !classes.isEmpty())
- {
- handleFaceletsResourceResolver(facesConfig, classes);
- }
-
- return facesConfig;
- }
-
- private void handleNamedEvent(FacesConfigImpl facesConfig, Set<Class<?>> classes)
- {
- for (Class<?> clazz : classes)
- {
- NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation(NamedEvent.class);
-
- if (namedEvent != null)
- {
- // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
- if (!ComponentSystemEvent.class.isAssignableFrom(clazz))
- {
- // Just log this. We'll catch it later in the runtime.
- if (log.isLoggable(Level.WARNING))
- {
- log.warning(clazz.getName() + " is annotated with @jakarta.faces.event.NamedEvent, but does "
- + "not extend jakarta.faces.event.ComponentSystemEvent");
- }
- }
- // Have to register @NamedEvent annotations with the NamedEventManager class since
- // we need to get access to this info later and can't from the dispenser (it's not a
- // singleton).
- org.apache.myfaces.config.impl.element.NamedEventImpl namedEventConfig =
- new org.apache.myfaces.config.impl.element.NamedEventImpl();
- namedEventConfig.setEventClass(clazz.getName());
- namedEventConfig.setShortName(namedEvent.shortName());
- facesConfig.addNamedEvent(namedEventConfig);
- }
- }
- }
-
- private void handleFacesBehavior(FacesConfigImpl facesConfig, Set<Class<?>> classes)
- {
- for (Class<?> clazz : classes)
- {
- FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation(FacesBehavior.class);
-
- if (facesBehavior != null)
- {
- // Can only apply @FacesBehavior to Behavior implementors.
- if (!jakarta.faces.component.behavior.Behavior.class.isAssignableFrom(clazz))
- {
- // Just log this. We'll catch it later in the runtime.
- if (log.isLoggable(Level.WARNING))
- {
- log.warning(clazz.getName()
- + " is annotated with @jakarta.faces.component.behavior.FacesBehavior, "
- + "but does not implement jakarta.faces.component.behavior.Behavior");
- }
- }
-
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ')');
- }
-
- BehaviorImpl behavior = new BehaviorImpl();
- behavior.setBehaviorId(facesBehavior.value());
- behavior.setBehaviorClass(clazz.getName());
- facesConfig.addBehavior(behavior);
- }
-
- }
- }
-
- private void handleFacesBehaviorRenderer(FacesConfigImpl facesConfig, Set<Class<?>> classes)
- {
- for (Class<?> clazz : classes)
- {
- FacesBehaviorRenderer facesBehaviorRenderer
- = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
-
- if (facesBehaviorRenderer != null)
- {
- String renderKitId = facesBehaviorRenderer.renderKitId();
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addClientBehaviorRenderer(" + renderKitId + ", "
- + facesBehaviorRenderer.rendererType() + ", "
- + clazz.getName() + ')');
- }
-
- org.apache.myfaces.config.impl.element.RenderKitImpl renderKit =
- (org.apache.myfaces.config.impl.element.RenderKitImpl)
- facesConfig.getRenderKit(renderKitId);
- if (renderKit == null)
- {
- renderKit = new org.apache.myfaces.config.impl.element.RenderKitImpl();
- renderKit.setId(renderKitId);
- facesConfig.addRenderKit(renderKit);
- }
-
- org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl cbr =
- new org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl();
- cbr.setRendererType(facesBehaviorRenderer.rendererType());
- cbr.setRendererClass(clazz.getName());
- renderKit.addClientBehaviorRenderer(cbr);
- }
- }
- }
-
- private void handleFaceletsResourceResolver(FacesConfigImpl facesConfig, Set<Class<?>> classes)
- {
- for (Class<?> clazz : classes)
- {
- FaceletsResourceResolver faceletsResourceResolver =
- (FaceletsResourceResolver) clazz.getAnnotation(FaceletsResourceResolver.class);
- if (faceletsResourceResolver != null)
- {
- facesConfig.addResourceResolver(clazz.getName());
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.annotation;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import jakarta.faces.FacesException;
+import jakarta.faces.component.FacesComponent;
+import jakarta.faces.component.behavior.FacesBehavior;
+import jakarta.faces.context.ExternalContext;
+import jakarta.faces.convert.FacesConverter;
+import jakarta.faces.event.ComponentSystemEvent;
+import jakarta.faces.event.NamedEvent;
+import jakarta.faces.render.FacesBehaviorRenderer;
+import jakarta.faces.render.FacesRenderer;
+import jakarta.faces.render.RenderKitFactory;
+import jakarta.faces.validator.FacesValidator;
+import jakarta.faces.view.facelets.FaceletsResourceResolver;
+
+import org.apache.myfaces.config.impl.element.ApplicationImpl;
+import org.apache.myfaces.config.impl.element.BehaviorImpl;
+import org.apache.myfaces.config.impl.element.ComponentImpl;
+import org.apache.myfaces.config.impl.element.ComponentTagDeclarationImpl;
+import org.apache.myfaces.config.impl.element.ConverterImpl;
+import org.apache.myfaces.config.impl.element.FacesConfigImpl;
+import org.apache.myfaces.spi.AnnotationProvider;
+import org.apache.myfaces.spi.AnnotationProviderFactory;
+import org.apache.myfaces.util.lang.StringUtils;
+
+/**
+ * Configure all annotations that needs to be defined at startup.
+ *
+ * <ul>
+ * <li>{@link jakarta.faces.component.FacesComponent}</li>
+ * <li>{@link jakarta.faces.convert.FacesConverter}</li>
+ * <li>{@link jakarta.faces.validator.FacesValidator}</li>
+ * <li>{@link jakarta.faces.render.FacesRenderer}</li>
+ * <li>{@link jakarta.faces.render.FacesBehaviorRenderer}</li>
+ * </ul>
+ * <p>
+ * Some parts copied from org.apache.shale.tiger.view.faces.LifecycleListener2
+ * </p>
+ *
+ * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class AnnotationConfigurator
+{
+ private static final Logger log = Logger.getLogger(AnnotationConfigurator.class.getName());
+
+ public AnnotationConfigurator()
+ {
+ }
+
+ public FacesConfigImpl createFacesConfig(ExternalContext externalcontext, boolean metadataComplete)
+ {
+ if (!metadataComplete)
+ {
+ AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(externalcontext).
+ getAnnotationProvider(externalcontext);
+ Map<Class<? extends Annotation>, Set<Class<?>>> map = provider.getAnnotatedClasses(externalcontext);
+ return createFacesConfig(map);
+ }
+ return null;
+ }
+
+ /**
+ * TODO: Implement strategy pattern over this method.
+ *
+ * @param map
+ * @return
+ */
+ protected FacesConfigImpl createFacesConfig(Map<Class<? extends Annotation>, Set<Class<?>>> map)
+ {
+ FacesConfigImpl facesConfig = new FacesConfigImpl();
+
+ Set<Class<?>> classes = map.get(FacesComponent.class);
+
+ if (classes != null && !classes.isEmpty())
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesComponent comp = (FacesComponent) clazz.getAnnotation(FacesComponent.class);
+ if (comp != null)
+ {
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addComponent(" + comp.value() + ',' + clazz.getName() + ')');
+ }
+
+ String value = comp.value();
+ if (StringUtils.isEmpty(value))
+ {
+ String simpleName = clazz.getSimpleName();
+ value = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
+ }
+ facesConfig.addComponent(new ComponentImpl(value, clazz.getName()));
+
+ if (comp.createTag())
+ {
+ String tagName = comp.tagName();
+ if (StringUtils.isEmpty(tagName))
+ {
+ tagName = clazz.getSimpleName();
+ tagName = Character.toLowerCase(tagName.charAt(0)) + tagName.substring(1);
+ }
+
+ facesConfig.addComponentTagDeclaration(value,
+ new ComponentTagDeclarationImpl(value, comp.namespace(), tagName));
+ }
+ }
+ }
+ }
+
+ classes = map.get(FacesConverter.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesConverter conv = (FacesConverter) clazz.getAnnotation(FacesConverter.class);
+ if (conv != null)
+ {
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addConverter(" + conv.value() + ',' + clazz.getName() + ')');
+ }
+
+ //If there is a previous entry on Application Configuration Resources,
+ //the entry there takes precedence
+ boolean hasForClass = !Object.class.equals(conv.forClass());
+ boolean hasValue = conv.value().length() > 0;
+ if (hasForClass || hasValue)
+ {
+ ConverterImpl converter = new ConverterImpl();
+ if (hasForClass)
+ {
+ converter.setForClass(conv.forClass().getName());
+ }
+ if (hasValue)
+ {
+ converter.setConverterId(conv.value());
+ }
+ converter.setConverterClass(clazz.getName());
+ facesConfig.addConverter(converter);
+ }
+ else
+ {
+ throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation "
+ + "@FacesConverter on class: " + clazz.getName());
+ }
+ }
+ }
+ }
+
+ classes = map.get(FacesValidator.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesValidator val = (FacesValidator) clazz.getAnnotation(FacesValidator.class);
+ if (val != null)
+ {
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addValidator(" + val.value() + ',' + clazz.getName() + ')');
+ }
+
+ String value = val.value();
+ if (value == null || value.isEmpty())
+ {
+ String simpleName = clazz.getSimpleName();
+ value = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
+ }
+ facesConfig.addValidator(value, clazz.getName());
+ if (val.isDefault())
+ {
+ ApplicationImpl app = null;
+ if (facesConfig.getApplications().isEmpty())
+ {
+ app = new ApplicationImpl();
+ }
+ else
+ {
+ app = (ApplicationImpl) facesConfig.getApplications().get(0);
+ }
+ app.addDefaultValidatorId(value);
+ }
+ }
+ }
+ }
+
+ classes = map.get(FacesRenderer.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesRenderer rend = (FacesRenderer) clazz.getAnnotation(FacesRenderer.class);
+ if (rend != null)
+ {
+ String renderKitId = rend.renderKitId();
+ if (renderKitId == null)
+ {
+ renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addRenderer(" + renderKitId + ", "
+ + rend.componentFamily() + ", " + rend.rendererType()
+ + ", " + clazz.getName() + ')');
+ }
+
+ org.apache.myfaces.config.impl.element.RenderKitImpl renderKit =
+ (org.apache.myfaces.config.impl.element.RenderKitImpl)
+ facesConfig.getRenderKit(renderKitId);
+ if (renderKit == null)
+ {
+ renderKit = new org.apache.myfaces.config.impl.element.RenderKitImpl();
+ renderKit.setId(renderKitId);
+ facesConfig.addRenderKit(renderKit);
+ }
+
+ org.apache.myfaces.config.impl.element.RendererImpl renderer =
+ new org.apache.myfaces.config.impl.element.RendererImpl();
+ renderer.setComponentFamily(rend.componentFamily());
+ renderer.setRendererClass(clazz.getName());
+ renderer.setRendererType(rend.rendererType());
+ renderKit.addRenderer(renderer);
+ }
+ }
+ }
+
+ classes = map.get(NamedEvent.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ handleNamedEvent(facesConfig, classes);
+ }
+
+ classes = map.get(FacesBehavior.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ handleFacesBehavior(facesConfig, classes);
+ }
+
+ classes = map.get(FacesBehaviorRenderer.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ handleFacesBehaviorRenderer(facesConfig, classes);
+ }
+
+ classes = map.get(FaceletsResourceResolver.class);
+ if (classes != null && !classes.isEmpty())
+ {
+ handleFaceletsResourceResolver(facesConfig, classes);
+ }
+
+ return facesConfig;
+ }
+
+ private void handleNamedEvent(FacesConfigImpl facesConfig, Set<Class<?>> classes)
+ {
+ for (Class<?> clazz : classes)
+ {
+ NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation(NamedEvent.class);
+
+ if (namedEvent != null)
+ {
+ // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
+ if (!ComponentSystemEvent.class.isAssignableFrom(clazz))
+ {
+ // Just log this. We'll catch it later in the runtime.
+ if (log.isLoggable(Level.WARNING))
+ {
+ log.warning(clazz.getName() + " is annotated with @jakarta.faces.event.NamedEvent, but does "
+ + "not extend jakarta.faces.event.ComponentSystemEvent");
+ }
+ }
+ // Have to register @NamedEvent annotations with the NamedEventManager class since
+ // we need to get access to this info later and can't from the dispenser (it's not a
+ // singleton).
+ org.apache.myfaces.config.impl.element.NamedEventImpl namedEventConfig =
+ new org.apache.myfaces.config.impl.element.NamedEventImpl();
+ namedEventConfig.setEventClass(clazz.getName());
+ namedEventConfig.setShortName(namedEvent.shortName());
+ facesConfig.addNamedEvent(namedEventConfig);
+ }
+ }
+ }
+
+ private void handleFacesBehavior(FacesConfigImpl facesConfig, Set<Class<?>> classes)
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation(FacesBehavior.class);
+
+ if (facesBehavior != null)
+ {
+ // Can only apply @FacesBehavior to Behavior implementors.
+ if (!jakarta.faces.component.behavior.Behavior.class.isAssignableFrom(clazz))
+ {
+ // Just log this. We'll catch it later in the runtime.
+ if (log.isLoggable(Level.WARNING))
+ {
+ log.warning(clazz.getName()
+ + " is annotated with @jakarta.faces.component.behavior.FacesBehavior, "
+ + "but does not implement jakarta.faces.component.behavior.Behavior");
+ }
+ }
+
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ')');
+ }
+
+ BehaviorImpl behavior = new BehaviorImpl();
+ behavior.setBehaviorId(facesBehavior.value());
+ behavior.setBehaviorClass(clazz.getName());
+ facesConfig.addBehavior(behavior);
+ }
+
+ }
+ }
+
+ private void handleFacesBehaviorRenderer(FacesConfigImpl facesConfig, Set<Class<?>> classes)
+ {
+ for (Class<?> clazz : classes)
+ {
+ FacesBehaviorRenderer facesBehaviorRenderer
+ = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
+
+ if (facesBehaviorRenderer != null)
+ {
+ String renderKitId = facesBehaviorRenderer.renderKitId();
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addClientBehaviorRenderer(" + renderKitId + ", "
+ + facesBehaviorRenderer.rendererType() + ", "
+ + clazz.getName() + ')');
+ }
+
+ org.apache.myfaces.config.impl.element.RenderKitImpl renderKit =
+ (org.apache.myfaces.config.impl.element.RenderKitImpl)
+ facesConfig.getRenderKit(renderKitId);
+ if (renderKit == null)
+ {
+ renderKit = new org.apache.myfaces.config.impl.element.RenderKitImpl();
+ renderKit.setId(renderKitId);
+ facesConfig.addRenderKit(renderKit);
+ }
+
+ org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl cbr =
+ new org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl();
+ cbr.setRendererType(facesBehaviorRenderer.rendererType());
+ cbr.setRendererClass(clazz.getName());
+ renderKit.addClientBehaviorRenderer(cbr);
+ }
+ }
+ }
+
+ private void handleFaceletsResourceResolver(FacesConfigImpl facesConfig, Set<Class<?>> classes)
+ {
+ for (Class<?> clazz : classes)
+ {
+ FaceletsResourceResolver faceletsResourceResolver =
+ (FaceletsResourceResolver) clazz.getAnnotation(FaceletsResourceResolver.class);
+ if (faceletsResourceResolver != null)
+ {
+ facesConfig.addResourceResolver(clazz.getName());
+ }
+ }
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java b/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java
index d60815d..af8ceaa 100644
--- a/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java
+++ b/impl/src/main/java/org/apache/myfaces/config/element/Behavior.java
@@ -1,33 +1,33 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.element;
-
-import java.io.Serializable;
-
-/**
- * Model for <behavior> config element.
- */
-
-public abstract class Behavior implements Serializable
-{
- public abstract String getBehaviorId();
-
- public abstract String getBehaviorClass();
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.element;
+
+import java.io.Serializable;
+
+/**
+ * Model for <behavior> config element.
+ */
+
+public abstract class Behavior implements Serializable
+{
+ public abstract String getBehaviorId();
+
+ public abstract String getBehaviorClass();
+
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/element/Component.java b/impl/src/main/java/org/apache/myfaces/config/element/Component.java
index 61eb246..89e3b9f 100644
--- a/impl/src/main/java/org/apache/myfaces/config/element/Component.java
+++ b/impl/src/main/java/org/apache/myfaces/config/element/Component.java
@@ -1,40 +1,40 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.element;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- *
- * @author Leonardo Uribe
- * @since 2.0.3
- */
-public abstract class Component implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- public abstract String getComponentType();
-
- public abstract String getComponentClass();
-
- public abstract List<? extends Property> getProperties();
-
- public abstract List<? extends Attribute> getAttributes();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.element;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Component implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ public abstract String getComponentType();
+
+ public abstract String getComponentClass();
+
+ public abstract List<? extends Property> getProperties();
+
+ public abstract List<? extends Attribute> getAttributes();
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/element/Converter.java b/impl/src/main/java/org/apache/myfaces/config/element/Converter.java
index ff1dc63..ae0e01f 100644
--- a/impl/src/main/java/org/apache/myfaces/config/element/Converter.java
+++ b/impl/src/main/java/org/apache/myfaces/config/element/Converter.java
@@ -1,40 +1,40 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.element;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- *
- * @author Leonardo Uribe
- * @since 2.0.3
- */
-public abstract class Converter implements Serializable
-{
- public abstract String getConverterId();
-
- public abstract String getForClass();
-
- public abstract String getConverterClass();
-
- public abstract List<? extends Property> getProperties();
-
- public abstract List<? extends Attribute> getAttributes();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.element;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class Converter implements Serializable
+{
+ public abstract String getConverterId();
+
+ public abstract String getForClass();
+
+ public abstract String getConverterClass();
+
+ public abstract List<? extends Property> getProperties();
+
+ public abstract List<? extends Attribute> getAttributes();
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java b/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
index 2dc7dc2..c4e6212 100644
--- a/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
+++ b/impl/src/main/java/org/apache/myfaces/config/element/FacesConfig.java
@@ -1,118 +1,118 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.element;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
-
-/**
- * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
- */
-public abstract class FacesConfig implements Serializable
-{
- public abstract List<Application> getApplications();
-
- public abstract List<Factory> getFactories();
-
- public abstract List<Component> getComponents();
-
- public abstract List<Converter> getConverters();
-
- public abstract List<NavigationRule> getNavigationRules();
-
- public abstract List<RenderKit> getRenderKits();
-
- public abstract List<String> getLifecyclePhaseListener();
-
- public abstract Map<String, String> getValidators();
-
- public abstract List<Behavior> getBehaviors ();
-
- public abstract List<NamedEvent> getNamedEvents ();
-
- public abstract RenderKit getRenderKit(String renderKitId);
-
- public abstract String getName();
-
- public abstract AbsoluteOrdering getAbsoluteOrdering();
-
- public abstract Ordering getOrdering();
-
- public abstract String getMetadataComplete();
-
- public abstract String getVersion ();
-
- /**
- *
- * @since 2.1.0
- */
- public List<FacesConfigExtension> getFacesConfigExtensions()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.2.0
- * @return
- */
- public List<FacesFlowDefinition> getFacesFlowDefinitions()
- {
- return Collections.emptyList();
- }
-
-
- /**
- * @since 2.2.0
- * @return
- */
- public List<String> getProtectedViewsUrlPatternList()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.2.0
- * @return
- */
- public Map<String, ComponentTagDeclaration> getComponentTagDeclarations()
- {
- return Collections.emptyMap();
- }
-
- /**
- * @since 2.2.0
- * @return
- */
- public List<String> getResourceResolversList()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.2.0
- * @return
- */
- public List<FaceletTagLibrary> getFaceletTagLibraryList()
- {
- return Collections.emptyList();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.element;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
+
+/**
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ */
+public abstract class FacesConfig implements Serializable
+{
+ public abstract List<Application> getApplications();
+
+ public abstract List<Factory> getFactories();
+
+ public abstract List<Component> getComponents();
+
+ public abstract List<Converter> getConverters();
+
+ public abstract List<NavigationRule> getNavigationRules();
+
+ public abstract List<RenderKit> getRenderKits();
+
+ public abstract List<String> getLifecyclePhaseListener();
+
+ public abstract Map<String, String> getValidators();
+
+ public abstract List<Behavior> getBehaviors ();
+
+ public abstract List<NamedEvent> getNamedEvents ();
+
+ public abstract RenderKit getRenderKit(String renderKitId);
+
+ public abstract String getName();
+
+ public abstract AbsoluteOrdering getAbsoluteOrdering();
+
+ public abstract Ordering getOrdering();
+
+ public abstract String getMetadataComplete();
+
+ public abstract String getVersion ();
+
+ /**
+ *
+ * @since 2.1.0
+ */
+ public List<FacesConfigExtension> getFacesConfigExtensions()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public List<FacesFlowDefinition> getFacesFlowDefinitions()
+ {
+ return Collections.emptyList();
+ }
+
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public List<String> getProtectedViewsUrlPatternList()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public Map<String, ComponentTagDeclaration> getComponentTagDeclarations()
+ {
+ return Collections.emptyMap();
+ }
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public List<String> getResourceResolversList()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public List<FaceletTagLibrary> getFaceletTagLibraryList()
+ {
+ return Collections.emptyList();
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java b/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
index ba62257..f54f602 100644
--- a/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
+++ b/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
@@ -1,333 +1,333 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.element;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
-
-
-
-/**
- *
- * @author Leonardo Uribe
- * @since 2.0.3
- */
-public abstract class FacesConfigData implements Serializable
-{
-
- /**
- *
- */
- private static final long serialVersionUID = -5278120443255410184L;
-
- /** @return Iterator over ApplicationFactory class names */
- public abstract Collection<String> getApplicationFactoryIterator();
-
- /** @return Iterator over ExceptionHandlerFactory class names */
- public abstract Collection<String> getExceptionHandlerFactoryIterator();
-
- /** @return Iterator over ExternalContextFactory class names */
- public abstract Collection<String> getExternalContextFactoryIterator();
-
- /** @return Iterator over FacesContextFactory class names */
- public abstract Collection<String> getFacesContextFactoryIterator();
-
- /** @return Iterator over LifecycleFactory class names */
- public abstract Collection<String> getLifecycleFactoryIterator();
-
- /** @return Iterator over ViewDeclarationLanguageFactory class names */
- public abstract Collection<String> getViewDeclarationLanguageFactoryIterator();
-
- /** @return Iterator over PartialViewContextFactory class names */
- public abstract Collection<String> getPartialViewContextFactoryIterator();
-
- /** @return Iterator over RenderKit factory class names */
- public abstract Collection<String> getRenderKitFactoryIterator();
-
- /** @return Iterator over TagHandlerDelegateFactory factory class names */
- public abstract Collection<String> getTagHandlerDelegateFactoryIterator();
-
- /** @return Iterator over VisitContextFactory factory class names */
- public abstract Collection<String> getVisitContextFactoryIterator();
-
- /**
- * @since 2.1.0
- * @return Iterator over FaceletCacheFactory factory class names
- */
- public Collection<String> getFaceletCacheFactoryIterator()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.2
- * @return
- */
- public Collection<String> getFlashFactoryIterator()
- {
- return Collections.emptyList();
- }
-
- public Collection<String> getClientWindowFactoryIterator()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.2
- * @return
- */
- public Collection<String> getFlowHandlerFactoryIterator()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.3
- * @return
- */
- public Collection<String> getSearchExpressionContextFactoryIterator()
- {
- return Collections.emptyList();
- }
-
- /** @return Iterator over ActionListener class names (in reverse order!) */
- public abstract Collection<String> getActionListenerIterator();
-
- /** @return the default render kit id */
- public abstract String getDefaultRenderKitId();
-
- /** @return Iterator over message bundle names (in reverse order!) */
- public abstract String getMessageBundle();
-
- /** @return Iterator over NavigationHandler class names */
- public abstract Collection<String> getNavigationHandlerIterator();
-
- /** @return Iterator over ViewHandler class names */
- public abstract Collection<String> getViewHandlerIterator();
-
- /** @return Iterator over StateManager class names*/
- public abstract Collection<String> getStateManagerIterator();
-
- /** @return Iterator over ResourceHandler class names*/
- public abstract Collection<String> getResourceHandlerIterator();
-
- /** @return Iterator over PropertyResolver class names */
- public abstract Collection<String> getPropertyResolverIterator();
-
- /** @return Iterator over VariableResolver class names */
- public abstract Collection<String> getVariableResolverIterator();
-
- /** @return the default locale name */
- public abstract String getDefaultLocale();
-
- /** @return Iterator over supported locale names */
- public abstract Collection<String> getSupportedLocalesIterator();
-
-
- /** @return Iterator over all defined component types */
- public abstract Collection<String> getComponentTypes();
-
- /** @return component class that belongs to the given component type */
- public abstract String getComponentClass(String componentType);
-
- public abstract Map<String, Component> getComponentsByType();
-
- /** @return Iterator over all defined converter ids */
- public abstract Collection<String> getConverterIds();
-
- /** @return Iterator over all classes with an associated converter */
- public abstract Collection<String> getConverterClasses();
-
- public abstract Map<String, String> getConverterClassesById();
-
- public abstract Map<String, String> getConverterClassesByClass();
-
- /** @return Iterator over the config classes for the converters */
- public abstract Collection<String> getConverterConfigurationByClassName();
-
- /** delivers a converter-configuration for one class-name */
- public abstract Converter getConverterConfiguration(String converterClassName);
-
- /** @return converter class that belongs to the given converter id */
- public abstract String getConverterClassById(String converterId);
-
- /** @return converter class that is associated with the given class name */
- public abstract String getConverterClassByClass(String className);
-
-
- /** @return Iterator over all defined validator ids */
- public abstract Collection<String> getValidatorIds();
-
- /** @return validator class name that belongs to the given validator id */
- public abstract String getValidatorClass(String validatorId);
-
- public abstract Map<String, String> getValidatorClassesById();
-
- /**
- * @return Iterator over {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
- */
- public abstract Collection<NavigationRule> getNavigationRules();
-
-
-
- /** @return Iterator over all defined renderkit ids */
- public abstract Collection<String> getRenderKitIds();
-
- /** @return renderkit class name for given renderkit id */
- public abstract Collection<String> getRenderKitClasses(String renderKitId);
-
- /**
- * @return Iterator over {@link org.apache.myfaces.config.element.ClientBehaviorRenderer ClientBehaviorRenderer}s
- * for the given renderKitId
- */
- public abstract Collection<ClientBehaviorRenderer> getClientBehaviorRenderers (String renderKitId);
-
- /**
- * @return Iterator over {@link org.apache.myfaces.config.element.Renderer Renderer}s for the given renderKitId
- */
- public abstract Collection<Renderer> getRenderers(String renderKitId);
-
-
- /**
- * @return Iterator over {@link jakarta.faces.event.PhaseListener} implementation class names
- */
- public abstract Collection<String> getLifecyclePhaseListeners();
-
- /**
- * @return Iterator over {@link ResourceBundle}
- */
- public abstract Collection<ResourceBundle> getResourceBundles();
-
- /**
- * @return Iterator over {@link jakarta.el.ELResolver} implementation class names
- */
- public abstract Collection<String> getElResolvers();
-
- /**
- * @return Iterator over (@link SystemEventListener) implementation class names
- */
- public abstract Collection<SystemEventListener> getSystemEventListeners();
-
- /**
- * @return Collection over behaviors
- */
- public abstract Collection<Behavior> getBehaviors ();
-
- /**
- * @return Collection over all defined default validator ids
- */
- public abstract Collection<String> getDefaultValidatorIds ();
-
- /**
- * @return Faces application version.
- */
- public abstract String getFacesVersion ();
-
- /**
- *
- * @return
- */
- public abstract Collection<NamedEvent> getNamedEvents();
-
- /**
- *
- * @since 2.1.0
- */
- public Collection<FaceletsProcessing> getFaceletsProcessing()
- {
- return Collections.emptyList();
- }
-
- public FaceletsProcessing getFaceletsProcessingConfiguration(String fileExtension)
- {
- return null;
- }
-
- /**
- * @since 2.2.0
- * @return
- */
- public Collection<FacesFlowDefinition> getFacesFlowDefinitions()
- {
- return Collections.emptyList();
- }
-
- public Collection<String> getProtectedViewUrlPatterns()
- {
- return Collections.emptyList();
- }
-
- public Collection<ContractMapping> getResourceLibraryContractMappings()
- {
- return Collections.emptyList();
- }
-
- public Collection<ComponentTagDeclaration> getComponentTagDeclarations()
- {
- return Collections.emptyList();
- }
-
- public Collection<String> getResourceResolvers()
- {
- return Collections.emptyList();
- }
-
- public Collection<FaceletTagLibrary> getTagLibraries()
- {
- return Collections.emptyList();
- }
-
- public Collection<ViewPoolMapping> getViewPoolMappings()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.3
- * @return
- */
- public Collection<String> getSearchKeywordResolvers()
- {
- return Collections.emptyList();
- }
-
- /**
- * @since 2.3
- * @return
- */
- public Collection<String> getSearchExpressionHandlerIterator()
- {
- return Collections.emptyList();
- }
-
- /**
- *
- * @since 2.3
- * @return
- */
- public Collection<FaceletsTemplateMapping> getFaceletsTemplateMappings()
- {
- return Collections.emptyList();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.element;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
+
+
+
+/**
+ *
+ * @author Leonardo Uribe
+ * @since 2.0.3
+ */
+public abstract class FacesConfigData implements Serializable
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5278120443255410184L;
+
+ /** @return Iterator over ApplicationFactory class names */
+ public abstract Collection<String> getApplicationFactoryIterator();
+
+ /** @return Iterator over ExceptionHandlerFactory class names */
+ public abstract Collection<String> getExceptionHandlerFactoryIterator();
+
+ /** @return Iterator over ExternalContextFactory class names */
+ public abstract Collection<String> getExternalContextFactoryIterator();
+
+ /** @return Iterator over FacesContextFactory class names */
+ public abstract Collection<String> getFacesContextFactoryIterator();
+
+ /** @return Iterator over LifecycleFactory class names */
+ public abstract Collection<String> getLifecycleFactoryIterator();
+
+ /** @return Iterator over ViewDeclarationLanguageFactory class names */
+ public abstract Collection<String> getViewDeclarationLanguageFactoryIterator();
+
+ /** @return Iterator over PartialViewContextFactory class names */
+ public abstract Collection<String> getPartialViewContextFactoryIterator();
+
+ /** @return Iterator over RenderKit factory class names */
+ public abstract Collection<String> getRenderKitFactoryIterator();
+
+ /** @return Iterator over TagHandlerDelegateFactory factory class names */
+ public abstract Collection<String> getTagHandlerDelegateFactoryIterator();
+
+ /** @return Iterator over VisitContextFactory factory class names */
+ public abstract Collection<String> getVisitContextFactoryIterator();
+
+ /**
+ * @since 2.1.0
+ * @return Iterator over FaceletCacheFactory factory class names
+ */
+ public Collection<String> getFaceletCacheFactoryIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.2
+ * @return
+ */
+ public Collection<String> getFlashFactoryIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<String> getClientWindowFactoryIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.2
+ * @return
+ */
+ public Collection<String> getFlowHandlerFactoryIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.3
+ * @return
+ */
+ public Collection<String> getSearchExpressionContextFactoryIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ /** @return Iterator over ActionListener class names (in reverse order!) */
+ public abstract Collection<String> getActionListenerIterator();
+
+ /** @return the default render kit id */
+ public abstract String getDefaultRenderKitId();
+
+ /** @return Iterator over message bundle names (in reverse order!) */
+ public abstract String getMessageBundle();
+
+ /** @return Iterator over NavigationHandler class names */
+ public abstract Collection<String> getNavigationHandlerIterator();
+
+ /** @return Iterator over ViewHandler class names */
+ public abstract Collection<String> getViewHandlerIterator();
+
+ /** @return Iterator over StateManager class names*/
+ public abstract Collection<String> getStateManagerIterator();
+
+ /** @return Iterator over ResourceHandler class names*/
+ public abstract Collection<String> getResourceHandlerIterator();
+
+ /** @return Iterator over PropertyResolver class names */
+ public abstract Collection<String> getPropertyResolverIterator();
+
+ /** @return Iterator over VariableResolver class names */
+ public abstract Collection<String> getVariableResolverIterator();
+
+ /** @return the default locale name */
+ public abstract String getDefaultLocale();
+
+ /** @return Iterator over supported locale names */
+ public abstract Collection<String> getSupportedLocalesIterator();
+
+
+ /** @return Iterator over all defined component types */
+ public abstract Collection<String> getComponentTypes();
+
+ /** @return component class that belongs to the given component type */
+ public abstract String getComponentClass(String componentType);
+
+ public abstract Map<String, Component> getComponentsByType();
+
+ /** @return Iterator over all defined converter ids */
+ public abstract Collection<String> getConverterIds();
+
+ /** @return Iterator over all classes with an associated converter */
+ public abstract Collection<String> getConverterClasses();
+
+ public abstract Map<String, String> getConverterClassesById();
+
+ public abstract Map<String, String> getConverterClassesByClass();
+
+ /** @return Iterator over the config classes for the converters */
+ public abstract Collection<String> getConverterConfigurationByClassName();
+
+ /** delivers a converter-configuration for one class-name */
+ public abstract Converter getConverterConfiguration(String converterClassName);
+
+ /** @return converter class that belongs to the given converter id */
+ public abstract String getConverterClassById(String converterId);
+
+ /** @return converter class that is associated with the given class name */
+ public abstract String getConverterClassByClass(String className);
+
+
+ /** @return Iterator over all defined validator ids */
+ public abstract Collection<String> getValidatorIds();
+
+ /** @return validator class name that belongs to the given validator id */
+ public abstract String getValidatorClass(String validatorId);
+
+ public abstract Map<String, String> getValidatorClassesById();
+
+ /**
+ * @return Iterator over {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
+ */
+ public abstract Collection<NavigationRule> getNavigationRules();
+
+
+
+ /** @return Iterator over all defined renderkit ids */
+ public abstract Collection<String> getRenderKitIds();
+
+ /** @return renderkit class name for given renderkit id */
+ public abstract Collection<String> getRenderKitClasses(String renderKitId);
+
+ /**
+ * @return Iterator over {@link org.apache.myfaces.config.element.ClientBehaviorRenderer ClientBehaviorRenderer}s
+ * for the given renderKitId
+ */
+ public abstract Collection<ClientBehaviorRenderer> getClientBehaviorRenderers (String renderKitId);
+
+ /**
+ * @return Iterator over {@link org.apache.myfaces.config.element.Renderer Renderer}s for the given renderKitId
+ */
+ public abstract Collection<Renderer> getRenderers(String renderKitId);
+
+
+ /**
+ * @return Iterator over {@link jakarta.faces.event.PhaseListener} implementation class names
+ */
+ public abstract Collection<String> getLifecyclePhaseListeners();
+
+ /**
+ * @return Iterator over {@link ResourceBundle}
+ */
+ public abstract Collection<ResourceBundle> getResourceBundles();
+
+ /**
+ * @return Iterator over {@link jakarta.el.ELResolver} implementation class names
+ */
+ public abstract Collection<String> getElResolvers();
+
+ /**
+ * @return Iterator over (@link SystemEventListener) implementation class names
+ */
+ public abstract Collection<SystemEventListener> getSystemEventListeners();
+
+ /**
+ * @return Collection over behaviors
+ */
+ public abstract Collection<Behavior> getBehaviors ();
+
+ /**
+ * @return Collection over all defined default validator ids
+ */
+ public abstract Collection<String> getDefaultValidatorIds ();
+
+ /**
+ * @return Faces application version.
+ */
+ public abstract String getFacesVersion ();
+
+ /**
+ *
+ * @return
+ */
+ public abstract Collection<NamedEvent> getNamedEvents();
+
+ /**
+ *
+ * @since 2.1.0
+ */
+ public Collection<FaceletsProcessing> getFaceletsProcessing()
+ {
+ return Collections.emptyList();
+ }
+
+ public FaceletsProcessing getFaceletsProcessingConfiguration(String fileExtension)
+ {
+ return null;
+ }
+
+ /**
+ * @since 2.2.0
+ * @return
+ */
+ public Collection<FacesFlowDefinition> getFacesFlowDefinitions()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<String> getProtectedViewUrlPatterns()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<ContractMapping> getResourceLibraryContractMappings()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<ComponentTagDeclaration> getComponentTagDeclarations()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<String> getResourceResolvers()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<FaceletTagLibrary> getTagLibraries()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<ViewPoolMapping> getViewPoolMappings()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.3
+ * @return
+ */
+ public Collection<String> getSearchKeywordResolvers()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ * @since 2.3
+ * @return
+ */
+ public Collection<String> getSearchExpressionHandlerIterator()
+ {
+ return Collections.emptyList();
+ }
+
+ /**
+ *
+ * @since 2.3
+ * @return
+ */
+ public Collection<FaceletsTemplateMapping> getFaceletsTemplateMappings()
+ {
+ return Collections.emptyList();
+ }
+
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigDispenserImpl.java b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigDispenserImpl.java
index 85c198d..719a4af 100755
--- a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigDispenserImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigDispenserImpl.java
@@ -1,1106 +1,1106 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import jakarta.faces.render.RenderKitFactory;
-
-import org.apache.myfaces.config.FacesConfigDispenser;
-import org.apache.myfaces.config.element.Behavior;
-import org.apache.myfaces.config.element.ClientBehaviorRenderer;
-import org.apache.myfaces.config.element.FaceletsProcessing;
-import org.apache.myfaces.config.element.FacesConfigExtension;
-import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.element.Renderer;
-import org.apache.myfaces.config.element.Application;
-import org.apache.myfaces.config.element.Component;
-import org.apache.myfaces.config.element.ComponentTagDeclaration;
-import org.apache.myfaces.config.element.ContractMapping;
-import org.apache.myfaces.config.element.Converter;
-import org.apache.myfaces.config.element.FaceletsTemplateMapping;
-import org.apache.myfaces.config.element.FacesConfig;
-import org.apache.myfaces.config.element.FacesFlowDefinition;
-import org.apache.myfaces.config.element.Factory;
-import org.apache.myfaces.config.element.LocaleConfig;
-import org.apache.myfaces.config.element.NamedEvent;
-import org.apache.myfaces.config.element.RenderKit;
-import org.apache.myfaces.config.element.ResourceBundle;
-import org.apache.myfaces.config.element.SystemEventListener;
-import org.apache.myfaces.config.element.ViewPoolMapping;
-import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
-import org.apache.myfaces.config.impl.element.RenderKitImpl;
-
-/**
- * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
- */
-public class FacesConfigDispenserImpl extends FacesConfigDispenser
-{
- private static final long serialVersionUID = 3550379003287939559L;
-
- private static final Logger log = Logger.getLogger(FacesConfigDispenserImpl.class.getName());
-
- // Factories
- private List<String> applicationFactories = new ArrayList<>();
- private List<String> exceptionHandlerFactories = new ArrayList<>();
- private List<String> externalContextFactories = new ArrayList<>();
- private List<String> facesContextFactories = new ArrayList<>();
- private List<String> lifecycleFactories = new ArrayList<>();
- private List<String> viewDeclarationLanguageFactories = new ArrayList<>();
- private List<String> partialViewContextFactories = new ArrayList<>();
- private List<String> renderKitFactories = new ArrayList<>();
- private List<String> tagHandlerDelegateFactories = new ArrayList<>();
- private List<String> visitContextFactories = new ArrayList<>();
- private List<String> faceletCacheFactories = new ArrayList<>();
- private List<String> flashFactories = new ArrayList<>();
- private List<String> clientWindowFactories = new ArrayList<>();
- private List<String> flowHandlerFactories = new ArrayList<>();
- private List<String> searchExpressionContextFactories = new ArrayList<>();
-
- private String defaultRenderKitId;
- private String messageBundle;
- private String facesVersion;
-
- private LocaleConfig localeConfig;
-
- private Map<String, Component> components = new HashMap<>();
- private Map<String, String> converterByClass = new HashMap<>();
- private Map<String, String> converterById = new HashMap<>();
- private Map<String, String> validators = new HashMap<>();
- private List<Behavior> behaviors = new ArrayList<>();
-
- private Map<String, Converter> converterConfigurationByClassName = new HashMap<>();
-
- private Map<String, RenderKit> renderKits = new LinkedHashMap<>();
-
- private List<String> actionListeners = new ArrayList<>();
- private List<String> elResolvers = new ArrayList<>();
- private List<String> lifecyclePhaseListeners = new ArrayList<>();
- private List<String> navigationHandlers = new ArrayList<>();
- private List<String> propertyResolver = new ArrayList<>();
- private List<String> resourceHandlers = new ArrayList<>();
- private List<String> stateManagers = new ArrayList<>();
- private List<String> variableResolver = new ArrayList<>();
- private List<String> viewHandlers = new ArrayList<>();
- private List<String> defaultValidatorIds = new ArrayList<>();
- private List<String> defaultAnnotatedValidatorIds = new ArrayList<>();
- private List<String> searchExpressionHandlers = new ArrayList<>();
- private List<String> searchKeywordResolvers = new ArrayList<>();
-
- private List<NavigationRule> navigationRules = new ArrayList<>();
- private List<ResourceBundle> resourceBundles = new ArrayList<>();
-
- private List<SystemEventListener> systemEventListeners = new ArrayList<>();
-
- private List<NamedEvent> namedEvents = new ArrayList<>();
-
- private Map<String, FaceletsProcessing> faceletsProcessingByFileExtension
- = new HashMap<>();
-
- private List<FacesFlowDefinition> facesFlowDefinitions = new ArrayList<>();
-
- private List<String> protectedViewUrlPatterns = new ArrayList<>();
- private List<ContractMapping> resourceLibraryContractMappings = new ArrayList<>();
-
- private List<ComponentTagDeclaration> componentTagDeclarations = new ArrayList<>();
- private List<FaceletTagLibrary> faceletTagLibraries = new ArrayList<>();
-
- private List <String> resourceResolvers = new ArrayList<>();
-
- private List<ViewPoolMapping> viewPoolMappings = new ArrayList<>();
- private List<FaceletsTemplateMapping> faceletsTemplateMappings = new ArrayList<>();
-
- // Unmodifiable list/maps to avoid modifications
- private transient List<String> umapplicationFactories;
- private transient List<String> umexceptionHandlerFactories;
- private transient List<String> umexternalContextFactories;
- private transient List<String> umfacesContextFactories;
- private transient List<String> umlifecycleFactories;
- private transient List<String> umviewDeclarationLanguageFactories;
- private transient List<String> umpartialViewContextFactories;
- private transient List<String> umrenderKitFactories;
- private transient List<String> umtagHandlerDelegateFactories;
- private transient List<String> umvisitContextFactories;
- private transient List<String> umfaceletCacheFactories;
- private transient List<String> umflashFactories;
- private transient List<String> umclientWindowFactories;
- private transient List<String> umflowHandlerFactories;
- private transient List<String> umsearchExpressionContextFactories;
- private transient List<Behavior> umbehaviors;
- private transient List<String> umactionListeners;
- private transient List<String> umelResolvers;
- private transient List<String> umlifecyclePhaseListeners;
- private transient List<String> umnavigationHandlers;
- private transient List<String> umpropertyResolver;
- private transient List<String> umresourceHandlers;
- private transient List<String> umstateManagers;
- private transient List<String> umvariableResolver;
- private transient List<String> umviewHandlers;
- private transient List<String> umsearchExpressionHandlers;
- private transient List<String> umsearchKeywordResolvers;
- private transient List<NavigationRule> umnavigationRules;
- private transient List<ResourceBundle> umresourceBundles;
- private transient List<SystemEventListener> umsystemEventListeners;
- private transient List<NamedEvent> umnamedEvents;
- private transient List<FacesFlowDefinition> umfacesFlowDefinitions;
- private transient List<String> umprotectedViewUrlPatterns;
- private transient List<ContractMapping> umresourceLibraryContractMappings;
- private transient List<ComponentTagDeclaration> umcomponentTagDeclarations;
- private transient List<FaceletTagLibrary> umfaceletTagLibraries;
- private transient List <String> umresourceResolvers;
- private transient List<ViewPoolMapping> umviewPoolMappings;
- private transient List<FaceletsTemplateMapping> umfaceletsTemplateMappings;
-
- /**
- * Add another unmarshalled faces config object.
- *
- * @param config
- * unmarshalled faces config object
- */
- @Override
- public void feed(FacesConfig config)
- {
- for (Factory factory : config.getFactories())
- {
- applicationFactories.addAll(factory.getApplicationFactory());
- exceptionHandlerFactories.addAll(factory.getExceptionHandlerFactory());
- externalContextFactories.addAll(factory.getExternalContextFactory());
- facesContextFactories.addAll(factory.getFacesContextFactory());
- lifecycleFactories.addAll(factory.getLifecycleFactory());
- viewDeclarationLanguageFactories.addAll(factory.getViewDeclarationLanguageFactory());
- partialViewContextFactories.addAll(factory.getPartialViewContextFactory());
- renderKitFactories.addAll(factory.getRenderkitFactory());
- tagHandlerDelegateFactories.addAll(factory.getTagHandlerDelegateFactory());
- visitContextFactories.addAll(factory.getVisitContextFactory());
- faceletCacheFactories.addAll(factory.getFaceletCacheFactory());
- flashFactories.addAll(factory.getFlashFactory());
- clientWindowFactories.addAll(factory.getClientWindowFactory());
- flowHandlerFactories.addAll(factory.getFlowHandlerFactory());
- searchExpressionContextFactories.addAll(factory.getSearchExpressionContextFactory());
- }
-
- for (Component component : config.getComponents())
- {
- components.put(component.getComponentType(), component);
- }
- validators.putAll(config.getValidators());
- behaviors.addAll(config.getBehaviors());
-
- for (Application application : config.getApplications())
- {
- if (!application.getDefaultRenderkitId().isEmpty())
- {
- defaultRenderKitId =
- application.getDefaultRenderkitId().get(application.getDefaultRenderkitId().size() - 1);
- }
-
- if (!application.getMessageBundle().isEmpty())
- {
- messageBundle = application.getMessageBundle().get(application.getMessageBundle().size() - 1);
- }
-
- if (!application.getLocaleConfig().isEmpty())
- {
- localeConfig = application.getLocaleConfig().get(application.getLocaleConfig().size() - 1);
- }
-
- actionListeners.addAll(application.getActionListener());
- navigationHandlers.addAll(application.getNavigationHandler());
- resourceHandlers.addAll(application.getResourceHandler());
- viewHandlers.addAll(application.getViewHandler());
- stateManagers.addAll(application.getStateManager());
- propertyResolver.addAll(application.getPropertyResolver());
- variableResolver.addAll(application.getVariableResolver());
- resourceBundles.addAll(application.getResourceBundle());
- elResolvers.addAll(application.getElResolver());
- resourceLibraryContractMappings.addAll(application.getResourceLibraryContractMappings());
- searchExpressionHandlers.addAll(application.getSearchExpressionHandler());
- searchKeywordResolvers.addAll(application.getSearchKeywordResolver());
-
- // Jsf 2.0 spec section 3.5.3 says this:
- // ".... Any configuration resource that declares a list of default
- // validators overrides any list provided in a previously processed
- // configuration resource. If an empty <default-validators/> element
- // is found in a configuration resource, the list
- // of default validators must be cleared....."
- if (application.isDefaultValidatorsPresent())
- {
- // we have a <default-validators> element, so any existing
- // default validators should be removed
- defaultValidatorIds.clear();
-
- // now add all default-validator entries (could be zero)
- defaultValidatorIds.addAll(application.getDefaultValidatorIds());
- }
- else
- {
- //If isDefaultValidatorsPresent() is false, and there are still
- //default validators, it means they were added using annotations, so
- //they are not affected by the empty entry according to section 3.5.3
- defaultAnnotatedValidatorIds.addAll(application.getDefaultValidatorIds());
- }
-
- systemEventListeners.addAll(application.getSystemEventListeners());
- }
-
- for (Converter converter : config.getConverters())
- {
- if (converter.getConverterId() != null)
- {
- converterById.put(converter.getConverterId(), converter.getConverterClass());
- }
- if (converter.getForClass() != null)
- {
- String oldConverter = converterByClass.get(converter.getForClass());
- // don't log if someone overwrites the built-in converters
- if (oldConverter != null && !oldConverter.startsWith("jakarta.faces.convert."))
- {
- log.warning("There is already a converter defined for class: " + converter.getForClass() + "."
- + " old: " + oldConverter
- + " new: " + converter.getConverterClass());
- }
-
- converterByClass.put(converter.getForClass(), converter.getConverterClass());
- }
-
- converterConfigurationByClassName.put(converter.getConverterClass(), converter);
- }
-
- for (RenderKit renderKit : config.getRenderKits())
- {
- String renderKitId = renderKit.getId();
-
- if (renderKitId == null)
- {
- renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
-
- RenderKit existing = renderKits.get(renderKitId);
-
- if (existing == null)
- {
- existing = new RenderKitImpl();
- existing.merge(renderKit);
- renderKits.put(renderKitId, existing);
- }
- else
- {
- existing.merge(renderKit);
- }
- }
-
- for (FacesConfigExtension extension : config.getFacesConfigExtensions())
- {
- for (FaceletsProcessing faceletsProcessing : extension.getFaceletsProcessingList())
- {
- if (faceletsProcessing.getFileExtension() != null && faceletsProcessing.getFileExtension().length() > 0)
- {
- faceletsProcessingByFileExtension.put(faceletsProcessing.getFileExtension(), faceletsProcessing);
- }
- }
- }
-
- componentTagDeclarations.addAll(config.getComponentTagDeclarations().values());
-
- faceletTagLibraries.addAll(config.getFaceletTagLibraryList());
-
- lifecyclePhaseListeners.addAll(config.getLifecyclePhaseListener());
- navigationRules.addAll(config.getNavigationRules());
- facesVersion = config.getVersion();
- namedEvents.addAll(config.getNamedEvents());
- facesFlowDefinitions.addAll(config.getFacesFlowDefinitions());
- protectedViewUrlPatterns.addAll(config.getProtectedViewsUrlPatternList());
- resourceResolvers.addAll(config.getResourceResolversList());
- for (FacesConfigExtension extension : config.getFacesConfigExtensions())
- {
- viewPoolMappings.addAll(extension.getViewPoolMappings());
- }
- for (FacesConfigExtension extension : config.getFacesConfigExtensions())
- {
- faceletsTemplateMappings.addAll(extension.getFaceletsTemplateMappings());
- }
- }
-
- /**
- * Add another ApplicationFactory class name
- *
- * @param factoryClassName a class name
- */
- @Override
- public void feedApplicationFactory(String factoryClassName)
- {
- applicationFactories.add(factoryClassName);
- }
-
- @Override
- public void feedExceptionHandlerFactory(String factoryClassName)
- {
- exceptionHandlerFactories.add(factoryClassName);
- }
-
- @Override
- public void feedExternalContextFactory(String factoryClassName)
- {
- externalContextFactories.add(factoryClassName);
- }
-
- /**
- * Add another FacesContextFactory class name
- *
- * @param factoryClassName a class name
- */
- @Override
- public void feedFacesContextFactory(String factoryClassName)
- {
- facesContextFactories.add(factoryClassName);
- }
-
- /**
- * Add another LifecycleFactory class name
- *
- * @param factoryClassName a class name
- */
- @Override
- public void feedLifecycleFactory(String factoryClassName)
- {
- lifecycleFactories.add(factoryClassName);
- }
-
- @Override
- public void feedViewDeclarationLanguageFactory(String factoryClassName)
- {
- viewDeclarationLanguageFactories.add(factoryClassName);
- }
-
- @Override
- public void feedPartialViewContextFactory(String factoryClassName)
- {
- partialViewContextFactories.add(factoryClassName);
- }
-
- /**
- * Add another RenderKitFactory class name
- *
- * @param factoryClassName a class name
- */
- @Override
- public void feedRenderKitFactory(String factoryClassName)
- {
- renderKitFactories.add(factoryClassName);
- }
-
- @Override
- public void feedTagHandlerDelegateFactory(String factoryClassName)
- {
- tagHandlerDelegateFactories.add(factoryClassName);
- }
-
- @Override
- public void feedVisitContextFactory(String factoryClassName)
- {
- visitContextFactories.add(factoryClassName);
- }
-
- /**
- * @return Collection over ApplicationFactory class names
- */
- @Override
- public Collection<String> getApplicationFactoryIterator()
- {
- if (umapplicationFactories == null)
- {
- umapplicationFactories = Collections.unmodifiableList(applicationFactories);
- }
- return umapplicationFactories;
- }
-
- @Override
- public Collection<String> getExceptionHandlerFactoryIterator()
- {
- if (umexceptionHandlerFactories == null)
- {
- umexceptionHandlerFactories = Collections.unmodifiableList(exceptionHandlerFactories);
- }
- return umexceptionHandlerFactories;
- }
-
- @Override
- public Collection<String> getExternalContextFactoryIterator()
- {
- if (umexternalContextFactories == null)
- {
- umexternalContextFactories = Collections.unmodifiableList(externalContextFactories);
- }
- return umexternalContextFactories;
- }
-
- /**
- * @return Collection over FacesContextFactory class names
- */
- @Override
- public Collection<String> getFacesContextFactoryIterator()
- {
- if (umfacesContextFactories == null)
- {
- umfacesContextFactories = Collections.unmodifiableList(facesContextFactories);
- }
- return umfacesContextFactories;
- }
-
- /**
- * @return Collection over LifecycleFactory class names
- */
- @Override
- public Collection<String> getLifecycleFactoryIterator()
- {
- if (umlifecycleFactories == null)
- {
- umlifecycleFactories = Collections.unmodifiableList(lifecycleFactories);
- }
- return umlifecycleFactories;
- }
-
- @Override
- public Collection<String> getViewDeclarationLanguageFactoryIterator()
- {
- if (umviewDeclarationLanguageFactories == null)
- {
- umviewDeclarationLanguageFactories = Collections.unmodifiableList(viewDeclarationLanguageFactories);
- }
- return umviewDeclarationLanguageFactories;
- }
-
- @Override
- public Collection<String> getPartialViewContextFactoryIterator()
- {
- if (umpartialViewContextFactories == null)
- {
- umpartialViewContextFactories = Collections.unmodifiableList(partialViewContextFactories);
- }
- return umpartialViewContextFactories;
- }
-
- /**
- * @return Collection over RenderKit factory class names
- */
- @Override
- public Collection<String> getRenderKitFactoryIterator()
- {
- if (umrenderKitFactories == null)
- {
- umrenderKitFactories = Collections.unmodifiableList(renderKitFactories);
- }
- return umrenderKitFactories;
- }
-
- @Override
- public Collection<String> getTagHandlerDelegateFactoryIterator()
- {
- if (umtagHandlerDelegateFactories == null)
- {
- umtagHandlerDelegateFactories = Collections.unmodifiableList(tagHandlerDelegateFactories);
- }
- return umtagHandlerDelegateFactories;
- }
-
- @Override
- public Collection<String> getVisitContextFactoryIterator()
- {
- if (umvisitContextFactories == null)
- {
- umvisitContextFactories = Collections.unmodifiableList(visitContextFactories);
- }
- return umvisitContextFactories;
- }
-
- /**
- * @return Collection over ActionListener class names
- */
- @Override
- public Collection<String> getActionListenerIterator()
- {
- if (umactionListeners == null)
- {
- umactionListeners = Collections.unmodifiableList(actionListeners);
- }
- return umactionListeners;
- }
-
- /**
- * @return the default render kit id
- */
- @Override
- public String getDefaultRenderKitId()
- {
- return defaultRenderKitId;
- }
-
- /**
- * @return Collection over message bundle names
- */
- @Override
- public String getMessageBundle()
- {
- return messageBundle;
- }
-
- /**
- * @return Collection over NavigationHandler class names
- */
- @Override
- public Collection<String> getNavigationHandlerIterator()
- {
- if (umnavigationHandlers == null)
- {
- umnavigationHandlers = Collections.unmodifiableList(navigationHandlers);
- }
- return umnavigationHandlers;
- }
-
- /**
- * @return Collection over ResourceHandler class names
- */
- @Override
- public Collection<String> getResourceHandlerIterator()
- {
- if (umresourceHandlers == null)
- {
- umresourceHandlers = Collections.unmodifiableList(resourceHandlers);
- }
- return umresourceHandlers;
- }
-
- /**
- * @return Collection over ViewHandler class names
- */
- @Override
- public Collection<String> getViewHandlerIterator()
- {
- if (umviewHandlers == null)
- {
- umviewHandlers = Collections.unmodifiableList(viewHandlers);
- }
- return umviewHandlers;
- }
-
- /**
- * @return Collection over StateManager class names
- */
- @Override
- public Collection<String> getStateManagerIterator()
- {
- if (umstateManagers == null)
- {
- umstateManagers = Collections.unmodifiableList(stateManagers);
- }
- return umstateManagers;
- }
-
- /**
- * @return Collection over PropertyResolver class names
- */
- @Override
- public Collection<String> getPropertyResolverIterator()
- {
- if (umpropertyResolver == null)
- {
- umpropertyResolver = Collections.unmodifiableList(propertyResolver);
- }
- return umpropertyResolver;
- }
-
- /**
- * @return Collection over VariableResolver class names
- */
- @Override
- public Collection<String> getVariableResolverIterator()
- {
- if (umvariableResolver == null)
- {
- umvariableResolver = Collections.unmodifiableList(variableResolver);
- }
- return umvariableResolver;
- }
-
- /**
- * @return the default locale name
- */
- @Override
- public String getDefaultLocale()
- {
- if (localeConfig != null)
- {
- return localeConfig.getDefaultLocale();
- }
- return null;
- }
-
- /**
- * @return Collection over supported locale names
- */
- @Override
- public Collection<String> getSupportedLocalesIterator()
- {
- Collection<String> locale;
- if (localeConfig != null)
- {
- locale = Collections.unmodifiableCollection(localeConfig.getSupportedLocales());
- }
- else
- {
- locale = Collections.emptyList();
- }
-
- return locale;
- }
-
- /**
- * @return Collection over all defined component types
- */
- @Override
- public Collection<String> getComponentTypes()
- {
- return Collections.unmodifiableCollection(components.keySet());
- }
-
- @Override
- public Map<String, Component> getComponentsByType()
- {
- return Collections.unmodifiableMap(components);
- }
-
- /**
- * @return component class that belongs to the given component type
- */
- @Override
- public String getComponentClass(String componentType)
- {
- Component component = components.get(componentType);
- return component == null ? null : component.getComponentClass();
- }
-
- /**
- * @return Collection over all defined converter ids
- */
- @Override
- public Collection<String> getConverterIds()
- {
- return Collections.unmodifiableCollection(converterById.keySet());
- }
-
- @Override
- public Map<String, String> getConverterClassesById()
- {
- return Collections.unmodifiableMap(converterById);
- }
-
- /**
- * @return Collection over all classes with an associated converter
- */
- @Override
- public Collection<String> getConverterClasses()
- {
- return Collections.unmodifiableCollection(converterByClass.keySet());
- }
-
- @Override
- public Map<String, String> getConverterClassesByClass()
- {
- return Collections.unmodifiableMap(converterByClass);
- }
-
- @Override
- public Collection<String> getConverterConfigurationByClassName()
- {
- return Collections.unmodifiableCollection(converterConfigurationByClassName.keySet());
- }
-
- @Override
- public Converter getConverterConfiguration(String converterClassName)
- {
- return converterConfigurationByClassName.get(converterClassName);
- }
-
- /**
- * @return converter class that belongs to the given converter id
- */
- @Override
- public String getConverterClassById(String converterId)
- {
- return converterById.get(converterId);
- }
-
- /**
- * @return converter class that is associated with the given class name
- */
- @Override
- public String getConverterClassByClass(String className)
- {
- return converterByClass.get(className);
- }
-
- /**
- * @return Collection over all defined default validator ids
- */
- @Override
- public Collection<String> getDefaultValidatorIds ()
- {
- List<String> allDefaultValidatorIds = new ArrayList<>();
- allDefaultValidatorIds.addAll(defaultAnnotatedValidatorIds);
- allDefaultValidatorIds.addAll(defaultValidatorIds);
- return Collections.unmodifiableCollection(allDefaultValidatorIds);
- }
-
- /**
- * @return Collection over all defined validator ids
- */
- @Override
- public Collection<String> getValidatorIds()
- {
- return Collections.unmodifiableCollection(validators.keySet());
- }
-
- @Override
- public Map<String, String> getValidatorClassesById()
- {
- return Collections.unmodifiableMap(validators);
- }
-
- /**
- * @return validator class name that belongs to the given validator id
- */
- @Override
- public String getValidatorClass(String validatorId)
- {
- return validators.get(validatorId);
- }
-
- /**
- * @return Collection over {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
- */
- @Override
- public Collection<NavigationRule> getNavigationRules()
- {
- if (umnavigationRules == null)
- {
- umnavigationRules = Collections.unmodifiableList(navigationRules);
- }
- return umnavigationRules;
- }
-
- /**
- * @return Collection over all defined renderkit ids
- */
- @Override
- public Collection<String> getRenderKitIds()
- {
- return Collections.unmodifiableCollection(renderKits.keySet());
- }
-
- /**
- * @return renderkit class name for given renderkit id
- */
- @Override
- public Collection<String> getRenderKitClasses(String renderKitId)
- {
- return renderKits.get(renderKitId).getRenderKitClasses();
- }
-
- /**
- * @return Iterator over
- * {@link org.apache.myfaces.config.element.ClientBehaviorRenderer ClientBehaviorRenderer}s
- * for the given renderKitId
- */
- @Override
- public Collection<ClientBehaviorRenderer> getClientBehaviorRenderers (String renderKitId)
- {
- return renderKits.get (renderKitId).getClientBehaviorRenderers();
- }
-
- /**
- * @return Collection over {@link org.apache.myfaces.config.element.Renderer Renderer}s for the given renderKitId
- */
- @Override
- public Collection<Renderer> getRenderers(String renderKitId)
- {
- return renderKits.get(renderKitId).getRenderer();
- }
-
- /**
- * @return Collection over {@link jakarta.faces.event.PhaseListener} implementation class names
- */
- @Override
- public Collection<String> getLifecyclePhaseListeners()
- {
- if (umlifecyclePhaseListeners == null)
- {
- umlifecyclePhaseListeners = Collections.unmodifiableList(lifecyclePhaseListeners);
- }
- return umlifecyclePhaseListeners;
- }
-
- @Override
- public Collection<ResourceBundle> getResourceBundles()
- {
- if (umresourceBundles == null)
- {
- umresourceBundles = Collections.unmodifiableList(resourceBundles);
- }
- return umresourceBundles;
- }
-
- @Override
- public Collection<String> getElResolvers()
- {
- if (umelResolvers == null)
- {
- umelResolvers = Collections.unmodifiableList(elResolvers);
- }
- return umelResolvers;
- }
-
- @Override
- public Collection<SystemEventListener> getSystemEventListeners()
- {
- if (umsystemEventListeners == null)
- {
- umsystemEventListeners = Collections.unmodifiableList(systemEventListeners);
- }
- return umsystemEventListeners;
- }
-
- @Override
- public Collection<Behavior> getBehaviors()
- {
- if (umbehaviors == null)
- {
- umbehaviors = Collections.unmodifiableList(behaviors);
- }
- return umbehaviors;
- }
-
- @Override
- public String getFacesVersion()
- {
- return facesVersion;
- }
-
- @Override
- public Collection<NamedEvent> getNamedEvents()
- {
- if (umnamedEvents == null)
- {
- umnamedEvents = Collections.unmodifiableList(namedEvents);
- }
- return umnamedEvents;
- }
-
- @Override
- public Collection<FaceletsProcessing> getFaceletsProcessing()
- {
- return Collections.unmodifiableCollection(faceletsProcessingByFileExtension.values());
- }
-
- @Override
- public FaceletsProcessing getFaceletsProcessingConfiguration(String fileExtension)
- {
- return faceletsProcessingByFileExtension.get(fileExtension);
- }
-
- @Override
- public void feedFaceletCacheFactory(String factoryClassName)
- {
- faceletCacheFactories.add(factoryClassName);
- }
-
- @Override
- public Collection<String> getFaceletCacheFactoryIterator()
- {
- if (umfaceletCacheFactories == null)
- {
- umfaceletCacheFactories = Collections.unmodifiableList(faceletCacheFactories);
- }
- return umfaceletCacheFactories;
- }
-
- @Override
- public void feedFlashFactory(String factoryClassName)
- {
- flashFactories.add(factoryClassName);
- }
-
- @Override
- public Collection<String> getFlashFactoryIterator()
- {
- if (umflashFactories == null)
- {
- umflashFactories = Collections.unmodifiableList(flashFactories);
- }
- return umflashFactories;
- }
-
- @Override
- public Collection<String> getFlowHandlerFactoryIterator()
- {
- if (umflowHandlerFactories == null)
- {
- umflowHandlerFactories = Collections.unmodifiableList(flowHandlerFactories);
- }
- return umflowHandlerFactories;
- }
-
- @Override
- public void feedClientWindowFactory(String factoryClassName)
- {
- clientWindowFactories.add(factoryClassName);
- }
-
- @Override
- public Collection<String> getClientWindowFactoryIterator()
- {
- if (umclientWindowFactories == null)
- {
- umclientWindowFactories = Collections.unmodifiableList(clientWindowFactories);
- }
- return umclientWindowFactories;
- }
-
- @Override
- public Collection<FacesFlowDefinition> getFacesFlowDefinitions()
- {
- if (umfacesFlowDefinitions == null)
- {
- umfacesFlowDefinitions = Collections.unmodifiableList(facesFlowDefinitions);
- }
- return umfacesFlowDefinitions;
- }
-
- @Override
- public Collection<String> getProtectedViewUrlPatterns()
- {
- if (umprotectedViewUrlPatterns == null)
- {
- umprotectedViewUrlPatterns = Collections.unmodifiableList(protectedViewUrlPatterns);
- }
- return umprotectedViewUrlPatterns;
- }
-
- @Override
- public Collection<ContractMapping> getResourceLibraryContractMappings()
- {
- if (umresourceLibraryContractMappings == null)
- {
- umresourceLibraryContractMappings = Collections.unmodifiableList(resourceLibraryContractMappings);
- }
- return umresourceLibraryContractMappings;
- }
-
- @Override
- public Collection<ComponentTagDeclaration> getComponentTagDeclarations()
- {
- if (umcomponentTagDeclarations == null)
- {
- umcomponentTagDeclarations = Collections.unmodifiableList(componentTagDeclarations);
- }
- return umcomponentTagDeclarations;
- }
-
- @Override
- public Collection<String> getResourceResolvers()
- {
- if (umresourceResolvers == null)
- {
- umresourceResolvers = Collections.unmodifiableList(resourceResolvers);
- }
- return umresourceResolvers;
- }
-
- @Override
- public Collection<FaceletTagLibrary> getTagLibraries()
- {
- if (umfaceletTagLibraries == null)
- {
- umfaceletTagLibraries = Collections.unmodifiableList(faceletTagLibraries);
- }
- return umfaceletTagLibraries;
- }
-
- @Override
- public Collection<ViewPoolMapping> getViewPoolMappings()
- {
- if (umviewPoolMappings == null)
- {
- umviewPoolMappings = Collections.unmodifiableList(viewPoolMappings);
- }
- return umviewPoolMappings;
- }
-
- @Override
- public void feedSearchExpressionContextFactory(String factoryClassName)
- {
- searchExpressionContextFactories.add(factoryClassName);
- }
-
- @Override
- public Collection<String> getSearchExpressionContextFactoryIterator()
- {
- if (umsearchExpressionContextFactories == null)
- {
- umsearchExpressionContextFactories = Collections.unmodifiableList(searchExpressionContextFactories);
- }
- return umsearchExpressionContextFactories;
- }
-
- @Override
- public Collection<String> getSearchKeywordResolvers()
- {
- if (umsearchKeywordResolvers == null)
- {
- umsearchKeywordResolvers = Collections.unmodifiableList(searchKeywordResolvers);
- }
- return umsearchKeywordResolvers;
- }
-
- @Override
- public Collection<String> getSearchExpressionHandlerIterator()
- {
- if (umsearchExpressionHandlers == null)
- {
- umsearchExpressionHandlers = Collections.unmodifiableList(searchExpressionHandlers);
- }
- return umsearchExpressionHandlers;
- }
-
- @Override
- public Collection<FaceletsTemplateMapping> getFaceletsTemplateMappings()
- {
- if (umfaceletsTemplateMappings == null)
- {
- umfaceletsTemplateMappings = Collections.unmodifiableList(faceletsTemplateMappings);
- }
- return umfaceletsTemplateMappings;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import jakarta.faces.render.RenderKitFactory;
+
+import org.apache.myfaces.config.FacesConfigDispenser;
+import org.apache.myfaces.config.element.Behavior;
+import org.apache.myfaces.config.element.ClientBehaviorRenderer;
+import org.apache.myfaces.config.element.FaceletsProcessing;
+import org.apache.myfaces.config.element.FacesConfigExtension;
+import org.apache.myfaces.config.element.NavigationRule;
+import org.apache.myfaces.config.element.Renderer;
+import org.apache.myfaces.config.element.Application;
+import org.apache.myfaces.config.element.Component;
+import org.apache.myfaces.config.element.ComponentTagDeclaration;
+import org.apache.myfaces.config.element.ContractMapping;
+import org.apache.myfaces.config.element.Converter;
+import org.apache.myfaces.config.element.FaceletsTemplateMapping;
+import org.apache.myfaces.config.element.FacesConfig;
+import org.apache.myfaces.config.element.FacesFlowDefinition;
+import org.apache.myfaces.config.element.Factory;
+import org.apache.myfaces.config.element.LocaleConfig;
+import org.apache.myfaces.config.element.NamedEvent;
+import org.apache.myfaces.config.element.RenderKit;
+import org.apache.myfaces.config.element.ResourceBundle;
+import org.apache.myfaces.config.element.SystemEventListener;
+import org.apache.myfaces.config.element.ViewPoolMapping;
+import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
+import org.apache.myfaces.config.impl.element.RenderKitImpl;
+
+/**
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ */
+public class FacesConfigDispenserImpl extends FacesConfigDispenser
+{
+ private static final long serialVersionUID = 3550379003287939559L;
+
+ private static final Logger log = Logger.getLogger(FacesConfigDispenserImpl.class.getName());
+
+ // Factories
+ private List<String> applicationFactories = new ArrayList<>();
+ private List<String> exceptionHandlerFactories = new ArrayList<>();
+ private List<String> externalContextFactories = new ArrayList<>();
+ private List<String> facesContextFactories = new ArrayList<>();
+ private List<String> lifecycleFactories = new ArrayList<>();
+ private List<String> viewDeclarationLanguageFactories = new ArrayList<>();
+ private List<String> partialViewContextFactories = new ArrayList<>();
+ private List<String> renderKitFactories = new ArrayList<>();
+ private List<String> tagHandlerDelegateFactories = new ArrayList<>();
+ private List<String> visitContextFactories = new ArrayList<>();
+ private List<String> faceletCacheFactories = new ArrayList<>();
+ private List<String> flashFactories = new ArrayList<>();
+ private List<String> clientWindowFactories = new ArrayList<>();
+ private List<String> flowHandlerFactories = new ArrayList<>();
+ private List<String> searchExpressionContextFactories = new ArrayList<>();
+
+ private String defaultRenderKitId;
+ private String messageBundle;
+ private String facesVersion;
+
+ private LocaleConfig localeConfig;
+
+ private Map<String, Component> components = new HashMap<>();
+ private Map<String, String> converterByClass = new HashMap<>();
+ private Map<String, String> converterById = new HashMap<>();
+ private Map<String, String> validators = new HashMap<>();
+ private List<Behavior> behaviors = new ArrayList<>();
+
+ private Map<String, Converter> converterConfigurationByClassName = new HashMap<>();
+
+ private Map<String, RenderKit> renderKits = new LinkedHashMap<>();
+
+ private List<String> actionListeners = new ArrayList<>();
+ private List<String> elResolvers = new ArrayList<>();
+ private List<String> lifecyclePhaseListeners = new ArrayList<>();
+ private List<String> navigationHandlers = new ArrayList<>();
+ private List<String> propertyResolver = new ArrayList<>();
+ private List<String> resourceHandlers = new ArrayList<>();
+ private List<String> stateManagers = new ArrayList<>();
+ private List<String> variableResolver = new ArrayList<>();
+ private List<String> viewHandlers = new ArrayList<>();
+ private List<String> defaultValidatorIds = new ArrayList<>();
+ private List<String> defaultAnnotatedValidatorIds = new ArrayList<>();
+ private List<String> searchExpressionHandlers = new ArrayList<>();
+ private List<String> searchKeywordResolvers = new ArrayList<>();
+
+ private List<NavigationRule> navigationRules = new ArrayList<>();
+ private List<ResourceBundle> resourceBundles = new ArrayList<>();
+
+ private List<SystemEventListener> systemEventListeners = new ArrayList<>();
+
+ private List<NamedEvent> namedEvents = new ArrayList<>();
+
+ private Map<String, FaceletsProcessing> faceletsProcessingByFileExtension
+ = new HashMap<>();
+
+ private List<FacesFlowDefinition> facesFlowDefinitions = new ArrayList<>();
+
+ private List<String> protectedViewUrlPatterns = new ArrayList<>();
+ private List<ContractMapping> resourceLibraryContractMappings = new ArrayList<>();
+
+ private List<ComponentTagDeclaration> componentTagDeclarations = new ArrayList<>();
+ private List<FaceletTagLibrary> faceletTagLibraries = new ArrayList<>();
+
+ private List <String> resourceResolvers = new ArrayList<>();
+
+ private List<ViewPoolMapping> viewPoolMappings = new ArrayList<>();
+ private List<FaceletsTemplateMapping> faceletsTemplateMappings = new ArrayList<>();
+
+ // Unmodifiable list/maps to avoid modifications
+ private transient List<String> umapplicationFactories;
+ private transient List<String> umexceptionHandlerFactories;
+ private transient List<String> umexternalContextFactories;
+ private transient List<String> umfacesContextFactories;
+ private transient List<String> umlifecycleFactories;
+ private transient List<String> umviewDeclarationLanguageFactories;
+ private transient List<String> umpartialViewContextFactories;
+ private transient List<String> umrenderKitFactories;
+ private transient List<String> umtagHandlerDelegateFactories;
+ private transient List<String> umvisitContextFactories;
+ private transient List<String> umfaceletCacheFactories;
+ private transient List<String> umflashFactories;
+ private transient List<String> umclientWindowFactories;
+ private transient List<String> umflowHandlerFactories;
+ private transient List<String> umsearchExpressionContextFactories;
+ private transient List<Behavior> umbehaviors;
+ private transient List<String> umactionListeners;
+ private transient List<String> umelResolvers;
+ private transient List<String> umlifecyclePhaseListeners;
+ private transient List<String> umnavigationHandlers;
+ private transient List<String> umpropertyResolver;
+ private transient List<String> umresourceHandlers;
+ private transient List<String> umstateManagers;
+ private transient List<String> umvariableResolver;
+ private transient List<String> umviewHandlers;
+ private transient List<String> umsearchExpressionHandlers;
+ private transient List<String> umsearchKeywordResolvers;
+ private transient List<NavigationRule> umnavigationRules;
+ private transient List<ResourceBundle> umresourceBundles;
+ private transient List<SystemEventListener> umsystemEventListeners;
+ private transient List<NamedEvent> umnamedEvents;
+ private transient List<FacesFlowDefinition> umfacesFlowDefinitions;
+ private transient List<String> umprotectedViewUrlPatterns;
+ private transient List<ContractMapping> umresourceLibraryContractMappings;
+ private transient List<ComponentTagDeclaration> umcomponentTagDeclarations;
+ private transient List<FaceletTagLibrary> umfaceletTagLibraries;
+ private transient List <String> umresourceResolvers;
+ private transient List<ViewPoolMapping> umviewPoolMappings;
+ private transient List<FaceletsTemplateMapping> umfaceletsTemplateMappings;
+
+ /**
+ * Add another unmarshalled faces config object.
+ *
+ * @param config
+ * unmarshalled faces config object
+ */
+ @Override
+ public void feed(FacesConfig config)
+ {
+ for (Factory factory : config.getFactories())
+ {
+ applicationFactories.addAll(factory.getApplicationFactory());
+ exceptionHandlerFactories.addAll(factory.getExceptionHandlerFactory());
+ externalContextFactories.addAll(factory.getExternalContextFactory());
+ facesContextFactories.addAll(factory.getFacesContextFactory());
+ lifecycleFactories.addAll(factory.getLifecycleFactory());
+ viewDeclarationLanguageFactories.addAll(factory.getViewDeclarationLanguageFactory());
+ partialViewContextFactories.addAll(factory.getPartialViewContextFactory());
+ renderKitFactories.addAll(factory.getRenderkitFactory());
+ tagHandlerDelegateFactories.addAll(factory.getTagHandlerDelegateFactory());
+ visitContextFactories.addAll(factory.getVisitContextFactory());
+ faceletCacheFactories.addAll(factory.getFaceletCacheFactory());
+ flashFactories.addAll(factory.getFlashFactory());
+ clientWindowFactories.addAll(factory.getClientWindowFactory());
+ flowHandlerFactories.addAll(factory.getFlowHandlerFactory());
+ searchExpressionContextFactories.addAll(factory.getSearchExpressionContextFactory());
+ }
+
+ for (Component component : config.getComponents())
+ {
+ components.put(component.getComponentType(), component);
+ }
+ validators.putAll(config.getValidators());
+ behaviors.addAll(config.getBehaviors());
+
+ for (Application application : config.getApplications())
+ {
+ if (!application.getDefaultRenderkitId().isEmpty())
+ {
+ defaultRenderKitId =
+ application.getDefaultRenderkitId().get(application.getDefaultRenderkitId().size() - 1);
+ }
+
+ if (!application.getMessageBundle().isEmpty())
+ {
+ messageBundle = application.getMessageBundle().get(application.getMessageBundle().size() - 1);
+ }
+
+ if (!application.getLocaleConfig().isEmpty())
+ {
+ localeConfig = application.getLocaleConfig().get(application.getLocaleConfig().size() - 1);
+ }
+
+ actionListeners.addAll(application.getActionListener());
+ navigationHandlers.addAll(application.getNavigationHandler());
+ resourceHandlers.addAll(application.getResourceHandler());
+ viewHandlers.addAll(application.getViewHandler());
+ stateManagers.addAll(application.getStateManager());
+ propertyResolver.addAll(application.getPropertyResolver());
+ variableResolver.addAll(application.getVariableResolver());
+ resourceBundles.addAll(application.getResourceBundle());
+ elResolvers.addAll(application.getElResolver());
+ resourceLibraryContractMappings.addAll(application.getResourceLibraryContractMappings());
+ searchExpressionHandlers.addAll(application.getSearchExpressionHandler());
+ searchKeywordResolvers.addAll(application.getSearchKeywordResolver());
+
+ // Jsf 2.0 spec section 3.5.3 says this:
+ // ".... Any configuration resource that declares a list of default
+ // validators overrides any list provided in a previously processed
+ // configuration resource. If an empty <default-validators/> element
+ // is found in a configuration resource, the list
+ // of default validators must be cleared....."
+ if (application.isDefaultValidatorsPresent())
+ {
+ // we have a <default-validators> element, so any existing
+ // default validators should be removed
+ defaultValidatorIds.clear();
+
+ // now add all default-validator entries (could be zero)
+ defaultValidatorIds.addAll(application.getDefaultValidatorIds());
+ }
+ else
+ {
+ //If isDefaultValidatorsPresent() is false, and there are still
+ //default validators, it means they were added using annotations, so
+ //they are not affected by the empty entry according to section 3.5.3
+ defaultAnnotatedValidatorIds.addAll(application.getDefaultValidatorIds());
+ }
+
+ systemEventListeners.addAll(application.getSystemEventListeners());
+ }
+
+ for (Converter converter : config.getConverters())
+ {
+ if (converter.getConverterId() != null)
+ {
+ converterById.put(converter.getConverterId(), converter.getConverterClass());
+ }
+ if (converter.getForClass() != null)
+ {
+ String oldConverter = converterByClass.get(converter.getForClass());
+ // don't log if someone overwrites the built-in converters
+ if (oldConverter != null && !oldConverter.startsWith("jakarta.faces.convert."))
+ {
+ log.warning("There is already a converter defined for class: " + converter.getForClass() + "."
+ + " old: " + oldConverter
+ + " new: " + converter.getConverterClass());
+ }
+
+ converterByClass.put(converter.getForClass(), converter.getConverterClass());
+ }
+
+ converterConfigurationByClassName.put(converter.getConverterClass(), converter);
+ }
+
+ for (RenderKit renderKit : config.getRenderKits())
+ {
+ String renderKitId = renderKit.getId();
+
+ if (renderKitId == null)
+ {
+ renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+
+ RenderKit existing = renderKits.get(renderKitId);
+
+ if (existing == null)
+ {
+ existing = new RenderKitImpl();
+ existing.merge(renderKit);
+ renderKits.put(renderKitId, existing);
+ }
+ else
+ {
+ existing.merge(renderKit);
+ }
+ }
+
+ for (FacesConfigExtension extension : config.getFacesConfigExtensions())
+ {
+ for (FaceletsProcessing faceletsProcessing : extension.getFaceletsProcessingList())
+ {
+ if (faceletsProcessing.getFileExtension() != null && faceletsProcessing.getFileExtension().length() > 0)
+ {
+ faceletsProcessingByFileExtension.put(faceletsProcessing.getFileExtension(), faceletsProcessing);
+ }
+ }
+ }
+
+ componentTagDeclarations.addAll(config.getComponentTagDeclarations().values());
+
+ faceletTagLibraries.addAll(config.getFaceletTagLibraryList());
+
+ lifecyclePhaseListeners.addAll(config.getLifecyclePhaseListener());
+ navigationRules.addAll(config.getNavigationRules());
+ facesVersion = config.getVersion();
+ namedEvents.addAll(config.getNamedEvents());
+ facesFlowDefinitions.addAll(config.getFacesFlowDefinitions());
+ protectedViewUrlPatterns.addAll(config.getProtectedViewsUrlPatternList());
+ resourceResolvers.addAll(config.getResourceResolversList());
+ for (FacesConfigExtension extension : config.getFacesConfigExtensions())
+ {
+ viewPoolMappings.addAll(extension.getViewPoolMappings());
+ }
+ for (FacesConfigExtension extension : config.getFacesConfigExtensions())
+ {
+ faceletsTemplateMappings.addAll(extension.getFaceletsTemplateMappings());
+ }
+ }
+
+ /**
+ * Add another ApplicationFactory class name
+ *
+ * @param factoryClassName a class name
+ */
+ @Override
+ public void feedApplicationFactory(String factoryClassName)
+ {
+ applicationFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedExceptionHandlerFactory(String factoryClassName)
+ {
+ exceptionHandlerFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedExternalContextFactory(String factoryClassName)
+ {
+ externalContextFactories.add(factoryClassName);
+ }
+
+ /**
+ * Add another FacesContextFactory class name
+ *
+ * @param factoryClassName a class name
+ */
+ @Override
+ public void feedFacesContextFactory(String factoryClassName)
+ {
+ facesContextFactories.add(factoryClassName);
+ }
+
+ /**
+ * Add another LifecycleFactory class name
+ *
+ * @param factoryClassName a class name
+ */
+ @Override
+ public void feedLifecycleFactory(String factoryClassName)
+ {
+ lifecycleFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedViewDeclarationLanguageFactory(String factoryClassName)
+ {
+ viewDeclarationLanguageFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedPartialViewContextFactory(String factoryClassName)
+ {
+ partialViewContextFactories.add(factoryClassName);
+ }
+
+ /**
+ * Add another RenderKitFactory class name
+ *
+ * @param factoryClassName a class name
+ */
+ @Override
+ public void feedRenderKitFactory(String factoryClassName)
+ {
+ renderKitFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedTagHandlerDelegateFactory(String factoryClassName)
+ {
+ tagHandlerDelegateFactories.add(factoryClassName);
+ }
+
+ @Override
+ public void feedVisitContextFactory(String factoryClassName)
+ {
+ visitContextFactories.add(factoryClassName);
+ }
+
+ /**
+ * @return Collection over ApplicationFactory class names
+ */
+ @Override
+ public Collection<String> getApplicationFactoryIterator()
+ {
+ if (umapplicationFactories == null)
+ {
+ umapplicationFactories = Collections.unmodifiableList(applicationFactories);
+ }
+ return umapplicationFactories;
+ }
+
+ @Override
+ public Collection<String> getExceptionHandlerFactoryIterator()
+ {
+ if (umexceptionHandlerFactories == null)
+ {
+ umexceptionHandlerFactories = Collections.unmodifiableList(exceptionHandlerFactories);
+ }
+ return umexceptionHandlerFactories;
+ }
+
+ @Override
+ public Collection<String> getExternalContextFactoryIterator()
+ {
+ if (umexternalContextFactories == null)
+ {
+ umexternalContextFactories = Collections.unmodifiableList(externalContextFactories);
+ }
+ return umexternalContextFactories;
+ }
+
+ /**
+ * @return Collection over FacesContextFactory class names
+ */
+ @Override
+ public Collection<String> getFacesContextFactoryIterator()
+ {
+ if (umfacesContextFactories == null)
+ {
+ umfacesContextFactories = Collections.unmodifiableList(facesContextFactories);
+ }
+ return umfacesContextFactories;
+ }
+
+ /**
+ * @return Collection over LifecycleFactory class names
+ */
+ @Override
+ public Collection<String> getLifecycleFactoryIterator()
+ {
+ if (umlifecycleFactories == null)
+ {
+ umlifecycleFactories = Collections.unmodifiableList(lifecycleFactories);
+ }
+ return umlifecycleFactories;
+ }
+
+ @Override
+ public Collection<String> getViewDeclarationLanguageFactoryIterator()
+ {
+ if (umviewDeclarationLanguageFactories == null)
+ {
+ umviewDeclarationLanguageFactories = Collections.unmodifiableList(viewDeclarationLanguageFactories);
+ }
+ return umviewDeclarationLanguageFactories;
+ }
+
+ @Override
+ public Collection<String> getPartialViewContextFactoryIterator()
+ {
+ if (umpartialViewContextFactories == null)
+ {
+ umpartialViewContextFactories = Collections.unmodifiableList(partialViewContextFactories);
+ }
+ return umpartialViewContextFactories;
+ }
+
+ /**
+ * @return Collection over RenderKit factory class names
+ */
+ @Override
+ public Collection<String> getRenderKitFactoryIterator()
+ {
+ if (umrenderKitFactories == null)
+ {
+ umrenderKitFactories = Collections.unmodifiableList(renderKitFactories);
+ }
+ return umrenderKitFactories;
+ }
+
+ @Override
+ public Collection<String> getTagHandlerDelegateFactoryIterator()
+ {
+ if (umtagHandlerDelegateFactories == null)
+ {
+ umtagHandlerDelegateFactories = Collections.unmodifiableList(tagHandlerDelegateFactories);
+ }
+ return umtagHandlerDelegateFactories;
+ }
+
+ @Override
+ public Collection<String> getVisitContextFactoryIterator()
+ {
+ if (umvisitContextFactories == null)
+ {
+ umvisitContextFactories = Collections.unmodifiableList(visitContextFactories);
+ }
+ return umvisitContextFactories;
+ }
+
+ /**
+ * @return Collection over ActionListener class names
+ */
+ @Override
+ public Collection<String> getActionListenerIterator()
+ {
+ if (umactionListeners == null)
+ {
+ umactionListeners = Collections.unmodifiableList(actionListeners);
+ }
+ return umactionListeners;
+ }
+
+ /**
+ * @return the default render kit id
+ */
+ @Override
+ public String getDefaultRenderKitId()
+ {
+ return defaultRenderKitId;
+ }
+
+ /**
+ * @return Collection over message bundle names
+ */
+ @Override
+ public String getMessageBundle()
+ {
+ return messageBundle;
+ }
+
+ /**
+ * @return Collection over NavigationHandler class names
+ */
+ @Override
+ public Collection<String> getNavigationHandlerIterator()
+ {
+ if (umnavigationHandlers == null)
+ {
+ umnavigationHandlers = Collections.unmodifiableList(navigationHandlers);
+ }
+ return umnavigationHandlers;
+ }
+
+ /**
+ * @return Collection over ResourceHandler class names
+ */
+ @Override
+ public Collection<String> getResourceHandlerIterator()
+ {
+ if (umresourceHandlers == null)
+ {
+ umresourceHandlers = Collections.unmodifiableList(resourceHandlers);
+ }
+ return umresourceHandlers;
+ }
+
+ /**
+ * @return Collection over ViewHandler class names
+ */
+ @Override
+ public Collection<String> getViewHandlerIterator()
+ {
+ if (umviewHandlers == null)
+ {
+ umviewHandlers = Collections.unmodifiableList(viewHandlers);
+ }
+ return umviewHandlers;
+ }
+
+ /**
+ * @return Collection over StateManager class names
+ */
+ @Override
+ public Collection<String> getStateManagerIterator()
+ {
+ if (umstateManagers == null)
+ {
+ umstateManagers = Collections.unmodifiableList(stateManagers);
+ }
+ return umstateManagers;
+ }
+
+ /**
+ * @return Collection over PropertyResolver class names
+ */
+ @Override
+ public Collection<String> getPropertyResolverIterator()
+ {
+ if (umpropertyResolver == null)
+ {
+ umpropertyResolver = Collections.unmodifiableList(propertyResolver);
+ }
+ return umpropertyResolver;
+ }
+
+ /**
+ * @return Collection over VariableResolver class names
+ */
+ @Override
+ public Collection<String> getVariableResolverIterator()
+ {
+ if (umvariableResolver == null)
+ {
+ umvariableResolver = Collections.unmodifiableList(variableResolver);
+ }
+ return umvariableResolver;
+ }
+
+ /**
+ * @return the default locale name
+ */
+ @Override
+ public String getDefaultLocale()
+ {
+ if (localeConfig != null)
+ {
+ return localeConfig.getDefaultLocale();
+ }
+ return null;
+ }
+
+ /**
+ * @return Collection over supported locale names
+ */
+ @Override
+ public Collection<String> getSupportedLocalesIterator()
+ {
+ Collection<String> locale;
+ if (localeConfig != null)
+ {
+ locale = Collections.unmodifiableCollection(localeConfig.getSupportedLocales());
+ }
+ else
+ {
+ locale = Collections.emptyList();
+ }
+
+ return locale;
+ }
+
+ /**
+ * @return Collection over all defined component types
+ */
+ @Override
+ public Collection<String> getComponentTypes()
+ {
+ return Collections.unmodifiableCollection(components.keySet());
+ }
+
+ @Override
+ public Map<String, Component> getComponentsByType()
+ {
+ return Collections.unmodifiableMap(components);
+ }
+
+ /**
+ * @return component class that belongs to the given component type
+ */
+ @Override
+ public String getComponentClass(String componentType)
+ {
+ Component component = components.get(componentType);
+ return component == null ? null : component.getComponentClass();
+ }
+
+ /**
+ * @return Collection over all defined converter ids
+ */
+ @Override
+ public Collection<String> getConverterIds()
+ {
+ return Collections.unmodifiableCollection(converterById.keySet());
+ }
+
+ @Override
+ public Map<String, String> getConverterClassesById()
+ {
+ return Collections.unmodifiableMap(converterById);
+ }
+
+ /**
+ * @return Collection over all classes with an associated converter
+ */
+ @Override
+ public Collection<String> getConverterClasses()
+ {
+ return Collections.unmodifiableCollection(converterByClass.keySet());
+ }
+
+ @Override
+ public Map<String, String> getConverterClassesByClass()
+ {
+ return Collections.unmodifiableMap(converterByClass);
+ }
+
+ @Override
+ public Collection<String> getConverterConfigurationByClassName()
+ {
+ return Collections.unmodifiableCollection(converterConfigurationByClassName.keySet());
+ }
+
+ @Override
+ public Converter getConverterConfiguration(String converterClassName)
+ {
+ return converterConfigurationByClassName.get(converterClassName);
+ }
+
+ /**
+ * @return converter class that belongs to the given converter id
+ */
+ @Override
+ public String getConverterClassById(String converterId)
+ {
+ return converterById.get(converterId);
+ }
+
+ /**
+ * @return converter class that is associated with the given class name
+ */
+ @Override
+ public String getConverterClassByClass(String className)
+ {
+ return converterByClass.get(className);
+ }
+
+ /**
+ * @return Collection over all defined default validator ids
+ */
+ @Override
+ public Collection<String> getDefaultValidatorIds ()
+ {
+ List<String> allDefaultValidatorIds = new ArrayList<>();
+ allDefaultValidatorIds.addAll(defaultAnnotatedValidatorIds);
+ allDefaultValidatorIds.addAll(defaultValidatorIds);
+ return Collections.unmodifiableCollection(allDefaultValidatorIds);
+ }
+
+ /**
+ * @return Collection over all defined validator ids
+ */
+ @Override
+ public Collection<String> getValidatorIds()
+ {
+ return Collections.unmodifiableCollection(validators.keySet());
+ }
+
+ @Override
+ public Map<String, String> getValidatorClassesById()
+ {
+ return Collections.unmodifiableMap(validators);
+ }
+
+ /**
+ * @return validator class name that belongs to the given validator id
+ */
+ @Override
+ public String getValidatorClass(String validatorId)
+ {
+ return validators.get(validatorId);
+ }
+
+ /**
+ * @return Collection over {@link org.apache.myfaces.config.element.NavigationRule NavigationRule}s
+ */
+ @Override
+ public Collection<NavigationRule> getNavigationRules()
+ {
+ if (umnavigationRules == null)
+ {
+ umnavigationRules = Collections.unmodifiableList(navigationRules);
+ }
+ return umnavigationRules;
+ }
+
+ /**
+ * @return Collection over all defined renderkit ids
+ */
+ @Override
+ public Collection<String> getRenderKitIds()
+ {
+ return Collections.unmodifiableCollection(renderKits.keySet());
+ }
+
+ /**
+ * @return renderkit class name for given renderkit id
+ */
+ @Override
+ public Collection<String> getRenderKitClasses(String renderKitId)
+ {
+ return renderKits.get(renderKitId).getRenderKitClasses();
+ }
+
+ /**
+ * @return Iterator over
+ * {@link org.apache.myfaces.config.element.ClientBehaviorRenderer ClientBehaviorRenderer}s
+ * for the given renderKitId
+ */
+ @Override
+ public Collection<ClientBehaviorRenderer> getClientBehaviorRenderers (String renderKitId)
+ {
+ return renderKits.get (renderKitId).getClientBehaviorRenderers();
+ }
+
+ /**
+ * @return Collection over {@link org.apache.myfaces.config.element.Renderer Renderer}s for the given renderKitId
+ */
+ @Override
+ public Collection<Renderer> getRenderers(String renderKitId)
+ {
+ return renderKits.get(renderKitId).getRenderer();
+ }
+
+ /**
+ * @return Collection over {@link jakarta.faces.event.PhaseListener} implementation class names
+ */
+ @Override
+ public Collection<String> getLifecyclePhaseListeners()
+ {
+ if (umlifecyclePhaseListeners == null)
+ {
+ umlifecyclePhaseListeners = Collections.unmodifiableList(lifecyclePhaseListeners);
+ }
+ return umlifecyclePhaseListeners;
+ }
+
+ @Override
+ public Collection<ResourceBundle> getResourceBundles()
+ {
+ if (umresourceBundles == null)
+ {
+ umresourceBundles = Collections.unmodifiableList(resourceBundles);
+ }
+ return umresourceBundles;
+ }
+
+ @Override
+ public Collection<String> getElResolvers()
+ {
+ if (umelResolvers == null)
+ {
+ umelResolvers = Collections.unmodifiableList(elResolvers);
+ }
+ return umelResolvers;
+ }
+
+ @Override
+ public Collection<SystemEventListener> getSystemEventListeners()
+ {
+ if (umsystemEventListeners == null)
+ {
+ umsystemEventListeners = Collections.unmodifiableList(systemEventListeners);
+ }
+ return umsystemEventListeners;
+ }
+
+ @Override
+ public Collection<Behavior> getBehaviors()
+ {
+ if (umbehaviors == null)
+ {
+ umbehaviors = Collections.unmodifiableList(behaviors);
+ }
+ return umbehaviors;
+ }
+
+ @Override
+ public String getFacesVersion()
+ {
+ return facesVersion;
+ }
+
+ @Override
+ public Collection<NamedEvent> getNamedEvents()
+ {
+ if (umnamedEvents == null)
+ {
+ umnamedEvents = Collections.unmodifiableList(namedEvents);
+ }
+ return umnamedEvents;
+ }
+
+ @Override
+ public Collection<FaceletsProcessing> getFaceletsProcessing()
+ {
+ return Collections.unmodifiableCollection(faceletsProcessingByFileExtension.values());
+ }
+
+ @Override
+ public FaceletsProcessing getFaceletsProcessingConfiguration(String fileExtension)
+ {
+ return faceletsProcessingByFileExtension.get(fileExtension);
+ }
+
+ @Override
+ public void feedFaceletCacheFactory(String factoryClassName)
+ {
+ faceletCacheFactories.add(factoryClassName);
+ }
+
+ @Override
+ public Collection<String> getFaceletCacheFactoryIterator()
+ {
+ if (umfaceletCacheFactories == null)
+ {
+ umfaceletCacheFactories = Collections.unmodifiableList(faceletCacheFactories);
+ }
+ return umfaceletCacheFactories;
+ }
+
+ @Override
+ public void feedFlashFactory(String factoryClassName)
+ {
+ flashFactories.add(factoryClassName);
+ }
+
+ @Override
+ public Collection<String> getFlashFactoryIterator()
+ {
+ if (umflashFactories == null)
+ {
+ umflashFactories = Collections.unmodifiableList(flashFactories);
+ }
+ return umflashFactories;
+ }
+
+ @Override
+ public Collection<String> getFlowHandlerFactoryIterator()
+ {
+ if (umflowHandlerFactories == null)
+ {
+ umflowHandlerFactories = Collections.unmodifiableList(flowHandlerFactories);
+ }
+ return umflowHandlerFactories;
+ }
+
+ @Override
+ public void feedClientWindowFactory(String factoryClassName)
+ {
+ clientWindowFactories.add(factoryClassName);
+ }
+
+ @Override
+ public Collection<String> getClientWindowFactoryIterator()
+ {
+ if (umclientWindowFactories == null)
+ {
+ umclientWindowFactories = Collections.unmodifiableList(clientWindowFactories);
+ }
+ return umclientWindowFactories;
+ }
+
+ @Override
+ public Collection<FacesFlowDefinition> getFacesFlowDefinitions()
+ {
+ if (umfacesFlowDefinitions == null)
+ {
+ umfacesFlowDefinitions = Collections.unmodifiableList(facesFlowDefinitions);
+ }
+ return umfacesFlowDefinitions;
+ }
+
+ @Override
+ public Collection<String> getProtectedViewUrlPatterns()
+ {
+ if (umprotectedViewUrlPatterns == null)
+ {
+ umprotectedViewUrlPatterns = Collections.unmodifiableList(protectedViewUrlPatterns);
+ }
+ return umprotectedViewUrlPatterns;
+ }
+
+ @Override
+ public Collection<ContractMapping> getResourceLibraryContractMappings()
+ {
+ if (umresourceLibraryContractMappings == null)
+ {
+ umresourceLibraryContractMappings = Collections.unmodifiableList(resourceLibraryContractMappings);
+ }
+ return umresourceLibraryContractMappings;
+ }
+
+ @Override
+ public Collection<ComponentTagDeclaration> getComponentTagDeclarations()
+ {
+ if (umcomponentTagDeclarations == null)
+ {
+ umcomponentTagDeclarations = Collections.unmodifiableList(componentTagDeclarations);
+ }
+ return umcomponentTagDeclarations;
+ }
+
+ @Override
+ public Collection<String> getResourceResolvers()
+ {
+ if (umresourceResolvers == null)
+ {
+ umresourceResolvers = Collections.unmodifiableList(resourceResolvers);
+ }
+ return umresourceResolvers;
+ }
+
+ @Override
+ public Collection<FaceletTagLibrary> getTagLibraries()
+ {
+ if (umfaceletTagLibraries == null)
+ {
+ umfaceletTagLibraries = Collections.unmodifiableList(faceletTagLibraries);
+ }
+ return umfaceletTagLibraries;
+ }
+
+ @Override
+ public Collection<ViewPoolMapping> getViewPoolMappings()
+ {
+ if (umviewPoolMappings == null)
+ {
+ umviewPoolMappings = Collections.unmodifiableList(viewPoolMappings);
+ }
+ return umviewPoolMappings;
+ }
+
+ @Override
+ public void feedSearchExpressionContextFactory(String factoryClassName)
+ {
+ searchExpressionContextFactories.add(factoryClassName);
+ }
+
+ @Override
+ public Collection<String> getSearchExpressionContextFactoryIterator()
+ {
+ if (umsearchExpressionContextFactories == null)
+ {
+ umsearchExpressionContextFactories = Collections.unmodifiableList(searchExpressionContextFactories);
+ }
+ return umsearchExpressionContextFactories;
+ }
+
+ @Override
+ public Collection<String> getSearchKeywordResolvers()
+ {
+ if (umsearchKeywordResolvers == null)
+ {
+ umsearchKeywordResolvers = Collections.unmodifiableList(searchKeywordResolvers);
+ }
+ return umsearchKeywordResolvers;
+ }
+
+ @Override
+ public Collection<String> getSearchExpressionHandlerIterator()
+ {
+ if (umsearchExpressionHandlers == null)
+ {
+ umsearchExpressionHandlers = Collections.unmodifiableList(searchExpressionHandlers);
+ }
+ return umsearchExpressionHandlers;
+ }
+
+ @Override
+ public Collection<FaceletsTemplateMapping> getFaceletsTemplateMappings()
+ {
+ if (umfaceletsTemplateMappings == null)
+ {
+ umfaceletsTemplateMappings = Collections.unmodifiableList(faceletsTemplateMappings);
+ }
+ return umfaceletsTemplateMappings;
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
index ffa53b7..84cd5d1 100755
--- a/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/FacesConfigUnmarshallerImpl.java
@@ -1,765 +1,765 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.impl;
-
-import java.io.ByteArrayInputStream;
-import jakarta.faces.context.ExternalContext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.function.Consumer;
-import jakarta.faces.FacesException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.myfaces.config.FacesConfigUnmarshaller;
-import org.apache.myfaces.config.element.FacesFlowDefinition;
-import org.apache.myfaces.config.impl.element.AbsoluteOrderingImpl;
-import org.apache.myfaces.config.impl.element.ApplicationImpl;
-import org.apache.myfaces.config.impl.element.AttributeImpl;
-import org.apache.myfaces.config.impl.element.BehaviorImpl;
-import org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl;
-import org.apache.myfaces.config.impl.element.ComponentImpl;
-import org.apache.myfaces.config.impl.element.ConfigOthersSlotImpl;
-import org.apache.myfaces.config.impl.element.ContractMappingImpl;
-import org.apache.myfaces.config.impl.element.ConverterImpl;
-import org.apache.myfaces.config.impl.element.FaceletsProcessingImpl;
-import org.apache.myfaces.config.impl.element.FaceletsTemplateMappingImpl;
-import org.apache.myfaces.config.impl.element.FacesConfigExtensionImpl;
-import org.apache.myfaces.config.impl.element.FacesConfigImpl;
-import org.apache.myfaces.config.impl.element.FacesConfigNameSlotImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowCallImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowDefinitionImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowMethodCallImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowMethodParameterImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowParameterImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowReferenceImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowReturnImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowSwitchImpl;
-import org.apache.myfaces.config.impl.element.FacesFlowViewImpl;
-import org.apache.myfaces.config.impl.element.FactoryImpl;
-import org.apache.myfaces.config.impl.element.LocaleConfigImpl;
-import org.apache.myfaces.config.impl.element.NavigationCaseImpl;
-import org.apache.myfaces.config.impl.element.NavigationRuleImpl;
-import org.apache.myfaces.config.impl.element.OrderingImpl;
-import org.apache.myfaces.config.impl.element.PropertyImpl;
-import org.apache.myfaces.config.impl.element.RedirectImpl;
-import org.apache.myfaces.config.impl.element.RenderKitImpl;
-import org.apache.myfaces.config.impl.element.RendererImpl;
-import org.apache.myfaces.config.impl.element.ResourceBundleImpl;
-import org.apache.myfaces.config.impl.element.SystemEventListenerImpl;
-import org.apache.myfaces.config.impl.element.ViewParamImpl;
-import org.apache.myfaces.config.impl.element.ViewPoolMappingImpl;
-import org.apache.myfaces.config.impl.element.ViewPoolParameterImpl;
-import org.apache.myfaces.util.lang.StringUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-public class FacesConfigUnmarshallerImpl implements FacesConfigUnmarshaller<FacesConfigImpl>
-{
- private static final Logger log = Logger.getLogger(FacesConfigUnmarshallerImpl.class.getName());
-
- private ExternalContext externalContext;
-
- public FacesConfigUnmarshallerImpl(ExternalContext externalContext)
- {
- this.externalContext = externalContext;
- }
-
- @Override
- public FacesConfigImpl getFacesConfig(String s) throws IOException, SAXException
- {
- return getFacesConfig(new ByteArrayInputStream(s.getBytes()), null);
- }
-
- @Override
- public FacesConfigImpl getFacesConfig(InputStream in, String systemId) throws IOException, SAXException
- {
- FacesConfigImpl facesConfig = new FacesConfigImpl();
-
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
-
- try
- {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
- factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
- factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- factory.setXIncludeAware(false);
- factory.setExpandEntityReferences(false);
- }
- catch (Throwable e)
- {
- log.log(Level.WARNING, "DocumentBuilderFactory#setFeature not implemented. Skipping...", e);
- }
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- builder.setEntityResolver(new FacesConfigEntityResolver(externalContext));
- Document document;
- if (systemId == null)
- {
- document = builder.parse(in);
- }
- else
- {
- document = builder.parse(in, systemId);
- }
- document.getDocumentElement().normalize();
-
- onAttribute("metadata-complete", document.getDocumentElement(),
- (v) -> { facesConfig.setMetadataComplete(v); });
- onAttribute("version", document.getDocumentElement(),
- (v) -> { facesConfig.setVersion(v); });
-
- onChild("name", document.getDocumentElement(),
- (n) -> { facesConfig.setName(getTextContent(n)); });
- onChild("ordering", document.getDocumentElement(),
- (n) -> { facesConfig.setOrdering(processOrdering(n)); });
- onChild("absolute-ordering", document.getDocumentElement(),
- (n) -> { facesConfig.setAbsoluteOrdering(processAbsoluteOrdering(n)); });
- onChild("application", document.getDocumentElement(),
- (n) -> { facesConfig.addApplication(processApplication(n)); });
- onChild("factory", document.getDocumentElement(),
- (n) -> { facesConfig.addFactory(processFactory(n)); });
- onChild("component", document.getDocumentElement(),
- (n) -> { facesConfig.addComponent(processComponent(n)); });
- onChild("lifecycle", document.getDocumentElement(), (n) -> {
- onChild("phase-listener", n, (cn) -> {
- facesConfig.addLifecyclePhaseListener(getTextContent(cn));
- });
- });
- onChild("validator", document.getDocumentElement(), (n) -> {
- facesConfig.addValidator(
- firstChildTextContent("validator-id", n),
- firstChildTextContent("validator-class", n));
- });
- onChild("render-kit", document.getDocumentElement(),
- (n) -> { facesConfig.addRenderKit(processRenderKit(n)); });
- onChild("behavior", document.getDocumentElement(),
- (n) -> { facesConfig.addBehavior(processBehavior(n)); });
- onChild("converter", document.getDocumentElement(),
- (n) -> { facesConfig.addConverter(processConverter(n)); });
- onChild("protected-views", document.getDocumentElement(), (n) -> {
- onChild("url-pattern", n, (cn) -> {
- facesConfig.addProtectedViewUrlPattern(getTextContent(cn));
- });
- });
- onChild("faces-config-extension", document.getDocumentElement(),
- (n) -> { facesConfig.addFacesConfigExtension(processFacesConfigExtension(n)); });
- onChild("navigation-rule", document.getDocumentElement(),
- (n) -> { facesConfig.addNavigationRule(processNavigationRule(n)); });
- onChild("flow-definition", document.getDocumentElement(),
- (n) -> { facesConfig.addFacesFlowDefinition(processFlowDefinition(n)); });
-
- }
- catch (Exception e)
- {
- throw new FacesException(e);
- }
- finally
- {
- try
- {
- in.close();
- }
- catch (IOException e)
- {
- // ignore silently
- }
- }
-
- postProcessFacesConfig(systemId, facesConfig);
-
- return facesConfig;
- }
-
- private void postProcessFacesConfig(String systemId, FacesConfigImpl config)
- {
- for (org.apache.myfaces.config.element.Application application : config.getApplications())
- {
- for (org.apache.myfaces.config.element.LocaleConfig localeConfig : application.getLocaleConfig())
- {
- if (!localeConfig.getSupportedLocales().contains(localeConfig.getDefaultLocale()))
- {
- localeConfig.addSupportedLocale(localeConfig.getDefaultLocale());
- }
- }
- }
-
- for (FacesFlowDefinition facesFlowDefinition : config.getFacesFlowDefinitions())
- {
- // JSF 2.2 section 11.4.3.1 says this: "... Flows are defined using the
- // <flow-definition> element. This element must have an id attribute which uniquely
- // identifies the flow within the scope of the Application Configuration Resource
- // file in which the element appears. To enable multiple flows with the same id to
- // exist in an application, the <faces-config><name> element is taken to
- // be the definingDocumentId of the flow. If no <name> element is specified,
- // the empty string is taken as the value for definingDocumentId. ..."
- if (config.getName() != null)
- {
- ((FacesFlowDefinitionImpl)facesFlowDefinition).setDefiningDocumentId(
- config.getName());
- }
- else
- {
- ((FacesFlowDefinitionImpl)facesFlowDefinition).setDefiningDocumentId("");
- }
- }
- }
-
- protected OrderingImpl processOrdering(Node node)
- {
- OrderingImpl obj = new OrderingImpl();
-
- onChild("before", node, (n) -> {
- onChild("name", n, (cn) -> {
- obj.addBeforeSlot(new FacesConfigNameSlotImpl(getTextContent(cn)));
- });
- onChild("others", n, (cn) -> {
- obj.addBeforeSlot(new ConfigOthersSlotImpl());
- });
- });
-
- onChild("after", node, (n) -> {
- onChild("name", n, (cn) -> {
- obj.addAfterSlot(new FacesConfigNameSlotImpl(getTextContent(cn)));
- });
- onChild("others", n, (cn) -> {
- obj.addAfterSlot(new ConfigOthersSlotImpl());
- });
- });
-
- return obj;
- }
-
- protected AbsoluteOrderingImpl processAbsoluteOrdering(Node node)
- {
- AbsoluteOrderingImpl obj = new AbsoluteOrderingImpl();
-
- forEachChild(node, (n) -> {
- if ("name".equals(n.getLocalName()))
- {
- FacesConfigNameSlotImpl slot = new FacesConfigNameSlotImpl();
- slot.setName(getTextContent(n));
- obj.addOrderSlot(slot);
- }
- else if ("others".equals(n.getLocalName()))
- {
- obj.addOrderSlot(new ConfigOthersSlotImpl());
- }
- });
-
- return obj;
- }
-
- protected ApplicationImpl processApplication(Node node)
- {
- ApplicationImpl obj = new ApplicationImpl();
-
- onChild("action-listener", node, (n) -> { obj.addActionListener(getTextContent(n)); });
- onChild("message-bundle", node, (n) -> { obj.addMessageBundle(getTextContent(n)); });
- onChild("navigation-handler", node, (n) -> { obj.addNavigationHandler(getTextContent(n)); });
- onChild("view-handler", node, (n) -> { obj.addViewHandler(getTextContent(n)); });
- onChild("state-manager", node, (n) -> { obj.addStateManager(getTextContent(n)); });
- onChild("property-resolver", node, (n) -> { obj.addPropertyResolver(getTextContent(n)); });
- onChild("variable-resolver", node, (n) -> { obj.addVariableResolver(getTextContent(n)); });
- onChild("el-resolver", node, (n) -> { obj.addElResolver(getTextContent(n)); });
- onChild("resource-handler", node, (n) -> { obj.addResourceHandler(getTextContent(n)); });
- onChild("default-render-kit-id", node, (n) -> { obj.addDefaultRenderkitId(getTextContent(n)); });
- onChild("search-expression-handler", node, (n) -> { obj.addSearchExpressionHandler(getTextContent(n)); });
- onChild("search-keyword-resolver", node, (n) -> { obj.addSearchKeywordResolver(getTextContent(n)); });
-
- onChild("default-validators", node, (n) -> {
- obj.setDefaultValidatorsPresent();
- onChild("validator-id", n, (cn) -> {
- obj.addDefaultValidatorId(getTextContent(cn));
- });
- });
-
- onChild("locale-config", node, (n) -> {
- LocaleConfigImpl lc = new LocaleConfigImpl();
- onChild("default-locale", n, (cn) -> { lc.setDefaultLocale(getTextContent(cn)); });
- onChild("supported-locale", n, (cn) -> { lc.addSupportedLocale(getTextContent(cn)); });
- obj.addLocaleConfig(lc);
- });
-
- onChild("resource-bundle", node, (n) -> {
- ResourceBundleImpl rb = new ResourceBundleImpl();
- onChild("base-name", n, (cn) -> { rb.setBaseName(getTextContent(cn)); });
- onChild("var", n, (cn) -> { rb.setVar(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { rb.setDisplayName(getTextContent(cn)); });
- obj.addResourceBundle(rb);
- });
-
- onChild("system-event-listener", node, (n) -> {
- SystemEventListenerImpl sel = new SystemEventListenerImpl();
- onChild("system-event-listener-class", n, (cn) -> {
- sel.setSystemEventListenerClass(getTextContent(cn));
- });
- onChild("system-event-class", n, (cn) -> {
- sel.setSystemEventClass(getTextContent(cn));
- });
- onChild("source-class", n, (cn) -> {
- sel.setSourceClass(getTextContent(cn));
- });
- obj.addSystemEventListener(sel);
- });
-
- onChild("resource-library-contracts", node, (n) -> {
- onChild("contract-mapping", n, (cn) -> {
- ContractMappingImpl cm = new ContractMappingImpl();
- onChild("url-pattern", cn, (ccn) -> {
- cm.addUrlPattern(getTextContent(ccn));
- });
- onChild("contracts", cn, (ccn) -> {
- cm.addContract(getTextContent(ccn));
- });
- obj.addResourceLibraryContractMapping(cm);
- });
- });
-
- return obj;
- }
-
- protected FactoryImpl processFactory(Node node)
- {
- FactoryImpl obj = new FactoryImpl();
-
- onChild("application-factory", node, (n) -> { obj.addApplicationFactory(getTextContent(n)); });
- onChild("faces-context-factory", node, (n) -> { obj.addFacesContextFactory(getTextContent(n)); });
- onChild("lifecycle-factory", node, (n) -> { obj.addLifecycleFactory(getTextContent(n)); });
- onChild("render-kit-factory", node, (n) -> { obj.addRenderkitFactory(getTextContent(n)); });
- onChild("exception-handler-factory", node, (n) -> { obj.addExceptionHandlerFactory(getTextContent(n)); });
- onChild("external-context-factory", node, (n) -> { obj.addExternalContextFactory(getTextContent(n)); });
- onChild("view-declaration-language-factory", node, (n) -> {
- obj.addViewDeclarationLanguageFactory(getTextContent(n));
- });
- onChild("partial-view-context-factory", node, (n) -> {
- obj.addPartialViewContextFactory(getTextContent(n));
- });
- onChild("tag-handler-delegate-factory", node, (n) -> {
- obj.addTagHandlerDelegateFactory(getTextContent(n));
- });
- onChild("visit-context-factory", node, (n) -> { obj.addVisitContextFactory(getTextContent(n)); });
- onChild("search-expression-context-factory", node, (n) -> {
- obj.addSearchExpressionContextFactory(getTextContent(n));
- });
- onChild("facelet-cache-factory", node, (n) -> { obj.addFaceletCacheFactory(getTextContent(n)); });
- onChild("flash-factory", node, (n) -> { obj.addFlashFactory(getTextContent(n)); });
- onChild("flow-handler-factory", node, (n) -> { obj.addFlowHandlerFactory(getTextContent(n)); });
- onChild("client-window-factory", node, (n) -> { obj.addClientWindowFactory(getTextContent(n)); });
-
- return obj;
- }
-
- protected RenderKitImpl processRenderKit(Node node)
- {
- RenderKitImpl obj = new RenderKitImpl();
-
- onChild("render-kit-id", node, (n) -> { obj.setId(getTextContent(n)); });
- onChild("render-kit-class", node, (n) -> { obj.addRenderKitClass(getTextContent(n)); });
-
- onChild("renderer", node, (n) -> {
- RendererImpl r = new RendererImpl();
- onChild("component-family", n, (cn) -> { r.setComponentFamily(getTextContent(cn)); });
- onChild("renderer-type", n, (cn) -> { r.setRendererType(getTextContent(cn)); });
- onChild("renderer-class", n, (cn) -> { r.setRendererClass(getTextContent(cn)); });
- obj.addRenderer(r);
- });
-
- onChild("client-behavior-renderer", node, (n) -> {
- ClientBehaviorRendererImpl r = new ClientBehaviorRendererImpl();
- onChild("client-behavior-renderer-type", n, (cn) -> { r.setRendererType(getTextContent(cn)); });
- onChild("client-behavior-renderer-class", n, (cn) -> { r.setRendererClass(getTextContent(cn)); });
- obj.addClientBehaviorRenderer(r);
- });
-
- return obj;
- }
-
- protected ComponentImpl processComponent(Node node)
- {
- ComponentImpl obj = new ComponentImpl();
-
- onChild("component-type", node, (n) -> { obj.setComponentType(getTextContent(n)); });
- onChild("component-class", node, (n) -> { obj.setComponentClass(getTextContent(n)); });
-
- onChild("attribute", node, (n) -> {
- AttributeImpl a = new AttributeImpl();
- onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
- onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
- onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
- onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
- obj.addAttribute(a);
- });
-
- onChild("property", node, (n) -> {
- PropertyImpl p = new PropertyImpl();
- onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
- onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
- onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
- onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
- obj.addProperty(p);
- });
-
- return obj;
- }
-
- protected BehaviorImpl processBehavior(Node node)
- {
- BehaviorImpl obj = new BehaviorImpl();
-
- onChild("behavior-id", node, (n) -> { obj.setBehaviorId(getTextContent(n)); });
- onChild("behavior-class", node, (n) -> { obj.setBehaviorClass(getTextContent(n)); });
-
- onChild("attribute", node, (n) -> {
- AttributeImpl a = new AttributeImpl();
- onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
- onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
- onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
- onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
- obj.addAttribute(a);
- });
-
- onChild("property", node, (n) -> {
- PropertyImpl p = new PropertyImpl();
- onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
- onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
- onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
- onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
- obj.addProperty(p);
- });
-
- return obj;
- }
-
- protected ConverterImpl processConverter(Node node)
- {
- ConverterImpl obj = new ConverterImpl();
-
- onChild("converter-id", node, (n) -> { obj.setConverterId(getTextContent(n)); });
- onChild("converter-for-class", node, (n) -> { obj.setForClass(getTextContent(n)); });
- onChild("converter-class", node, (n) -> { obj.setConverterClass(getTextContent(n)); });
-
- onChild("attribute", node, (n) -> {
- AttributeImpl a = new AttributeImpl();
- onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
- onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
- onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
- onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
- obj.addAttribute(a);
- });
-
- onChild("property", node, (n) -> {
- PropertyImpl p = new PropertyImpl();
- onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
- onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
- onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
- onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
- onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
- onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
- onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
- onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
- obj.addProperty(p);
- });
-
- return obj;
- }
-
- protected FacesConfigExtensionImpl processFacesConfigExtension(Node node)
- {
- FacesConfigExtensionImpl obj = new FacesConfigExtensionImpl();
-
- onChild("facelets-processing", node, (n) -> {
- FaceletsProcessingImpl fp = new FaceletsProcessingImpl();
- onChild("file-extension", n, (cn) -> { fp.setFileExtension(getTextContent(cn)); });
- onChild("process-as", n, (cn) -> { fp.setProcessAs(getTextContent(cn)); });
- onChild("oam-compress-spaces", n, (cn) -> { fp.setOamCompressSpaces(getTextContent(cn)); });
- obj.addFaceletsProcessing(fp);
- });
-
- onChild("view-pool-mapping", node, (n) -> {
- ViewPoolMappingImpl vpm = new ViewPoolMappingImpl();
- onChild("url-pattern", n, (cn) -> { vpm.setUrlPattern(getTextContent(cn)); });
- onChild("parameter", n, (cn) -> {
- ViewPoolParameterImpl vpp = new ViewPoolParameterImpl();
- onChild("name", cn, (ccn) -> { vpp.setName(getTextContent(ccn)); });
- onChild("value", cn, (ccn) -> { vpp.setValue(getTextContent(ccn)); });
- vpm.addParameter(vpp);
- });
- obj.addViewPoolMapping(vpm);
- });
-
- onChild("facelets-template-mapping", node, (n) -> {
- FaceletsTemplateMappingImpl ftm = new FaceletsTemplateMappingImpl();
- onChild("url-pattern", n, (cn) -> { ftm.setUrlPattern(getTextContent(cn)); });
- obj.addFaceletsTemplateMapping(ftm);
- });
-
- return obj;
- }
-
- protected NavigationRuleImpl processNavigationRule(Node node)
- {
- NavigationRuleImpl obj = new NavigationRuleImpl();
-
- onChild("from-view-id", node, (n) -> { obj.setFromViewId(getTextContent(n)); });
-
- onChild("navigation-case", node, (n) -> {
- obj.addNavigationCase(processNavigationCase(n));
- });
-
- return obj;
- }
-
- protected FacesFlowDefinitionImpl processFlowDefinition(Node node)
- {
- FacesFlowDefinitionImpl obj = new FacesFlowDefinitionImpl();
-
- onAttribute("id", node, (v) -> { obj.setId(v); });
- onChild("start-node", node, (n) -> { obj.setStartNode(getTextContent(n)); });
- onChild("initializer", node, (n) -> { obj.setInitializer(getTextContent(n)); });
- onChild("finalizer", node, (n) -> { obj.setFinalizer(getTextContent(n)); });
-
- onChild("view", node, (n) -> {
- FacesFlowViewImpl ffv = new FacesFlowViewImpl();
- onAttribute("id", n, (v) -> { ffv.setId(v); });
- onChild("vdl-document", n, (cn) -> { ffv.setVdlDocument(getTextContent(cn)); });
- obj.addView(ffv);
- });
-
- onChild("switch", node, (n) -> {
- FacesFlowSwitchImpl ffs = new FacesFlowSwitchImpl();
- onAttribute("id", n, (v) -> { ffs.setId(v); });
- onChild("case", n, (cn) -> { ffs.addNavigationCase(processNavigationCase(cn)); });
- onChild("default-outcome", n, (cn) -> {
- NavigationCaseImpl nc = new NavigationCaseImpl();
- nc.setFromAction(getTextContent(cn));
- ffs.setDefaultOutcome(nc);
- });
- obj.addSwitch(ffs);
- });
-
- onChild("flow-return", node, (n) -> {
- FacesFlowReturnImpl ffr = new FacesFlowReturnImpl();
- onAttribute("id", n, (v) -> { ffr.setId(v); });
- onChild("from-outcome", n, (cn) -> {
- NavigationCaseImpl nc = new NavigationCaseImpl();
- nc.setFromOutcome(getTextContent(cn));
- ffr.setNavigationCase(nc);
- });
- obj.addReturn(ffr);
- });
-
- onChild("navigation-rule", node, (n) -> {
- NavigationRuleImpl nr = new NavigationRuleImpl();
- onChild("from-view-id", n, (cn) -> { nr.setFromViewId(getTextContent(cn)); });
- onChild("navigation-case", n, (cn) -> { nr.addNavigationCase(processNavigationCase(cn)); });
- obj.addNavigationRule(nr);
- });
-
- onChild("flow-call", node, (n) -> {
- FacesFlowCallImpl ffc = new FacesFlowCallImpl();
- onAttribute("id", n, (v) -> { ffc.setId(v); });
- onChild("flow-reference", n, (cn) -> {
- FacesFlowReferenceImpl ffr = new FacesFlowReferenceImpl();
- onChild("flow-document-id", cn, (ccn) -> { ffr.setFlowDocumentId(getTextContent(ccn)); });
- onChild("flow-id", cn, (ccn) -> { ffr.setFlowId(getTextContent(ccn)); });
- ffc.setFlowReference(ffr);
- });
- onChild("outbound-parameter", n, (cn) -> {
- FacesFlowParameterImpl ffp = new FacesFlowParameterImpl();
- onChild("name", cn, (ccn) -> { ffp.setName(getTextContent(ccn)); });
- onChild("value", cn, (ccn) -> { ffp.setValue(getTextContent(ccn)); });
- ffc.addOutboundParameter(ffp);
- });
- obj.addFlowCall(ffc);
- });
-
- onChild("method-call", node, (n) -> {
- FacesFlowMethodCallImpl ffmc = new FacesFlowMethodCallImpl();
- onAttribute("id", n, (v) -> { ffmc.setId(v); });
- onChild("method", n, (cn) -> { ffmc.setMethod(getTextContent(cn)); });
- onChild("default-outcome", n, (cn) -> { ffmc.setDefaultOutcome(getTextContent(cn)); });
- onChild("parameter", n, (cn) -> {
- FacesFlowMethodParameterImpl ffmp = new FacesFlowMethodParameterImpl();
- onChild("class", cn, (ccn) -> { ffmp.setClassName(getTextContent(ccn)); });
- onChild("value", cn, (ccn) -> { ffmp.setValue(getTextContent(ccn)); });
- ffmc.addParameter(ffmp);
- });
- obj.addMethodCall(ffmc);
- });
-
- onChild("inbound-parameter", node, (n) -> {
- FacesFlowParameterImpl ffp = new FacesFlowParameterImpl();
- onChild("name", n, (cn) -> { ffp.setName(getTextContent(cn)); });
- onChild("value", n, (cn) -> { ffp.setValue(getTextContent(cn)); });
- obj.addInboundParameter(ffp);
- });
-
- return obj;
- }
-
- private NavigationCaseImpl processNavigationCase(Node node)
- {
- NavigationCaseImpl obj = new NavigationCaseImpl();
-
- onChild("from-action", node, (n) -> { obj.setFromAction(getTextContent(n)); });
- onChild("from-outcome", node, (n) -> { obj.setFromOutcome(getTextContent(n)); });
- onChild("if", node, (n) -> { obj.setIf(getTextContent(n)); });
- onChild("to-view-id", node, (n) -> { obj.setToViewId(getTextContent(n)); });
-
- onChild("redirect", node, (n) -> {
- RedirectImpl r = new RedirectImpl();
- onChild("include-view-params", n, (cn) -> { r.setIncludeViewParams("true"); });
- onChild("view-param", n, (cn) -> {
- ViewParamImpl vp = new ViewParamImpl();
- onChild("name", cn, (ccn) -> { vp.setName(getTextContent(ccn)); });
- onChild("value", cn, (ccn) -> { vp.setValue(getTextContent(ccn)); });
- r.addViewParam(vp);
- });
- onChild("redirect-param", n, (cn) -> {
- ViewParamImpl vp = new ViewParamImpl();
- onChild("name", cn, (ccn) -> { vp.setName(getTextContent(ccn)); });
- onChild("value", cn, (ccn) -> { vp.setValue(getTextContent(ccn)); });
- r.addViewParam(vp);
- });
- obj.setRedirect(r);
- });
-
- return obj;
- }
-
-
-
-
- protected void onAttribute(String name, Node node, Consumer<String> val)
- {
- if (node instanceof Element)
- {
- Element element = (Element) node;
- if (element.hasAttribute(name))
- {
- val.accept(element.getAttribute(name));
- }
- }
- }
-
- protected void forEachChild(Node node, Consumer<Node> val)
- {
- if (node.getChildNodes() != null)
- {
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node childNode = node.getChildNodes().item(i);
- if (childNode == null)
- {
- continue;
- }
-
- val.accept(childNode);
- }
- }
- }
-
- protected void onChild(String name, Node node, Consumer<Node> val)
- {
- if (node.getChildNodes() != null)
- {
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node childNode = node.getChildNodes().item(i);
- if (childNode == null)
- {
- continue;
- }
-
- if (name.equals(childNode.getLocalName()))
- {
- val.accept(childNode);
- }
- }
- }
- }
-
- protected String firstChildTextContent(String name, Node node)
- {
- if (node.getChildNodes() != null)
- {
- for (int i = 0; i < node.getChildNodes().getLength(); i++)
- {
- Node childNode = node.getChildNodes().item(i);
- if (childNode == null)
- {
- continue;
- }
-
- if (name.equals(childNode.getLocalName()))
- {
- return childNode.getTextContent();
- }
- }
- }
-
- return null;
- }
-
- protected String getTextContent(Node node)
- {
- if (node == null)
- {
- return null;
- }
-
- String textContent = node.getTextContent();
- if (textContent != null)
- {
- textContent = textContent.trim();
- }
-
- return StringUtils.isBlank(textContent) ? null : textContent;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.impl;
+
+import java.io.ByteArrayInputStream;
+import jakarta.faces.context.ExternalContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.function.Consumer;
+import jakarta.faces.FacesException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.myfaces.config.FacesConfigUnmarshaller;
+import org.apache.myfaces.config.element.FacesFlowDefinition;
+import org.apache.myfaces.config.impl.element.AbsoluteOrderingImpl;
+import org.apache.myfaces.config.impl.element.ApplicationImpl;
+import org.apache.myfaces.config.impl.element.AttributeImpl;
+import org.apache.myfaces.config.impl.element.BehaviorImpl;
+import org.apache.myfaces.config.impl.element.ClientBehaviorRendererImpl;
+import org.apache.myfaces.config.impl.element.ComponentImpl;
+import org.apache.myfaces.config.impl.element.ConfigOthersSlotImpl;
+import org.apache.myfaces.config.impl.element.ContractMappingImpl;
+import org.apache.myfaces.config.impl.element.ConverterImpl;
+import org.apache.myfaces.config.impl.element.FaceletsProcessingImpl;
+import org.apache.myfaces.config.impl.element.FaceletsTemplateMappingImpl;
+import org.apache.myfaces.config.impl.element.FacesConfigExtensionImpl;
+import org.apache.myfaces.config.impl.element.FacesConfigImpl;
+import org.apache.myfaces.config.impl.element.FacesConfigNameSlotImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowCallImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowDefinitionImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowMethodCallImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowMethodParameterImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowParameterImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowReferenceImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowReturnImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowSwitchImpl;
+import org.apache.myfaces.config.impl.element.FacesFlowViewImpl;
+import org.apache.myfaces.config.impl.element.FactoryImpl;
+import org.apache.myfaces.config.impl.element.LocaleConfigImpl;
+import org.apache.myfaces.config.impl.element.NavigationCaseImpl;
+import org.apache.myfaces.config.impl.element.NavigationRuleImpl;
+import org.apache.myfaces.config.impl.element.OrderingImpl;
+import org.apache.myfaces.config.impl.element.PropertyImpl;
+import org.apache.myfaces.config.impl.element.RedirectImpl;
+import org.apache.myfaces.config.impl.element.RenderKitImpl;
+import org.apache.myfaces.config.impl.element.RendererImpl;
+import org.apache.myfaces.config.impl.element.ResourceBundleImpl;
+import org.apache.myfaces.config.impl.element.SystemEventListenerImpl;
+import org.apache.myfaces.config.impl.element.ViewParamImpl;
+import org.apache.myfaces.config.impl.element.ViewPoolMappingImpl;
+import org.apache.myfaces.config.impl.element.ViewPoolParameterImpl;
+import org.apache.myfaces.util.lang.StringUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class FacesConfigUnmarshallerImpl implements FacesConfigUnmarshaller<FacesConfigImpl>
+{
+ private static final Logger log = Logger.getLogger(FacesConfigUnmarshallerImpl.class.getName());
+
+ private ExternalContext externalContext;
+
+ public FacesConfigUnmarshallerImpl(ExternalContext externalContext)
+ {
+ this.externalContext = externalContext;
+ }
+
+ @Override
+ public FacesConfigImpl getFacesConfig(String s) throws IOException, SAXException
+ {
+ return getFacesConfig(new ByteArrayInputStream(s.getBytes()), null);
+ }
+
+ @Override
+ public FacesConfigImpl getFacesConfig(InputStream in, String systemId) throws IOException, SAXException
+ {
+ FacesConfigImpl facesConfig = new FacesConfigImpl();
+
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+
+ try
+ {
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+ factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ factory.setXIncludeAware(false);
+ factory.setExpandEntityReferences(false);
+ }
+ catch (Throwable e)
+ {
+ log.log(Level.WARNING, "DocumentBuilderFactory#setFeature not implemented. Skipping...", e);
+ }
+
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(new FacesConfigEntityResolver(externalContext));
+ Document document;
+ if (systemId == null)
+ {
+ document = builder.parse(in);
+ }
+ else
+ {
+ document = builder.parse(in, systemId);
+ }
+ document.getDocumentElement().normalize();
+
+ onAttribute("metadata-complete", document.getDocumentElement(),
+ (v) -> { facesConfig.setMetadataComplete(v); });
+ onAttribute("version", document.getDocumentElement(),
+ (v) -> { facesConfig.setVersion(v); });
+
+ onChild("name", document.getDocumentElement(),
+ (n) -> { facesConfig.setName(getTextContent(n)); });
+ onChild("ordering", document.getDocumentElement(),
+ (n) -> { facesConfig.setOrdering(processOrdering(n)); });
+ onChild("absolute-ordering", document.getDocumentElement(),
+ (n) -> { facesConfig.setAbsoluteOrdering(processAbsoluteOrdering(n)); });
+ onChild("application", document.getDocumentElement(),
+ (n) -> { facesConfig.addApplication(processApplication(n)); });
+ onChild("factory", document.getDocumentElement(),
+ (n) -> { facesConfig.addFactory(processFactory(n)); });
+ onChild("component", document.getDocumentElement(),
+ (n) -> { facesConfig.addComponent(processComponent(n)); });
+ onChild("lifecycle", document.getDocumentElement(), (n) -> {
+ onChild("phase-listener", n, (cn) -> {
+ facesConfig.addLifecyclePhaseListener(getTextContent(cn));
+ });
+ });
+ onChild("validator", document.getDocumentElement(), (n) -> {
+ facesConfig.addValidator(
+ firstChildTextContent("validator-id", n),
+ firstChildTextContent("validator-class", n));
+ });
+ onChild("render-kit", document.getDocumentElement(),
+ (n) -> { facesConfig.addRenderKit(processRenderKit(n)); });
+ onChild("behavior", document.getDocumentElement(),
+ (n) -> { facesConfig.addBehavior(processBehavior(n)); });
+ onChild("converter", document.getDocumentElement(),
+ (n) -> { facesConfig.addConverter(processConverter(n)); });
+ onChild("protected-views", document.getDocumentElement(), (n) -> {
+ onChild("url-pattern", n, (cn) -> {
+ facesConfig.addProtectedViewUrlPattern(getTextContent(cn));
+ });
+ });
+ onChild("faces-config-extension", document.getDocumentElement(),
+ (n) -> { facesConfig.addFacesConfigExtension(processFacesConfigExtension(n)); });
+ onChild("navigation-rule", document.getDocumentElement(),
+ (n) -> { facesConfig.addNavigationRule(processNavigationRule(n)); });
+ onChild("flow-definition", document.getDocumentElement(),
+ (n) -> { facesConfig.addFacesFlowDefinition(processFlowDefinition(n)); });
+
+ }
+ catch (Exception e)
+ {
+ throw new FacesException(e);
+ }
+ finally
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ // ignore silently
+ }
+ }
+
+ postProcessFacesConfig(systemId, facesConfig);
+
+ return facesConfig;
+ }
+
+ private void postProcessFacesConfig(String systemId, FacesConfigImpl config)
+ {
+ for (org.apache.myfaces.config.element.Application application : config.getApplications())
+ {
+ for (org.apache.myfaces.config.element.LocaleConfig localeConfig : application.getLocaleConfig())
+ {
+ if (!localeConfig.getSupportedLocales().contains(localeConfig.getDefaultLocale()))
+ {
+ localeConfig.addSupportedLocale(localeConfig.getDefaultLocale());
+ }
+ }
+ }
+
+ for (FacesFlowDefinition facesFlowDefinition : config.getFacesFlowDefinitions())
+ {
+ // JSF 2.2 section 11.4.3.1 says this: "... Flows are defined using the
+ // <flow-definition> element. This element must have an id attribute which uniquely
+ // identifies the flow within the scope of the Application Configuration Resource
+ // file in which the element appears. To enable multiple flows with the same id to
+ // exist in an application, the <faces-config><name> element is taken to
+ // be the definingDocumentId of the flow. If no <name> element is specified,
+ // the empty string is taken as the value for definingDocumentId. ..."
+ if (config.getName() != null)
+ {
+ ((FacesFlowDefinitionImpl)facesFlowDefinition).setDefiningDocumentId(
+ config.getName());
+ }
+ else
+ {
+ ((FacesFlowDefinitionImpl)facesFlowDefinition).setDefiningDocumentId("");
+ }
+ }
+ }
+
+ protected OrderingImpl processOrdering(Node node)
+ {
+ OrderingImpl obj = new OrderingImpl();
+
+ onChild("before", node, (n) -> {
+ onChild("name", n, (cn) -> {
+ obj.addBeforeSlot(new FacesConfigNameSlotImpl(getTextContent(cn)));
+ });
+ onChild("others", n, (cn) -> {
+ obj.addBeforeSlot(new ConfigOthersSlotImpl());
+ });
+ });
+
+ onChild("after", node, (n) -> {
+ onChild("name", n, (cn) -> {
+ obj.addAfterSlot(new FacesConfigNameSlotImpl(getTextContent(cn)));
+ });
+ onChild("others", n, (cn) -> {
+ obj.addAfterSlot(new ConfigOthersSlotImpl());
+ });
+ });
+
+ return obj;
+ }
+
+ protected AbsoluteOrderingImpl processAbsoluteOrdering(Node node)
+ {
+ AbsoluteOrderingImpl obj = new AbsoluteOrderingImpl();
+
+ forEachChild(node, (n) -> {
+ if ("name".equals(n.getLocalName()))
+ {
+ FacesConfigNameSlotImpl slot = new FacesConfigNameSlotImpl();
+ slot.setName(getTextContent(n));
+ obj.addOrderSlot(slot);
+ }
+ else if ("others".equals(n.getLocalName()))
+ {
+ obj.addOrderSlot(new ConfigOthersSlotImpl());
+ }
+ });
+
+ return obj;
+ }
+
+ protected ApplicationImpl processApplication(Node node)
+ {
+ ApplicationImpl obj = new ApplicationImpl();
+
+ onChild("action-listener", node, (n) -> { obj.addActionListener(getTextContent(n)); });
+ onChild("message-bundle", node, (n) -> { obj.addMessageBundle(getTextContent(n)); });
+ onChild("navigation-handler", node, (n) -> { obj.addNavigationHandler(getTextContent(n)); });
+ onChild("view-handler", node, (n) -> { obj.addViewHandler(getTextContent(n)); });
+ onChild("state-manager", node, (n) -> { obj.addStateManager(getTextContent(n)); });
+ onChild("property-resolver", node, (n) -> { obj.addPropertyResolver(getTextContent(n)); });
+ onChild("variable-resolver", node, (n) -> { obj.addVariableResolver(getTextContent(n)); });
+ onChild("el-resolver", node, (n) -> { obj.addElResolver(getTextContent(n)); });
+ onChild("resource-handler", node, (n) -> { obj.addResourceHandler(getTextContent(n)); });
+ onChild("default-render-kit-id", node, (n) -> { obj.addDefaultRenderkitId(getTextContent(n)); });
+ onChild("search-expression-handler", node, (n) -> { obj.addSearchExpressionHandler(getTextContent(n)); });
+ onChild("search-keyword-resolver", node, (n) -> { obj.addSearchKeywordResolver(getTextContent(n)); });
+
+ onChild("default-validators", node, (n) -> {
+ obj.setDefaultValidatorsPresent();
+ onChild("validator-id", n, (cn) -> {
+ obj.addDefaultValidatorId(getTextContent(cn));
+ });
+ });
+
+ onChild("locale-config", node, (n) -> {
+ LocaleConfigImpl lc = new LocaleConfigImpl();
+ onChild("default-locale", n, (cn) -> { lc.setDefaultLocale(getTextContent(cn)); });
+ onChild("supported-locale", n, (cn) -> { lc.addSupportedLocale(getTextContent(cn)); });
+ obj.addLocaleConfig(lc);
+ });
+
+ onChild("resource-bundle", node, (n) -> {
+ ResourceBundleImpl rb = new ResourceBundleImpl();
+ onChild("base-name", n, (cn) -> { rb.setBaseName(getTextContent(cn)); });
+ onChild("var", n, (cn) -> { rb.setVar(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { rb.setDisplayName(getTextContent(cn)); });
+ obj.addResourceBundle(rb);
+ });
+
+ onChild("system-event-listener", node, (n) -> {
+ SystemEventListenerImpl sel = new SystemEventListenerImpl();
+ onChild("system-event-listener-class", n, (cn) -> {
+ sel.setSystemEventListenerClass(getTextContent(cn));
+ });
+ onChild("system-event-class", n, (cn) -> {
+ sel.setSystemEventClass(getTextContent(cn));
+ });
+ onChild("source-class", n, (cn) -> {
+ sel.setSourceClass(getTextContent(cn));
+ });
+ obj.addSystemEventListener(sel);
+ });
+
+ onChild("resource-library-contracts", node, (n) -> {
+ onChild("contract-mapping", n, (cn) -> {
+ ContractMappingImpl cm = new ContractMappingImpl();
+ onChild("url-pattern", cn, (ccn) -> {
+ cm.addUrlPattern(getTextContent(ccn));
+ });
+ onChild("contracts", cn, (ccn) -> {
+ cm.addContract(getTextContent(ccn));
+ });
+ obj.addResourceLibraryContractMapping(cm);
+ });
+ });
+
+ return obj;
+ }
+
+ protected FactoryImpl processFactory(Node node)
+ {
+ FactoryImpl obj = new FactoryImpl();
+
+ onChild("application-factory", node, (n) -> { obj.addApplicationFactory(getTextContent(n)); });
+ onChild("faces-context-factory", node, (n) -> { obj.addFacesContextFactory(getTextContent(n)); });
+ onChild("lifecycle-factory", node, (n) -> { obj.addLifecycleFactory(getTextContent(n)); });
+ onChild("render-kit-factory", node, (n) -> { obj.addRenderkitFactory(getTextContent(n)); });
+ onChild("exception-handler-factory", node, (n) -> { obj.addExceptionHandlerFactory(getTextContent(n)); });
+ onChild("external-context-factory", node, (n) -> { obj.addExternalContextFactory(getTextContent(n)); });
+ onChild("view-declaration-language-factory", node, (n) -> {
+ obj.addViewDeclarationLanguageFactory(getTextContent(n));
+ });
+ onChild("partial-view-context-factory", node, (n) -> {
+ obj.addPartialViewContextFactory(getTextContent(n));
+ });
+ onChild("tag-handler-delegate-factory", node, (n) -> {
+ obj.addTagHandlerDelegateFactory(getTextContent(n));
+ });
+ onChild("visit-context-factory", node, (n) -> { obj.addVisitContextFactory(getTextContent(n)); });
+ onChild("search-expression-context-factory", node, (n) -> {
+ obj.addSearchExpressionContextFactory(getTextContent(n));
+ });
+ onChild("facelet-cache-factory", node, (n) -> { obj.addFaceletCacheFactory(getTextContent(n)); });
+ onChild("flash-factory", node, (n) -> { obj.addFlashFactory(getTextContent(n)); });
+ onChild("flow-handler-factory", node, (n) -> { obj.addFlowHandlerFactory(getTextContent(n)); });
+ onChild("client-window-factory", node, (n) -> { obj.addClientWindowFactory(getTextContent(n)); });
+
+ return obj;
+ }
+
+ protected RenderKitImpl processRenderKit(Node node)
+ {
+ RenderKitImpl obj = new RenderKitImpl();
+
+ onChild("render-kit-id", node, (n) -> { obj.setId(getTextContent(n)); });
+ onChild("render-kit-class", node, (n) -> { obj.addRenderKitClass(getTextContent(n)); });
+
+ onChild("renderer", node, (n) -> {
+ RendererImpl r = new RendererImpl();
+ onChild("component-family", n, (cn) -> { r.setComponentFamily(getTextContent(cn)); });
+ onChild("renderer-type", n, (cn) -> { r.setRendererType(getTextContent(cn)); });
+ onChild("renderer-class", n, (cn) -> { r.setRendererClass(getTextContent(cn)); });
+ obj.addRenderer(r);
+ });
+
+ onChild("client-behavior-renderer", node, (n) -> {
+ ClientBehaviorRendererImpl r = new ClientBehaviorRendererImpl();
+ onChild("client-behavior-renderer-type", n, (cn) -> { r.setRendererType(getTextContent(cn)); });
+ onChild("client-behavior-renderer-class", n, (cn) -> { r.setRendererClass(getTextContent(cn)); });
+ obj.addClientBehaviorRenderer(r);
+ });
+
+ return obj;
+ }
+
+ protected ComponentImpl processComponent(Node node)
+ {
+ ComponentImpl obj = new ComponentImpl();
+
+ onChild("component-type", node, (n) -> { obj.setComponentType(getTextContent(n)); });
+ onChild("component-class", node, (n) -> { obj.setComponentClass(getTextContent(n)); });
+
+ onChild("attribute", node, (n) -> {
+ AttributeImpl a = new AttributeImpl();
+ onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
+ onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
+ onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
+ onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
+ obj.addAttribute(a);
+ });
+
+ onChild("property", node, (n) -> {
+ PropertyImpl p = new PropertyImpl();
+ onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
+ onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
+ onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
+ onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
+ obj.addProperty(p);
+ });
+
+ return obj;
+ }
+
+ protected BehaviorImpl processBehavior(Node node)
+ {
+ BehaviorImpl obj = new BehaviorImpl();
+
+ onChild("behavior-id", node, (n) -> { obj.setBehaviorId(getTextContent(n)); });
+ onChild("behavior-class", node, (n) -> { obj.setBehaviorClass(getTextContent(n)); });
+
+ onChild("attribute", node, (n) -> {
+ AttributeImpl a = new AttributeImpl();
+ onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
+ onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
+ onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
+ onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
+ obj.addAttribute(a);
+ });
+
+ onChild("property", node, (n) -> {
+ PropertyImpl p = new PropertyImpl();
+ onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
+ onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
+ onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
+ onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
+ obj.addProperty(p);
+ });
+
+ return obj;
+ }
+
+ protected ConverterImpl processConverter(Node node)
+ {
+ ConverterImpl obj = new ConverterImpl();
+
+ onChild("converter-id", node, (n) -> { obj.setConverterId(getTextContent(n)); });
+ onChild("converter-for-class", node, (n) -> { obj.setForClass(getTextContent(n)); });
+ onChild("converter-class", node, (n) -> { obj.setConverterClass(getTextContent(n)); });
+
+ onChild("attribute", node, (n) -> {
+ AttributeImpl a = new AttributeImpl();
+ onChild("description", n, (cn) -> { a.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { a.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { a.addIcon(getTextContent(cn)); });
+ onChild("attribute-name", n, (cn) -> { a.setAttributeName(getTextContent(cn)); });
+ onChild("attribute-class", n, (cn) -> { a.setAttributeClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { a.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { a.setSuggestedValue(getTextContent(cn)); });
+ onChild("attribute-extension", n, (cn) -> { a.addAttributeExtension(getTextContent(cn)); });
+ obj.addAttribute(a);
+ });
+
+ onChild("property", node, (n) -> {
+ PropertyImpl p = new PropertyImpl();
+ onChild("description", n, (cn) -> { p.addDescription(getTextContent(cn)); });
+ onChild("display-name", n, (cn) -> { p.addDisplayName(getTextContent(cn)); });
+ onChild("icon", n, (cn) -> { p.addIcon(getTextContent(cn)); });
+ onChild("property-name", n, (cn) -> { p.setPropertyName(getTextContent(cn)); });
+ onChild("property-class", n, (cn) -> { p.setPropertyClass(getTextContent(cn)); });
+ onChild("default-value", n, (cn) -> { p.setDefaultValue(getTextContent(cn)); });
+ onChild("suggested-value", n, (cn) -> { p.setSuggestedValue(getTextContent(cn)); });
+ onChild("property-extension", n, (cn) -> { p.addPropertyExtension(getTextContent(cn)); });
+ obj.addProperty(p);
+ });
+
+ return obj;
+ }
+
+ protected FacesConfigExtensionImpl processFacesConfigExtension(Node node)
+ {
+ FacesConfigExtensionImpl obj = new FacesConfigExtensionImpl();
+
+ onChild("facelets-processing", node, (n) -> {
+ FaceletsProcessingImpl fp = new FaceletsProcessingImpl();
+ onChild("file-extension", n, (cn) -> { fp.setFileExtension(getTextContent(cn)); });
+ onChild("process-as", n, (cn) -> { fp.setProcessAs(getTextContent(cn)); });
+ onChild("oam-compress-spaces", n, (cn) -> { fp.setOamCompressSpaces(getTextContent(cn)); });
+ obj.addFaceletsProcessing(fp);
+ });
+
+ onChild("view-pool-mapping", node, (n) -> {
+ ViewPoolMappingImpl vpm = new ViewPoolMappingImpl();
+ onChild("url-pattern", n, (cn) -> { vpm.setUrlPattern(getTextContent(cn)); });
+ onChild("parameter", n, (cn) -> {
+ ViewPoolParameterImpl vpp = new ViewPoolParameterImpl();
+ onChild("name", cn, (ccn) -> { vpp.setName(getTextContent(ccn)); });
+ onChild("value", cn, (ccn) -> { vpp.setValue(getTextContent(ccn)); });
+ vpm.addParameter(vpp);
+ });
+ obj.addViewPoolMapping(vpm);
+ });
+
+ onChild("facelets-template-mapping", node, (n) -> {
+ FaceletsTemplateMappingImpl ftm = new FaceletsTemplateMappingImpl();
+ onChild("url-pattern", n, (cn) -> { ftm.setUrlPattern(getTextContent(cn)); });
+ obj.addFaceletsTemplateMapping(ftm);
+ });
+
+ return obj;
+ }
+
+ protected NavigationRuleImpl processNavigationRule(Node node)
+ {
+ NavigationRuleImpl obj = new NavigationRuleImpl();
+
+ onChild("from-view-id", node, (n) -> { obj.setFromViewId(getTextContent(n)); });
+
+ onChild("navigation-case", node, (n) -> {
+ obj.addNavigationCase(processNavigationCase(n));
+ });
+
+ return obj;
+ }
+
+ protected FacesFlowDefinitionImpl processFlowDefinition(Node node)
+ {
+ FacesFlowDefinitionImpl obj = new FacesFlowDefinitionImpl();
+
+ onAttribute("id", node, (v) -> { obj.setId(v); });
+ onChild("start-node", node, (n) -> { obj.setStartNode(getTextContent(n)); });
+ onChild("initializer", node, (n) -> { obj.setInitializer(getTextContent(n)); });
+ onChild("finalizer", node, (n) -> { obj.setFinalizer(getTextContent(n)); });
+
+ onChild("view", node, (n) -> {
+ FacesFlowViewImpl ffv = new FacesFlowViewImpl();
+ onAttribute("id", n, (v) -> { ffv.setId(v); });
+ onChild("vdl-document", n, (cn) -> { ffv.setVdlDocument(getTextContent(cn)); });
+ obj.addView(ffv);
+ });
+
+ onChild("switch", node, (n) -> {
+ FacesFlowSwitchImpl ffs = new FacesFlowSwitchImpl();
+ onAttribute("id", n, (v) -> { ffs.setId(v); });
+ onChild("case", n, (cn) -> { ffs.addNavigationCase(processNavigationCase(cn)); });
+ onChild("default-outcome", n, (cn) -> {
+ NavigationCaseImpl nc = new NavigationCaseImpl();
+ nc.setFromAction(getTextContent(cn));
+ ffs.setDefaultOutcome(nc);
+ });
+ obj.addSwitch(ffs);
+ });
+
+ onChild("flow-return", node, (n) -> {
+ FacesFlowReturnImpl ffr = new FacesFlowReturnImpl();
+ onAttribute("id", n, (v) -> { ffr.setId(v); });
+ onChild("from-outcome", n, (cn) -> {
+ NavigationCaseImpl nc = new NavigationCaseImpl();
+ nc.setFromOutcome(getTextContent(cn));
+ ffr.setNavigationCase(nc);
+ });
+ obj.addReturn(ffr);
+ });
+
+ onChild("navigation-rule", node, (n) -> {
+ NavigationRuleImpl nr = new NavigationRuleImpl();
+ onChild("from-view-id", n, (cn) -> { nr.setFromViewId(getTextContent(cn)); });
+ onChild("navigation-case", n, (cn) -> { nr.addNavigationCase(processNavigationCase(cn)); });
+ obj.addNavigationRule(nr);
+ });
+
+ onChild("flow-call", node, (n) -> {
+ FacesFlowCallImpl ffc = new FacesFlowCallImpl();
+ onAttribute("id", n, (v) -> { ffc.setId(v); });
+ onChild("flow-reference", n, (cn) -> {
+ FacesFlowReferenceImpl ffr = new FacesFlowReferenceImpl();
+ onChild("flow-document-id", cn, (ccn) -> { ffr.setFlowDocumentId(getTextContent(ccn)); });
+ onChild("flow-id", cn, (ccn) -> { ffr.setFlowId(getTextContent(ccn)); });
+ ffc.setFlowReference(ffr);
+ });
+ onChild("outbound-parameter", n, (cn) -> {
+ FacesFlowParameterImpl ffp = new FacesFlowParameterImpl();
+ onChild("name", cn, (ccn) -> { ffp.setName(getTextContent(ccn)); });
+ onChild("value", cn, (ccn) -> { ffp.setValue(getTextContent(ccn)); });
+ ffc.addOutboundParameter(ffp);
+ });
+ obj.addFlowCall(ffc);
+ });
+
+ onChild("method-call", node, (n) -> {
+ FacesFlowMethodCallImpl ffmc = new FacesFlowMethodCallImpl();
+ onAttribute("id", n, (v) -> { ffmc.setId(v); });
+ onChild("method", n, (cn) -> { ffmc.setMethod(getTextContent(cn)); });
+ onChild("default-outcome", n, (cn) -> { ffmc.setDefaultOutcome(getTextContent(cn)); });
+ onChild("parameter", n, (cn) -> {
+ FacesFlowMethodParameterImpl ffmp = new FacesFlowMethodParameterImpl();
+ onChild("class", cn, (ccn) -> { ffmp.setClassName(getTextContent(ccn)); });
+ onChild("value", cn, (ccn) -> { ffmp.setValue(getTextContent(ccn)); });
+ ffmc.addParameter(ffmp);
+ });
+ obj.addMethodCall(ffmc);
+ });
+
+ onChild("inbound-parameter", node, (n) -> {
+ FacesFlowParameterImpl ffp = new FacesFlowParameterImpl();
+ onChild("name", n, (cn) -> { ffp.setName(getTextContent(cn)); });
+ onChild("value", n, (cn) -> { ffp.setValue(getTextContent(cn)); });
+ obj.addInboundParameter(ffp);
+ });
+
+ return obj;
+ }
+
+ private NavigationCaseImpl processNavigationCase(Node node)
+ {
+ NavigationCaseImpl obj = new NavigationCaseImpl();
+
+ onChild("from-action", node, (n) -> { obj.setFromAction(getTextContent(n)); });
+ onChild("from-outcome", node, (n) -> { obj.setFromOutcome(getTextContent(n)); });
+ onChild("if", node, (n) -> { obj.setIf(getTextContent(n)); });
+ onChild("to-view-id", node, (n) -> { obj.setToViewId(getTextContent(n)); });
+
+ onChild("redirect", node, (n) -> {
+ RedirectImpl r = new RedirectImpl();
+ onChild("include-view-params", n, (cn) -> { r.setIncludeViewParams("true"); });
+ onChild("view-param", n, (cn) -> {
+ ViewParamImpl vp = new ViewParamImpl();
+ onChild("name", cn, (ccn) -> { vp.setName(getTextContent(ccn)); });
+ onChild("value", cn, (ccn) -> { vp.setValue(getTextContent(ccn)); });
+ r.addViewParam(vp);
+ });
+ onChild("redirect-param", n, (cn) -> {
+ ViewParamImpl vp = new ViewParamImpl();
+ onChild("name", cn, (ccn) -> { vp.setName(getTextContent(ccn)); });
+ onChild("value", cn, (ccn) -> { vp.setValue(getTextContent(ccn)); });
+ r.addViewParam(vp);
+ });
+ obj.setRedirect(r);
+ });
+
+ return obj;
+ }
+
+
+
+
+ protected void onAttribute(String name, Node node, Consumer<String> val)
+ {
+ if (node instanceof Element)
+ {
+ Element element = (Element) node;
+ if (element.hasAttribute(name))
+ {
+ val.accept(element.getAttribute(name));
+ }
+ }
+ }
+
+ protected void forEachChild(Node node, Consumer<Node> val)
+ {
+ if (node.getChildNodes() != null)
+ {
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ {
+ Node childNode = node.getChildNodes().item(i);
+ if (childNode == null)
+ {
+ continue;
+ }
+
+ val.accept(childNode);
+ }
+ }
+ }
+
+ protected void onChild(String name, Node node, Consumer<Node> val)
+ {
+ if (node.getChildNodes() != null)
+ {
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ {
+ Node childNode = node.getChildNodes().item(i);
+ if (childNode == null)
+ {
+ continue;
+ }
+
+ if (name.equals(childNode.getLocalName()))
+ {
+ val.accept(childNode);
+ }
+ }
+ }
+ }
+
+ protected String firstChildTextContent(String name, Node node)
+ {
+ if (node.getChildNodes() != null)
+ {
+ for (int i = 0; i < node.getChildNodes().getLength(); i++)
+ {
+ Node childNode = node.getChildNodes().item(i);
+ if (childNode == null)
+ {
+ continue;
+ }
+
+ if (name.equals(childNode.getLocalName()))
+ {
+ return childNode.getTextContent();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ protected String getTextContent(Node node)
+ {
+ if (node == null)
+ {
+ return null;
+ }
+
+ String textContent = node.getTextContent();
+ if (textContent != null)
+ {
+ textContent = textContent.trim();
+ }
+
+ return StringUtils.isBlank(textContent) ? null : textContent;
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/element/ComponentImpl.java b/impl/src/main/java/org/apache/myfaces/config/impl/element/ComponentImpl.java
index 55aea41..c43097f 100755
--- a/impl/src/main/java/org/apache/myfaces/config/impl/element/ComponentImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/element/ComponentImpl.java
@@ -1,106 +1,106 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.impl.element;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
- */
-public class ComponentImpl extends org.apache.myfaces.config.element.Component implements Serializable
-{
- private String componentType;
- private String componentClass;
- private List<org.apache.myfaces.config.element.Property> properties = null;
- private List<org.apache.myfaces.config.element.Attribute> attributes = null;
-
- public ComponentImpl()
- {
-
- }
-
- public ComponentImpl(String componentType, String componentClass)
- {
- this.componentType = componentType;
- this.componentClass = componentClass;
- }
-
- public void setComponentType(String componentType)
- {
- this.componentType = componentType;
- }
-
- public void setComponentClass(String componentClass)
- {
- this.componentClass = componentClass;
- }
-
- @Override
- public String getComponentType()
- {
- return componentType;
- }
-
- @Override
- public String getComponentClass()
- {
- return componentClass;
- }
-
- public void addProperty(org.apache.myfaces.config.element.Property value)
- {
- if (properties == null)
- {
- properties = new ArrayList<>();
- }
- properties.add(value);
- }
-
- @Override
- public List<? extends org.apache.myfaces.config.element.Property> getProperties()
- {
- if (properties == null)
- {
- return Collections.emptyList();
- }
- return properties;
- }
-
- public void addAttribute(org.apache.myfaces.config.element.Attribute value)
- {
- if (attributes == null)
- {
- attributes = new ArrayList<>();
- }
- attributes.add(value);
- }
-
- @Override
- public List<? extends org.apache.myfaces.config.element.Attribute> getAttributes()
- {
- if (attributes == null)
- {
- return Collections.emptyList();
- }
- return attributes;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.impl.element;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ */
+public class ComponentImpl extends org.apache.myfaces.config.element.Component implements Serializable
+{
+ private String componentType;
+ private String componentClass;
+ private List<org.apache.myfaces.config.element.Property> properties = null;
+ private List<org.apache.myfaces.config.element.Attribute> attributes = null;
+
+ public ComponentImpl()
+ {
+
+ }
+
+ public ComponentImpl(String componentType, String componentClass)
+ {
+ this.componentType = componentType;
+ this.componentClass = componentClass;
+ }
+
+ public void setComponentType(String componentType)
+ {
+ this.componentType = componentType;
+ }
+
+ public void setComponentClass(String componentClass)
+ {
+ this.componentClass = componentClass;
+ }
+
+ @Override
+ public String getComponentType()
+ {
+ return componentType;
+ }
+
+ @Override
+ public String getComponentClass()
+ {
+ return componentClass;
+ }
+
+ public void addProperty(org.apache.myfaces.config.element.Property value)
+ {
+ if (properties == null)
+ {
+ properties = new ArrayList<>();
+ }
+ properties.add(value);
+ }
+
+ @Override
+ public List<? extends org.apache.myfaces.config.element.Property> getProperties()
+ {
+ if (properties == null)
+ {
+ return Collections.emptyList();
+ }
+ return properties;
+ }
+
+ public void addAttribute(org.apache.myfaces.config.element.Attribute value)
+ {
+ if (attributes == null)
+ {
+ attributes = new ArrayList<>();
+ }
+ attributes.add(value);
+ }
+
+ @Override
+ public List<? extends org.apache.myfaces.config.element.Attribute> getAttributes()
+ {
+ if (attributes == null)
+ {
+ return Collections.emptyList();
+ }
+ return attributes;
+ }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/config/impl/element/FacesConfigImpl.java b/impl/src/main/java/org/apache/myfaces/config/impl/element/FacesConfigImpl.java
index 7cc1789..7088b09 100755
--- a/impl/src/main/java/org/apache/myfaces/config/impl/element/FacesConfigImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/config/impl/element/FacesConfigImpl.java
@@ -1,544 +1,544 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.config.impl.element;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-import org.apache.myfaces.config.element.AbsoluteOrdering;
-import org.apache.myfaces.config.element.Application;
-import org.apache.myfaces.config.element.Behavior;
-import org.apache.myfaces.config.element.Component;
-import org.apache.myfaces.config.element.ComponentTagDeclaration;
-import org.apache.myfaces.config.element.Converter;
-import org.apache.myfaces.config.element.FacesConfigExtension;
-import org.apache.myfaces.config.element.FacesFlowDefinition;
-import org.apache.myfaces.config.element.Factory;
-import org.apache.myfaces.config.element.NamedEvent;
-import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.element.Ordering;
-import org.apache.myfaces.config.element.RenderKit;
-import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
-
-/**
- * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
- */
-public class FacesConfigImpl extends org.apache.myfaces.config.element.FacesConfig implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private static final Logger LOG = Logger.getLogger(FacesConfigImpl.class.getName());
-
- private List<Application> applications;
- private List<Factory> factories;
- private List<Component> components;
- private Map<String, ComponentTagDeclaration> componentTagDeclarations;
- private List<Converter> converters;
- private List<NavigationRule> navigationRules;
- private List<RenderKit> renderKits;
- private List<String> lifecyclePhaseListener;
- private Map<String, String> validators;
- private List<Behavior> behaviors;
- private List<NamedEvent> namedEvents;
- private List<FacesConfigExtension> facesConfigExtensions;
- private List <FacesFlowDefinition> facesFlowDefinitions;
- private List <String> protectedViewsUrlPatternList;
- private List <String> resourceResolvers;
- private List<FaceletTagLibrary> faceletTagLibraryList;
-
- private transient List<Application> unmodifiableApplications;
- private transient List<Factory> unmodifiableFactories;
- private transient List<Component> unmodifiableComponents;
- private transient Map<String, ComponentTagDeclaration> unmodifiableComponentTagDeclarations;
- private transient List<Converter> unmodifiableConverters;
- private transient List<NavigationRule> unmodifiableNavigationRules;
- private transient List<RenderKit> unmodifiableRenderKits;
- private transient List<String> unmodifiableLifecyclePhaseListener;
- private transient Map<String, String> unmodifiableValidators;
- private transient List<Behavior> unmodifiableBehaviors;
- private transient List<NamedEvent> unmodifiableNamedEvents;
- private transient List<FacesConfigExtension> unmodifiableFacesConfigExtensions;
- private transient List<FacesFlowDefinition> unmodifiableFacesFlowDefinitions;
- private transient List<String> unmodifiableProtectedViewsUrlPatternList;
- private transient List<String> unmodifiableResourceResolvers;
- private transient List<FaceletTagLibrary> unmodifiableFaceletTagLibraryList;
-
- private String metadataComplete;
- private String version;
- //Ordering variables
- //This information are not merged, and helps
- //with preprocessing of faces-config files
- private String name;
- private AbsoluteOrdering absoluteOrdering;
- private Ordering ordering;
-
- public void addApplication(Application application)
- {
- if (applications == null)
- {
- applications = new ArrayList<>();
- }
- applications.add(application);
- }
-
- public void addFactory(Factory factory)
- {
- if (factories == null)
- {
- factories = new ArrayList<>();
- }
- factories.add(factory);
- }
-
- public void addComponent(Component component)
- {
- if (components == null)
- {
- components = new ArrayList<>();
- }
- components.add(component);
- }
-
- public void addComponentTagDeclaration(String componentType, ComponentTagDeclaration tagDeclaration)
- {
- if (componentTagDeclarations == null)
- {
- componentTagDeclarations = new HashMap<>();
- }
- componentTagDeclarations.put(componentType, tagDeclaration);
- }
-
- public void addConverter(Converter converter)
- {
- if (converters == null)
- {
- converters = new ArrayList<>();
- }
- converters.add(converter);
- }
-
- public void addNavigationRule(NavigationRule rule)
- {
- if (navigationRules == null)
- {
- navigationRules = new ArrayList<>();
- }
- navigationRules.add(rule);
- }
-
- public void addRenderKit(RenderKit renderKit)
- {
- if (renderKits == null)
- {
- renderKits = new ArrayList<>();
- }
- renderKits.add(renderKit);
- }
-
- public void addLifecyclePhaseListener(String value)
- {
- if (lifecyclePhaseListener == null)
- {
- lifecyclePhaseListener = new ArrayList<>();
- }
- lifecyclePhaseListener.add(value);
- }
-
- public void addValidator(String id, String validatorClass)
- {
- if (validators == null)
- {
- validators = new HashMap<>();
- }
-
- String oldValidator = validators.get(id);
- // don't log if someone overwrites the built-in converters
- if (oldValidator != null && !oldValidator.startsWith("jakarta.faces.validator."))
- {
- LOG.warning("There is already a validator defined for id: " + id + "."
- + " old: " + oldValidator
- + " new: " + validatorClass);
- }
-
- validators.put(id, validatorClass);
- }
-
- public void addBehavior(Behavior behavior)
- {
- if (behaviors == null)
- {
- behaviors = new ArrayList<>();
- }
- behaviors.add (behavior);
- }
-
- public void addNamedEvent(NamedEvent namedEvent)
- {
- if (namedEvents == null)
- {
- namedEvents = new ArrayList<>();
- }
- namedEvents.add(namedEvent);
- }
-
- public void addFacesConfigExtension(FacesConfigExtension elem)
- {
- if (facesConfigExtensions == null)
- {
- facesConfigExtensions = new ArrayList<>();
- }
- facesConfigExtensions.add(elem);
- }
-
- public void addFacesFlowDefinition(FacesFlowDefinition elem)
- {
- if (facesFlowDefinitions == null)
- {
- facesFlowDefinitions = new ArrayList<>();
- }
- facesFlowDefinitions.add(elem);
- }
-
- public void addProtectedViewUrlPattern(String urlPattern)
- {
- if (protectedViewsUrlPatternList == null)
- {
- protectedViewsUrlPatternList = new ArrayList<>();
- }
- protectedViewsUrlPatternList.add(urlPattern);
- }
-
- public void addResourceResolver(String resourceResolverClass)
- {
- if (resourceResolvers == null)
- {
- resourceResolvers = new ArrayList<>();
- }
- resourceResolvers.add(resourceResolverClass);
- }
-
- public void addFaceletTagLibrary(FaceletTagLibrary library)
- {
- if (faceletTagLibraryList == null)
- {
- faceletTagLibraryList = new ArrayList<>();
- }
- faceletTagLibraryList.add(library);
- }
-
- @Override
- public List<Application> getApplications()
- {
- if (applications == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableApplications == null)
- {
- unmodifiableApplications = Collections.unmodifiableList(applications);
- }
- return unmodifiableApplications;
- }
-
- @Override
- public List<Factory> getFactories()
- {
- if (factories == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableFactories == null)
- {
- unmodifiableFactories = Collections.unmodifiableList(factories);
- }
- return unmodifiableFactories;
- }
-
- @Override
- public List<Component> getComponents()
- {
- if (components == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableComponents == null)
- {
- unmodifiableComponents = Collections.unmodifiableList(components);
- }
- return unmodifiableComponents;
- }
-
- @Override
- public Map<String, ComponentTagDeclaration> getComponentTagDeclarations()
- {
- if (componentTagDeclarations == null)
- {
- return Collections.emptyMap();
- }
- if (unmodifiableComponentTagDeclarations == null)
- {
- unmodifiableComponentTagDeclarations = Collections.unmodifiableMap(componentTagDeclarations);
- }
- return unmodifiableComponentTagDeclarations;
- }
-
- @Override
- public List<Converter> getConverters()
- {
- if (converters == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableConverters == null)
- {
- unmodifiableConverters = Collections.unmodifiableList(converters);
- }
- return unmodifiableConverters;
- }
-
- @Override
- public List<NavigationRule> getNavigationRules()
- {
- if (navigationRules == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableNavigationRules == null)
- {
- unmodifiableNavigationRules = Collections.unmodifiableList(navigationRules);
- }
- return unmodifiableNavigationRules;
- }
-
- @Override
- public List<RenderKit> getRenderKits()
- {
- if (renderKits == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableRenderKits == null)
- {
- unmodifiableRenderKits = Collections.unmodifiableList(renderKits);
- }
- return unmodifiableRenderKits;
- }
-
- @Override
- public List<String> getLifecyclePhaseListener()
- {
- if (lifecyclePhaseListener == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableLifecyclePhaseListener == null)
- {
- unmodifiableLifecyclePhaseListener = Collections.unmodifiableList(lifecyclePhaseListener);
- }
- return unmodifiableLifecyclePhaseListener;
- }
-
- @Override
- public Map<String, String> getValidators()
- {
- if (validators == null)
- {
- return Collections.emptyMap();
- }
- if (unmodifiableValidators == null)
- {
- unmodifiableValidators = Collections.unmodifiableMap(validators);
- }
- return unmodifiableValidators;
- }
-
- @Override
- public List<Behavior> getBehaviors ()
- {
- if (behaviors == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableBehaviors == null)
- {
- unmodifiableBehaviors = Collections.unmodifiableList(behaviors);
- }
- return unmodifiableBehaviors;
- }
-
- @Override
- public List<NamedEvent> getNamedEvents()
- {
- if (namedEvents == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableNamedEvents == null)
- {
- unmodifiableNamedEvents = Collections.unmodifiableList(namedEvents);
- }
- return unmodifiableNamedEvents;
- }
-
- @Override
- public RenderKit getRenderKit(String renderKitId)
- {
- for (RenderKit rk : getRenderKits())
- {
- if (renderKitId != null && renderKitId.equals(rk.getId()))
- {
- return rk;
- }
- else if (renderKitId == null && rk.getId() == null)
- {
- return rk;
- }
- }
- return null;
- }
-
- @Override
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- @Override
- public org.apache.myfaces.config.element.AbsoluteOrdering getAbsoluteOrdering()
- {
- return absoluteOrdering;
- }
-
- public void setAbsoluteOrdering(org.apache.myfaces.config.element.AbsoluteOrdering absoluteOrdering)
- {
- this.absoluteOrdering = absoluteOrdering;
- }
-
- @Override
- public org.apache.myfaces.config.element.Ordering getOrdering()
- {
- return ordering;
- }
-
- public void setOrdering(org.apache.myfaces.config.element.Ordering ordering)
- {
- this.ordering = ordering;
- }
-
- @Override
- public String getMetadataComplete()
- {
- return metadataComplete;
- }
-
- public void setMetadataComplete(String metadataComplete)
- {
- this.metadataComplete = metadataComplete;
- }
-
- @Override
- public String getVersion()
- {
- return version;
- }
-
- public void setVersion(String version)
- {
- this.version = version;
- }
-
- @Override
- public List<org.apache.myfaces.config.element.FacesConfigExtension> getFacesConfigExtensions()
- {
- if (facesConfigExtensions == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableFacesConfigExtensions == null)
- {
- unmodifiableFacesConfigExtensions = Collections.unmodifiableList(facesConfigExtensions);
- }
- return unmodifiableFacesConfigExtensions;
- }
-
- @Override
- public List<FacesFlowDefinition> getFacesFlowDefinitions()
- {
- if (facesFlowDefinitions == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableFacesFlowDefinitions == null)
- {
- unmodifiableFacesFlowDefinitions = Collections.unmodifiableList(facesFlowDefinitions);
- }
- return unmodifiableFacesFlowDefinitions;
- }
-
- @Override
- public List<String> getProtectedViewsUrlPatternList()
- {
- if (protectedViewsUrlPatternList == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableProtectedViewsUrlPatternList == null)
- {
- unmodifiableProtectedViewsUrlPatternList = Collections.unmodifiableList(protectedViewsUrlPatternList);
- }
- return unmodifiableProtectedViewsUrlPatternList;
- }
-
- @Override
- public List<String> getResourceResolversList()
- {
- if (resourceResolvers == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableResourceResolvers == null)
- {
- unmodifiableResourceResolvers = Collections.unmodifiableList(resourceResolvers);
- }
- return unmodifiableResourceResolvers;
- }
-
- @Override
- public List<FaceletTagLibrary> getFaceletTagLibraryList()
- {
- if (faceletTagLibraryList == null)
- {
- return Collections.emptyList();
- }
- if (unmodifiableFaceletTagLibraryList == null)
- {
- unmodifiableFaceletTagLibraryList = Collections.unmodifiableList(faceletTagLibraryList);
- }
- return unmodifiableFaceletTagLibraryList;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.config.impl.element;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+import org.apache.myfaces.config.element.AbsoluteOrdering;
+import org.apache.myfaces.config.element.Application;
+import org.apache.myfaces.config.element.Behavior;
+import org.apache.myfaces.config.element.Component;
+import org.apache.myfaces.config.element.ComponentTagDeclaration;
+import org.apache.myfaces.config.element.Converter;
+import org.apache.myfaces.config.element.FacesConfigExtension;
+import org.apache.myfaces.config.element.FacesFlowDefinition;
+import org.apache.myfaces.config.element.Factory;
+import org.apache.myfaces.config.element.NamedEvent;
+import org.apache.myfaces.config.element.NavigationRule;
+import org.apache.myfaces.config.element.Ordering;
+import org.apache.myfaces.config.element.RenderKit;
+import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
+
+/**
+ * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
+ */
+public class FacesConfigImpl extends org.apache.myfaces.config.element.FacesConfig implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = Logger.getLogger(FacesConfigImpl.class.getName());
+
+ private List<Application> applications;
+ private List<Factory> factories;
+ private List<Component> components;
+ private Map<String, ComponentTagDeclaration> componentTagDeclarations;
+ private List<Converter> converters;
+ private List<NavigationRule> navigationRules;
+ private List<RenderKit> renderKits;
+ private List<String> lifecyclePhaseListener;
+ private Map<String, String> validators;
+ private List<Behavior> behaviors;
+ private List<NamedEvent> namedEvents;
+ private List<FacesConfigExtension> facesConfigExtensions;
+ private List <FacesFlowDefinition> facesFlowDefinitions;
+ private List <String> protectedViewsUrlPatternList;
+ private List <String> resourceResolvers;
+ private List<FaceletTagLibrary> faceletTagLibraryList;
+
+ private transient List<Application> unmodifiableApplications;
+ private transient List<Factory> unmodifiableFactories;
+ private transient List<Component> unmodifiableComponents;
+ private transient Map<String, ComponentTagDeclaration> unmodifiableComponentTagDeclarations;
+ private transient List<Converter> unmodifiableConverters;
+ private transient List<NavigationRule> unmodifiableNavigationRules;
+ private transient List<RenderKit> unmodifiableRenderKits;
+ private transient List<String> unmodifiableLifecyclePhaseListener;
+ private transient Map<String, String> unmodifiableValidators;
+ private transient List<Behavior> unmodifiableBehaviors;
+ private transient List<NamedEvent> unmodifiableNamedEvents;
+ private transient List<FacesConfigExtension> unmodifiableFacesConfigExtensions;
+ private transient List<FacesFlowDefinition> unmodifiableFacesFlowDefinitions;
+ private transient List<String> unmodifiableProtectedViewsUrlPatternList;
+ private transient List<String> unmodifiableResourceResolvers;
+ private transient List<FaceletTagLibrary> unmodifiableFaceletTagLibraryList;
+
+ private String metadataComplete;
+ private String version;
+ //Ordering variables
+ //This information are not merged, and helps
+ //with preprocessing of faces-config files
+ private String name;
+ private AbsoluteOrdering absoluteOrdering;
+ private Ordering ordering;
+
+ public void addApplication(Application application)
+ {
+ if (applications == null)
+ {
+ applications = new ArrayList<>();
+ }
+ applications.add(application);
+ }
+
+ public void addFactory(Factory factory)
+ {
+ if (factories == null)
+ {
+ factories = new ArrayList<>();
+ }
+ factories.add(factory);
+ }
+
+ public void addComponent(Component component)
+ {
+ if (components == null)
+ {
+ components = new ArrayList<>();
+ }
+ components.add(component);
+ }
+
+ public void addComponentTagDeclaration(String componentType, ComponentTagDeclaration tagDeclaration)
+ {
+ if (componentTagDeclarations == null)
+ {
+ componentTagDeclarations = new HashMap<>();
+ }
+ componentTagDeclarations.put(componentType, tagDeclaration);
+ }
+
+ public void addConverter(Converter converter)
+ {
+ if (converters == null)
+ {
+ converters = new ArrayList<>();
+ }
+ converters.add(converter);
+ }
+
+ public void addNavigationRule(NavigationRule rule)
+ {
+ if (navigationRules == null)
+ {
+ navigationRules = new ArrayList<>();
+ }
+ navigationRules.add(rule);
+ }
+
+ public void addRenderKit(RenderKit renderKit)
+ {
+ if (renderKits == null)
+ {
+ renderKits = new ArrayList<>();
+ }
+ renderKits.add(renderKit);
+ }
+
+ public void addLifecyclePhaseListener(String value)
+ {
+ if (lifecyclePhaseListener == null)
+ {
+ lifecyclePhaseListener = new ArrayList<>();
+ }
+ lifecyclePhaseListener.add(value);
+ }
+
+ public void addValidator(String id, String validatorClass)
+ {
+ if (validators == null)
+ {
+ validators = new HashMap<>();
+ }
+
+ String oldValidator = validators.get(id);
+ // don't log if someone overwrites the built-in converters
+ if (oldValidator != null && !oldValidator.startsWith("jakarta.faces.validator."))
+ {
+ LOG.warning("There is already a validator defined for id: " + id + "."
+ + " old: " + oldValidator
+ + " new: " + validatorClass);
+ }
+
+ validators.put(id, validatorClass);
+ }
+
+ public void addBehavior(Behavior behavior)
+ {
+ if (behaviors == null)
+ {
+ behaviors = new ArrayList<>();
+ }
+ behaviors.add (behavior);
+ }
+
+ public void addNamedEvent(NamedEvent namedEvent)
+ {
+ if (namedEvents == null)
+ {
+ namedEvents = new ArrayList<>();
+ }
+ namedEvents.add(namedEvent);
+ }
+
+ public void addFacesConfigExtension(FacesConfigExtension elem)
+ {
+ if (facesConfigExtensions == null)
+ {
+ facesConfigExtensions = new ArrayList<>();
+ }
+ facesConfigExtensions.add(elem);
+ }
+
+ public void addFacesFlowDefinition(FacesFlowDefinition elem)
+ {
+ if (facesFlowDefinitions == null)
+ {
+ facesFlowDefinitions = new ArrayList<>();
+ }
+ facesFlowDefinitions.add(elem);
+ }
+
+ public void addProtectedViewUrlPattern(String urlPattern)
+ {
+ if (protectedViewsUrlPatternList == null)
+ {
+ protectedViewsUrlPatternList = new ArrayList<>();
+ }
+ protectedViewsUrlPatternList.add(urlPattern);
+ }
+
+ public void addResourceResolver(String resourceResolverClass)
+ {
+ if (resourceResolvers == null)
+ {
+ resourceResolvers = new ArrayList<>();
+ }
+ resourceResolvers.add(resourceResolverClass);
+ }
+
+ public void addFaceletTagLibrary(FaceletTagLibrary library)
+ {
+ if (faceletTagLibraryList == null)
+ {
+ faceletTagLibraryList = new ArrayList<>();
+ }
+ faceletTagLibraryList.add(library);
+ }
+
+ @Override
+ public List<Application> getApplications()
+ {
+ if (applications == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableApplications == null)
+ {
+ unmodifiableApplications = Collections.unmodifiableList(applications);
+ }
+ return unmodifiableApplications;
+ }
+
+ @Override
+ public List<Factory> getFactories()
+ {
+ if (factories == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableFactories == null)
+ {
+ unmodifiableFactories = Collections.unmodifiableList(factories);
+ }
+ return unmodifiableFactories;
+ }
+
+ @Override
+ public List<Component> getComponents()
+ {
+ if (components == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableComponents == null)
+ {
+ unmodifiableComponents = Collections.unmodifiableList(components);
+ }
+ return unmodifiableComponents;
+ }
+
+ @Override
+ public Map<String, ComponentTagDeclaration> getComponentTagDeclarations()
+ {
+ if (componentTagDeclarations == null)
+ {
+ return Collections.emptyMap();
+ }
+ if (unmodifiableComponentTagDeclarations == null)
+ {
+ unmodifiableComponentTagDeclarations = Collections.unmodifiableMap(componentTagDeclarations);
+ }
+ return unmodifiableComponentTagDeclarations;
+ }
+
+ @Override
+ public List<Converter> getConverters()
+ {
+ if (converters == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableConverters == null)
+ {
+ unmodifiableConverters = Collections.unmodifiableList(converters);
+ }
+ return unmodifiableConverters;
+ }
+
+ @Override
+ public List<NavigationRule> getNavigationRules()
+ {
+ if (navigationRules == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableNavigationRules == null)
+ {
+ unmodifiableNavigationRules = Collections.unmodifiableList(navigationRules);
+ }
+ return unmodifiableNavigationRules;
+ }
+
+ @Override
+ public List<RenderKit> getRenderKits()
+ {
+ if (renderKits == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableRenderKits == null)
+ {
+ unmodifiableRenderKits = Collections.unmodifiableList(renderKits);
+ }
+ return unmodifiableRenderKits;
+ }
+
+ @Override
+ public List<String> getLifecyclePhaseListener()
+ {
+ if (lifecyclePhaseListener == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableLifecyclePhaseListener == null)
+ {
+ unmodifiableLifecyclePhaseListener = Collections.unmodifiableList(lifecyclePhaseListener);
+ }
+ return unmodifiableLifecyclePhaseListener;
+ }
+
+ @Override
+ public Map<String, String> getValidators()
+ {
+ if (validators == null)
+ {
+ return Collections.emptyMap();
+ }
+ if (unmodifiableValidators == null)
+ {
+ unmodifiableValidators = Collections.unmodifiableMap(validators);
+ }
+ return unmodifiableValidators;
+ }
+
+ @Override
+ public List<Behavior> getBehaviors ()
+ {
+ if (behaviors == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableBehaviors == null)
+ {
+ unmodifiableBehaviors = Collections.unmodifiableList(behaviors);
+ }
+ return unmodifiableBehaviors;
+ }
+
+ @Override
+ public List<NamedEvent> getNamedEvents()
+ {
+ if (namedEvents == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableNamedEvents == null)
+ {
+ unmodifiableNamedEvents = Collections.unmodifiableList(namedEvents);
+ }
+ return unmodifiableNamedEvents;
+ }
+
+ @Override
+ public RenderKit getRenderKit(String renderKitId)
+ {
+ for (RenderKit rk : getRenderKits())
+ {
+ if (renderKitId != null && renderKitId.equals(rk.getId()))
+ {
+ return rk;
+ }
+ else if (renderKitId == null && rk.getId() == null)
+ {
+ return rk;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ public org.apache.myfaces.config.element.AbsoluteOrdering getAbsoluteOrdering()
+ {
+ return absoluteOrdering;
+ }
+
+ public void setAbsoluteOrdering(org.apache.myfaces.config.element.AbsoluteOrdering absoluteOrdering)
+ {
+ this.absoluteOrdering = absoluteOrdering;
+ }
+
+ @Override
+ public org.apache.myfaces.config.element.Ordering getOrdering()
+ {
+ return ordering;
+ }
+
+ public void setOrdering(org.apache.myfaces.config.element.Ordering ordering)
+ {
+ this.ordering = ordering;
+ }
+
+ @Override
+ public String getMetadataComplete()
+ {
+ return metadataComplete;
+ }
+
+ public void setMetadataComplete(String metadataComplete)
+ {
+ this.metadataComplete = metadataComplete;
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(String version)
+ {
+ this.version = version;
+ }
+
+ @Override
+ public List<org.apache.myfaces.config.element.FacesConfigExtension> getFacesConfigExtensions()
+ {
+ if (facesConfigExtensions == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableFacesConfigExtensions == null)
+ {
+ unmodifiableFacesConfigExtensions = Collections.unmodifiableList(facesConfigExtensions);
+ }
+ return unmodifiableFacesConfigExtensions;
+ }
+
+ @Override
+ public List<FacesFlowDefinition> getFacesFlowDefinitions()
+ {
+ if (facesFlowDefinitions == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableFacesFlowDefinitions == null)
+ {
+ unmodifiableFacesFlowDefinitions = Collections.unmodifiableList(facesFlowDefinitions);
+ }
+ return unmodifiableFacesFlowDefinitions;
+ }
+
+ @Override
+ public List<String> getProtectedViewsUrlPatternList()
+ {
+ if (protectedViewsUrlPatternList == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableProtectedViewsUrlPatternList == null)
+ {
+ unmodifiableProtectedViewsUrlPatternList = Collections.unmodifiableList(protectedViewsUrlPatternList);
+ }
+ return unmodifiableProtectedViewsUrlPatternList;
+ }
+
+ @Override
+ public List<String> getResourceResolversList()
+ {
+ if (resourceResolvers == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableResourceResolvers == null)
+ {
+ unmodifiableResourceResolvers = Collections.unmodifiableList(resourceResolvers);
+ }
+ return unmodifiableResourceResolvers;
+ }
+
+ @Override
+ public List<FaceletTagLibrary> getFaceletTagLibraryList()
+ {
+ if (faceletTagLibraryList == null)
+ {
+ return Collections.emptyList();
+ }
+ if (unmodifiableFaceletTagLibraryList == null)
+ {
+ unmodifiableFaceletTagLibraryList = Collections.unmodifiableList(faceletTagLibraryList);
+ }
+ return unmodifiableFaceletTagLibraryList;
+ }
+}