You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/04/21 21:06:35 UTC
svn commit: r767260 - in /myfaces/core/branches/2_0_0/impl/src:
main/java/org/apache/myfaces/config/
main/java/org/apache/myfaces/config/impl/digester/
main/java/org/apache/myfaces/config/impl/digester/elements/
main/resources/org/apache/myfaces/resour...
Author: lu4242
Date: Tue Apr 21 19:06:35 2009
New Revision: 767260
URL: http://svn.apache.org/viewvc?rev=767260&view=rev
Log:
MYFACES-2171 Add Config Ordering feature
Added:
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java (with props)
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java (with props)
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java (with props)
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java (with props)
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml (with props)
myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml (with props)
Modified:
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/impl/digister/DigesterFacesConfigUnmarshallerImplTest.java
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=767260&r1=767259&r2=767260&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Tue Apr 21 19:06:35 2009
@@ -29,9 +29,12 @@
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -70,7 +73,10 @@
import org.apache.myfaces.config.element.Renderer;
import org.apache.myfaces.config.impl.digester.DigesterFacesConfigDispenserImpl;
import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
+import org.apache.myfaces.config.impl.digester.elements.ConfigOthersSlot;
import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
+import org.apache.myfaces.config.impl.digester.elements.FacesConfigNameSlot;
+import org.apache.myfaces.config.impl.digester.elements.OrderSlot;
import org.apache.myfaces.config.impl.digester.elements.ResourceBundle;
import org.apache.myfaces.context.FacesContextFactoryImpl;
import org.apache.myfaces.el.DefaultPropertyResolver;
@@ -315,11 +321,21 @@
{
try
{
+ //1. Feed standard-faces-config.xml first.
feedStandardConfig();
+ //2. Feed META-INF/services factories
feedMetaInfServicesFactories();
- feedClassloaderConfigurations();
- feedContextSpecifiedConfig();
- feedWebAppConfig();
+
+ //3. Retrieve all appConfigResources
+ List<FacesConfig> appConfigResources = new ArrayList<FacesConfig>();
+ addClassloaderConfigurations(appConfigResources);
+ addContextSpecifiedConfig(appConfigResources);
+
+ //4. Retrieve webAppFacesConfig
+ FacesConfig webAppFacesConfig = getWebAppConfig();
+
+ //5. Ordering of Artifacts (see section 11.4.7 of the spec)
+ orderAndFeedArtifacts(appConfigResources,webAppFacesConfig);
if (log.isInfoEnabled())
{
@@ -534,7 +550,7 @@
/**
* This method fixes MYFACES-208
*/
- private void feedClassloaderConfigurations()
+ private void addClassloaderConfigurations(List<FacesConfig> appConfigResources)
{
try
{
@@ -557,7 +573,8 @@
{
log.info("Reading config : " + entry.getKey());
}
- getDispenser().feed(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
+ appConfigResources.add(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
+ //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, entry.getKey()));
}
finally
{
@@ -574,7 +591,7 @@
}
}
- private void feedContextSpecifiedConfig() throws IOException, SAXException
+ private void addContextSpecifiedConfig(List<FacesConfig> appConfigResources) throws IOException, SAXException
{
for (String systemId : getConfigFilesList())
{
@@ -589,7 +606,8 @@
{
log.info("Reading config " + systemId);
}
- getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId));
+ appConfigResources.add(getUnmarshaller().getFacesConfig(stream, systemId));
+ //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId));
stream.close();
}
}
@@ -623,17 +641,734 @@
return configFilesList;
}
- private void feedWebAppConfig() throws IOException, SAXException
+ private FacesConfig getWebAppConfig() throws IOException, SAXException
{
+ FacesConfig webAppConfig = null;
// web application config
InputStream stream = _externalContext.getResourceAsStream(DEFAULT_FACES_CONFIG);
if (stream != null)
{
if (log.isInfoEnabled())
log.info("Reading config /WEB-INF/faces-config.xml");
- getDispenser().feed(getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG));
+ webAppConfig = getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG);
+ //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, DEFAULT_FACES_CONFIG));
stream.close();
}
+ return webAppConfig;
+ }
+
+ protected void orderAndFeedArtifacts(List<FacesConfig> appConfigResources, FacesConfig webAppConfig)
+ throws FacesException
+ {
+ if (webAppConfig != null && webAppConfig.getAbsoluteOrdering() != null)
+ {
+ if (webAppConfig.getOrdering() != null)
+ {
+ if (log.isWarnEnabled())
+ {
+ log.warn("<ordering> element found in application faces config. " +
+ "This description will be ignored and the actions described " +
+ "in <absolute-ordering> element will be taken into account instead.");
+ }
+ }
+ //Absolute ordering
+
+ //1. Scan all appConfigResources and create a list
+ //containing all resources not mentioned directly, preserving the
+ //order founded
+ List<FacesConfig> othersResources = new ArrayList<FacesConfig>();
+ List<OrderSlot> slots = webAppConfig.getAbsoluteOrdering().getOrderList();
+ for (FacesConfig resource : appConfigResources)
+ {
+ if (resource.getName() != null && containsResourceInSlot(slots, resource.getName()))
+ {
+ othersResources.add(resource);
+ }
+ }
+
+ //2. Scan slot by slot and merge information according
+ for (OrderSlot slot : webAppConfig.getAbsoluteOrdering().getOrderList())
+ {
+ if (slot instanceof ConfigOthersSlot)
+ {
+ //Add all mentioned in othersResources
+ for (FacesConfig resource : othersResources)
+ {
+ getDispenser().feed(resource);
+ }
+ }
+ else
+ {
+ //Add it to the sorted list
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ getDispenser().feed(getFacesConfig(appConfigResources, nameSlot.getName()));
+ }
+ }
+ }
+ else
+ {
+ //Relative ordering
+ for (FacesConfig resource : appConfigResources)
+ {
+ if (resource.getOrdering() != null)
+ {
+ if (log.isWarnEnabled())
+ {
+ log.warn("<absolute-ordering> element found in application " +
+ "configuration resource "+resource.getName()+". " +
+ "This description will be ignored and the actions described " +
+ "in <ordering> elements will be taken into account instead.");
+ }
+ }
+ }
+
+ List<FacesConfig> postOrderedList = getPostOrderedList(appConfigResources);
+
+ List<FacesConfig> sortedList = sortRelativeOrderingList(postOrderedList);
+
+ for (FacesConfig resource : sortedList)
+ {
+ //Feed
+ getDispenser().feed(resource);
+ }
+ }
+ getDispenser().feed(webAppConfig);
+ }
+
+ /**
+ * Sort a list of pre ordered elements. It scans one by one the elements
+ * and apply the conditions mentioned by Ordering object if it is available.
+ *
+ * The preOrderedList ensures that application config resources referenced by
+ * other resources are processed first, making more easier the sort procedure.
+ *
+ * @param preOrderedList
+ * @return
+ */
+ protected List<FacesConfig> sortRelativeOrderingList(List<FacesConfig> preOrderedList) throws FacesException
+ {
+ List<FacesConfig> sortedList = new ArrayList<FacesConfig>();
+
+ for (int i=0; i < preOrderedList.size(); i++)
+ {
+ FacesConfig resource = preOrderedList.get(i);
+ if (resource.getOrdering() != null)
+ {
+ if (resource.getOrdering().getBeforeList().isEmpty() &&
+ resource.getOrdering().getAfterList().isEmpty())
+ {
+ //No order rules, just put it as is
+ sortedList.add(resource);
+ }
+ else if (resource.getOrdering().getBeforeList().isEmpty())
+ {
+ //Only after rules
+ applyAfterRule(sortedList, resource);
+ }
+ else if (resource.getOrdering().getAfterList().isEmpty())
+ {
+ //Only before rules
+
+ //Resolve if there is a later reference to this node before
+ //apply it
+ boolean referenceNode = false;
+
+ for (int j = i+1; j < preOrderedList.size(); j++)
+ {
+ FacesConfig pointingResource = preOrderedList.get(j);
+ for (OrderSlot slot : pointingResource.getOrdering().getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot &&
+ resource.getName().equals(((FacesConfigNameSlot)slot).getName()) )
+ {
+ referenceNode = true;
+ }
+ if (slot instanceof ConfigOthersSlot)
+ {
+ //No matter if there is a reference, because this rule
+ //is not strict and before other ordering is unpredictable.
+ //
+ referenceNode = false;
+ break;
+ }
+ }
+ if (referenceNode)
+ {
+ break;
+ }
+ for (OrderSlot slot : pointingResource.getOrdering().getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot &&
+ resource.getName().equals(((FacesConfigNameSlot)slot).getName()) )
+ {
+ referenceNode = true;
+ break;
+ }
+ }
+ }
+
+ applyBeforeRule(sortedList, resource, referenceNode);
+ }
+ else
+ {
+ //Both before and after rules
+ //In this case we should compare before and after rules
+ //and the one with names takes precedence over the other one.
+ //It both have names references, before rules takes
+ //precedence over after
+ //after some action is applied a check of the condition is made.
+ int beforeWeight = 0;
+ int afterWeight = 0;
+ for (OrderSlot slot : resource.getOrdering()
+ .getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ beforeWeight++;
+ }
+ }
+ for (OrderSlot slot : resource.getOrdering()
+ .getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ afterWeight++;
+ }
+ }
+
+ if (beforeWeight >= afterWeight)
+ {
+ applyBeforeRule(sortedList, resource,false);
+ }
+ else
+ {
+ applyAfterRule(sortedList, resource);
+ }
+
+
+ }
+ }
+ else
+ {
+ //No order rules, just put it as is
+ sortedList.add(resource);
+ }
+ }
+
+ //Check
+ for (int i = 0; i < sortedList.size(); i++)
+ {
+ FacesConfig resource = sortedList.get(i);
+
+ if (resource.getOrdering() != null)
+ {
+ for (OrderSlot slot : resource.getOrdering().getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ String name = ((FacesConfigNameSlot) slot).getName();
+ if (name != null && !"".equals(name))
+ {
+ boolean founded = false;
+ for (int j = i-1; j >= 0; j--)
+ {
+ if (name.equals(sortedList.get(j).getName()))
+ {
+ founded=true;
+ break;
+ }
+ }
+ if (founded)
+ {
+ log.fatal("Circular references detected when sorting " +
+ "application config resources. Use absolute ordering instead.");
+ throw new FacesException("Circular references detected when sorting " +
+ "application config resources. Use absolute ordering instead.");
+ }
+ }
+ }
+ }
+ for (OrderSlot slot : resource.getOrdering().getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ String name = ((FacesConfigNameSlot) slot).getName();
+ if (name != null && !"".equals(name))
+ {
+ boolean founded = false;
+ for (int j = i+1; j < sortedList.size(); j++)
+ {
+ if (name.equals(sortedList.get(j).getName()))
+ {
+ founded=true;
+ break;
+ }
+ }
+ if (founded)
+ {
+ log.fatal("Circular references detected when sorting " +
+ "application config resources. Use absolute ordering instead.");
+ throw new FacesException("Circular references detected when sorting " +
+ "application config resources. Use absolute ordering instead.");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return sortedList;
+ }
+
+ private void applyBeforeRule(List<FacesConfig> sortedList, FacesConfig resource, boolean referenced) throws FacesException
+ {
+ //Only before rules
+ boolean configOthers = false;
+ List<String> names = new ArrayList<String>();
+
+ for (OrderSlot slot : resource.getOrdering().getBeforeList())
+ {
+ if (slot instanceof ConfigOthersSlot)
+ {
+ configOthers = true;
+ break;
+ }
+ else
+ {
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ names.add(nameSlot.getName());
+ }
+ }
+
+ if (configOthers)
+ {
+ //<before>....<others/></before> case
+ //other reference where already considered when
+ //pre ordered list was calculated, so just add to the end.
+
+ //There is one very special case, and it is when there
+ //is another resource with a reference on it. In this case,
+ //it is better do not apply this rule and add it to the end
+ //to give the chance to the other one to be applied.
+ if (resource.getOrdering().getBeforeList().size() > 1)
+ {
+ //If there is a reference apply it
+ sortedList.add(0,resource);
+ }
+ else if (!referenced)
+ {
+ //If it is not referenced apply it
+ sortedList.add(0,resource);
+ }
+ else
+ {
+ //if it is referenced bypass the rule and add it to the end
+ sortedList.add(resource);
+ }
+ }
+ else
+ {
+ //Scan the nearest reference and add it after
+ boolean founded = false;
+ for (int i = 0; i < sortedList.size() ; i++)
+ {
+ if (names.contains(sortedList.get(i).getName()))
+ {
+ sortedList.add(i,resource);
+ founded = true;
+ break;
+ }
+ }
+ if (!founded)
+ {
+ //just add it to the end
+ sortedList.add(resource);
+ }
+ }
+ }
+
+ private void applyAfterRule(List<FacesConfig> sortedList, FacesConfig resource) throws FacesException
+ {
+ boolean configOthers = false;
+ List<String> names = new ArrayList<String>();
+
+ for (OrderSlot slot : resource.getOrdering().getAfterList())
+ {
+ if (slot instanceof ConfigOthersSlot)
+ {
+ configOthers = true;
+ break;
+ }
+ else
+ {
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ names.add(nameSlot.getName());
+ }
+ }
+
+ if (configOthers)
+ {
+ //<after>....<others/></after> case
+ //other reference where already considered when
+ //pre ordered list was calculated, so just add to the end.
+ sortedList.add(resource);
+ }
+ else
+ {
+ //Scan the nearest reference and add it after
+ boolean founded = false;
+ for (int i = sortedList.size()-1 ; i >=0 ; i--)
+ {
+ if (names.contains(sortedList.get(i).getName()))
+ {
+ if (i+1 < sortedList.size())
+ {
+ sortedList.add(i+1,resource);
+ }
+ else
+ {
+ sortedList.add(resource);
+ }
+ founded = true;
+ break;
+ }
+ }
+ if (!founded)
+ {
+ //just add it to the end
+ sortedList.add(resource);
+ }
+ }
+ }
+
+
+ /**
+ * Pre Sort the appConfigResources, detecting cyclic references, so when sort process
+ * start, it is just necessary to traverse the preOrderedList once. To do that, we just
+ * scan "before" and "after" lists for references, and then those references are traversed
+ * again, so the first elements of the pre ordered list does not have references and
+ * the next elements has references to the already added ones.
+ *
+ * The elements on the preOrderedList looks like this:
+ *
+ * [ no ordering elements , referenced elements ... more referenced elements,
+ * before others / after others non referenced elements]
+ *
+ * @param appConfigResources
+ * @return
+ */
+ protected List<FacesConfig> getPostOrderedList(final List<FacesConfig> appConfigResources) throws FacesException
+ {
+
+ List<FacesConfig> appFilteredConfigResources = new ArrayList<FacesConfig>();
+
+ //0. Clean up: remove all not found resource references from the ordering
+ //descriptions.
+ List<String> availableReferences = new ArrayList<String>();
+ for (FacesConfig resource : appFilteredConfigResources)
+ {
+ String name = resource.getName();
+ if (name != null && "".equals(name))
+ {
+ availableReferences.add(name);
+ }
+ }
+
+ for (FacesConfig resource : appFilteredConfigResources)
+ {
+ for (Iterator<OrderSlot> it = resource.getOrdering().getBeforeList().iterator();it.hasNext();)
+ {
+ OrderSlot slot = it.next();
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ String name = ((FacesConfigNameSlot) slot).getName();
+ if (!availableReferences.contains(name))
+ {
+ it.remove();
+ }
+ }
+ }
+ for (Iterator<OrderSlot> it = resource.getOrdering().getAfterList().iterator();it.hasNext();)
+ {
+ OrderSlot slot = it.next();
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ String name = ((FacesConfigNameSlot) slot).getName();
+ if (!availableReferences.contains(name))
+ {
+ it.remove();
+ }
+ }
+ }
+ }
+
+ //1. Pre filtering: Sort nodes according to its weight. The weight is the number of named
+ //nodes containing in both before and after lists. The sort is done from the more complex
+ //to the most simple
+ if (appConfigResources instanceof ArrayList)
+ {
+ appFilteredConfigResources = (List<FacesConfig>)
+ ((ArrayList<FacesConfig>)appConfigResources).clone();
+ }
+ else
+ {
+ appFilteredConfigResources = new ArrayList<FacesConfig>();
+ appFilteredConfigResources.addAll(appConfigResources);
+ }
+ Collections.sort(appFilteredConfigResources,
+ new Comparator<FacesConfig>()
+ {
+ public int compare(FacesConfig o1, FacesConfig o2)
+ {
+ int o1Weight = 0;
+ int o2Weight = 0;
+ if (o1.getOrdering() != null)
+ {
+ for (OrderSlot slot : o1.getOrdering()
+ .getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ o1Weight++;
+ }
+ }
+ for (OrderSlot slot : o1.getOrdering()
+ .getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ o1Weight++;
+ }
+ }
+ }
+ if (o2.getOrdering() != null)
+ {
+ for (OrderSlot slot : o2.getOrdering()
+ .getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ o2Weight++;
+ }
+ }
+ for (OrderSlot slot : o2.getOrdering()
+ .getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ o2Weight++;
+ }
+ }
+ }
+ return o2Weight - o1Weight;
+ }
+ });
+
+ List<FacesConfig> postOrderedList = new LinkedList<FacesConfig>();
+ List<FacesConfig> othersList = new ArrayList<FacesConfig>();
+
+ List<String> nameBeforeStack = new ArrayList<String>();
+ List<String> nameAfterStack = new ArrayList<String>();
+
+ boolean[] visitedSlots = new boolean[appFilteredConfigResources.size()];
+
+ //2. Scan and resolve conflicts
+ for (int i = 0; i < appFilteredConfigResources.size(); i++)
+ {
+ if (!visitedSlots[i])
+ {
+ resolveConflicts(appFilteredConfigResources, i, visitedSlots,
+ nameBeforeStack, nameAfterStack, postOrderedList, othersList, false);
+ }
+ }
+
+ //Add othersList to postOrderedList so <before><others/></before> and <after><others/></after>
+ //ordering conditions are handled at last if there are not referenced by anyone
+ postOrderedList.addAll(othersList);
+
+ return postOrderedList;
+ }
+
+ private void resolveConflicts(final List<FacesConfig> appConfigResources, int index, boolean[] visitedSlots,
+ List<String> nameBeforeStack, List<String> nameAfterStack, List<FacesConfig> postOrderedList,
+ List<FacesConfig> othersList, boolean indexReferenced) throws FacesException
+ {
+ FacesConfig facesConfig = appConfigResources.get(index);
+
+ if (nameBeforeStack.contains(facesConfig.getName()))
+ {
+ //Already referenced, just return. Later if there exists a
+ //circular reference, it will be detected and solved.
+ return;
+ }
+
+ if (nameAfterStack.contains(facesConfig.getName()))
+ {
+ //Already referenced, just return. Later if there exists a
+ //circular reference, it will be detected and solved.
+ return;
+ }
+
+ if (facesConfig.getOrdering() != null)
+ {
+ boolean pointingResource = false;
+
+ //Deal with before restrictions first
+ for (OrderSlot slot : facesConfig.getOrdering().getBeforeList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ //The resource pointed is not added yet?
+ boolean alreadyAdded = false;
+ for (FacesConfig res : postOrderedList)
+ {
+ if (nameSlot.getName().equals(res.getName()))
+ {
+ alreadyAdded = true;
+ break;
+ }
+ }
+ if (!alreadyAdded)
+ {
+ int indexSlot = -1;
+ //Find it
+ for (int i = 0; i < appConfigResources.size(); i++)
+ {
+ FacesConfig resource = appConfigResources.get(i);
+ if (resource.getName() != null && nameSlot.getName().equals(resource.getName()))
+ {
+ indexSlot = i;
+ break;
+ }
+ }
+
+ //Resource founded on appConfigResources
+ if (indexSlot != -1)
+ {
+ pointingResource = true;
+ //Add to nameStac
+ nameBeforeStack.add(facesConfig.getName());
+
+ resolveConflicts(appConfigResources, indexSlot, visitedSlots,
+ nameBeforeStack, nameAfterStack, postOrderedList,
+ othersList,true);
+
+ nameBeforeStack.remove(facesConfig.getName());
+ }
+ }
+ else
+ {
+ pointingResource = true;
+ }
+ }
+ }
+
+ for (OrderSlot slot : facesConfig.getOrdering().getAfterList())
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ //The resource pointed is not added yet?
+ boolean alreadyAdded = false;
+ for (FacesConfig res : postOrderedList)
+ {
+ if (nameSlot.getName().equals(res.getName()))
+ {
+ alreadyAdded = true;
+ break;
+ }
+ }
+ if (!alreadyAdded)
+ {
+ int indexSlot = -1;
+ //Find it
+ for (int i = 0; i < appConfigResources.size(); i++)
+ {
+ FacesConfig resource = appConfigResources.get(i);
+ if (resource.getName() != null && nameSlot.getName().equals(resource.getName()))
+ {
+ indexSlot = i;
+ break;
+ }
+ }
+
+ //Resource founded on appConfigResources
+ if (indexSlot != -1)
+ {
+ pointingResource = true;
+ //Add to nameStac
+ nameAfterStack.add(facesConfig.getName());
+
+ resolveConflicts(appConfigResources, indexSlot, visitedSlots,
+ nameBeforeStack, nameAfterStack, postOrderedList,
+ othersList,true);
+
+ nameAfterStack.remove(facesConfig.getName());
+ }
+ }
+ else
+ {
+ pointingResource = true;
+ }
+ }
+ }
+
+ if (facesConfig.getOrdering().getBeforeList().isEmpty() &&
+ facesConfig.getOrdering().getAfterList().isEmpty())
+ {
+ //Fits in the category "others", put at beginning
+ postOrderedList.add(0,appConfigResources.get(index));
+ }
+ else if (pointingResource || indexReferenced)
+ {
+ //If the node points to other or is referenced from other,
+ //add to the postOrderedList at the end
+ postOrderedList.add(appConfigResources.get(index));
+ }
+ else
+ {
+ //Add to othersList
+ othersList.add(appConfigResources.get(index));
+ }
+ }
+ else
+ {
+ //Add at start of the list, since does not have any ordering
+ //instructions and on the next step makes than "before others" and "after others"
+ //works correctly
+ postOrderedList.add(0,appConfigResources.get(index));
+ }
+ //Set the node as visited
+ visitedSlots[index] = true;
+ }
+
+ private FacesConfig getFacesConfig(List<FacesConfig> appConfigResources, String name)
+ {
+ for (FacesConfig cfg: appConfigResources)
+ {
+ if (cfg.getName() != null && name.equals(cfg.getName()));
+ {
+ return cfg;
+ }
+ }
+ return null;
+ }
+
+ private boolean containsResourceInSlot(List<OrderSlot> slots, String name)
+ {
+ for (OrderSlot slot: slots)
+ {
+ if (slot instanceof FacesConfigNameSlot)
+ {
+ FacesConfigNameSlot nameSlot = (FacesConfigNameSlot) slot;
+ if (name.equals(nameSlot.getName()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
}
private void configureFactories()
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=767260&r1=767259&r2=767260&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java Tue Apr 21 19:06:35 2009
@@ -46,6 +46,31 @@
digester.setUseContextClassLoader(true);
digester.addObjectCreate("faces-config", FacesConfig.class);
+ // 2.0 config ordering name start
+ digester.addCallMethod("faces-config/name", "setName", 0);
+ digester.addObjectCreate("faces-config/ordering", Ordering.class);
+ digester.addSetNext("faces-config/ordering", "setOrdering");
+ digester.addObjectCreate("faces-config/ordering/before/name", FacesConfigNameSlot.class);
+ digester.addSetNext("faces-config/ordering/before/name", "addBeforeSlot");
+ digester.addCallMethod("faces-config/ordering/before/name", "setName",0);
+ digester.addObjectCreate("faces-config/ordering/before/others", ConfigOthersSlot.class);
+ digester.addSetNext("faces-config/ordering/before/others", "addBeforeSlot");
+
+ digester.addObjectCreate("faces-config/ordering/after/name", FacesConfigNameSlot.class);
+ digester.addSetNext("faces-config/ordering/after/name", "addAfterSlot");
+ digester.addCallMethod("faces-config/ordering/after/name", "setName",0);
+ digester.addObjectCreate("faces-config/ordering/after/others", ConfigOthersSlot.class);
+ digester.addSetNext("faces-config/ordering/after/others", "addAfterSlot");
+
+ digester.addObjectCreate("faces-config/absolute-ordering", AbsoluteOrdering.class);
+ digester.addSetNext("faces-config/absolute-ordering", "setAbsoluteOrdering");
+ digester.addObjectCreate("faces-config/absolute-ordering/name", FacesConfigNameSlot.class);
+ digester.addSetNext("faces-config/absolute-ordering/name", "addOrderSlot");
+ digester.addCallMethod("faces-config/absolute-ordering/name", "setName",0);
+ digester.addObjectCreate("faces-config/absolute-ordering/others", ConfigOthersSlot.class);
+ digester.addSetNext("faces-config/absolute-ordering/others", "addOrderSlot");
+ // 2.0 config ordering name end
+
digester.addObjectCreate("faces-config/application", Application.class);
digester.addSetNext("faces-config/application", "addApplication");
digester.addCallMethod("faces-config/application/action-listener", "addActionListener", 0);
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java Tue Apr 21 19:06:35 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.digester.elements;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AbsoluteOrdering
+{
+ private List<OrderSlot> orderList = new ArrayList<OrderSlot>();
+
+ public void addOrderSlot(OrderSlot slot)
+ {
+ orderList.add(slot);
+ }
+
+ public List<OrderSlot> getOrderList()
+ {
+ return orderList;
+ }
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/AbsoluteOrdering.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java Tue Apr 21 19:06:35 2009
@@ -0,0 +1,24 @@
+/*
+ * 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.digester.elements;
+
+public class ConfigOthersSlot implements OrderSlot
+{
+
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/ConfigOthersSlot.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java?rev=767260&r1=767259&r2=767260&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfig.java Tue Apr 21 19:06:35 2009
@@ -38,6 +38,13 @@
private List<RenderKit> renderKits = new ArrayList<RenderKit>();
private List<String> lifecyclePhaseListener = new ArrayList<String>();
private Map<String, String> validators = new HashMap<String, String>();
+
+ //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)
{
@@ -128,4 +135,34 @@
{
return validators;
}
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public AbsoluteOrdering getAbsoluteOrdering()
+ {
+ return absoluteOrdering;
+ }
+
+ public void setAbsoluteOrdering(AbsoluteOrdering absoluteOrdering)
+ {
+ this.absoluteOrdering = absoluteOrdering;
+ }
+
+ public Ordering getOrdering()
+ {
+ return ordering;
+ }
+
+ public void setOrdering(Ordering ordering)
+ {
+ this.ordering = ordering;
+ }
}
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java Tue Apr 21 19:06:35 2009
@@ -0,0 +1,34 @@
+/*
+ * 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.digester.elements;
+
+public class FacesConfigNameSlot implements OrderSlot
+{
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/FacesConfigNameSlot.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java Tue Apr 21 19:06:35 2009
@@ -0,0 +1,24 @@
+/*
+ * 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.digester.elements;
+
+public interface OrderSlot
+{
+
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/OrderSlot.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java Tue Apr 21 19:06:35 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.digester.elements;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Ordering
+{
+
+ private List<OrderSlot> beforeList = new ArrayList<OrderSlot>();
+ private List<OrderSlot> afterList = new ArrayList<OrderSlot>();
+
+ public void addBeforeSlot(OrderSlot slot)
+ {
+ beforeList.add(slot);
+ }
+
+ public List<OrderSlot> getBeforeList()
+ {
+ return beforeList;
+ }
+
+ public void addAfterSlot(OrderSlot slot)
+ {
+ afterList.add(slot);
+ }
+
+ public List<OrderSlot> getAfterList()
+ {
+ return afterList;
+ }
+}
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Ordering.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd?rev=767260&r1=767259&r2=767260&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/resources/org/apache/myfaces/resource/web-facesconfig_2_0.xsd Tue Apr 21 19:06:35 2009
@@ -53,10 +53,13 @@
<xsd:complexType name="faces-configType">
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element name="application" type="javaee:faces-config-applicationType"/>
+ <xsd:element name="ordering" type="javaee:faces-config-orderingType"/>
+ <xsd:element name="absolute-ordering" type="javaee:faces-config-absoluteOrderingType"/>
<xsd:element name="factory" type="javaee:faces-config-factoryType"/>
<xsd:element name="component" type="javaee:faces-config-componentType"/>
<xsd:element name="converter" type="javaee:faces-config-converterType"/>
<xsd:element name="managed-bean" type="javaee:faces-config-managed-beanType"/>
+ <xsd:element name="name" type="javaee:java-identifierType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="navigation-rule" type="javaee:faces-config-navigation-ruleType"/>
<xsd:element name="referenced-bean" type="javaee:faces-config-referenced-beanType"/>
<xsd:element name="render-kit" type="javaee:faces-config-render-kitType"/>
@@ -96,6 +99,31 @@
</xsd:choice>
<xsd:attribute name="id" type="xsd:ID"/>
</xsd:complexType>
+
+ <xsd:complexType name="faces-config-orderingType">
+ <xsd:sequence>
+ <xsd:element name="after" type="javaee:faces-config-ordering-orderingType" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="before" type="javaee:faces-config-ordering-orderingType" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="faces-config-ordering-orderingType">
+ <xsd:sequence>
+ <xsd:element name="name" type="javaee:java-identifierType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="others" type="javaee:faces-config-ordering-othersType" minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="faces-config-ordering-othersType">
+ <xsd:attribute name="id" type="xsd:ID"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="faces-config-absoluteOrderingType">
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="name" type="javaee:java-identifierType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="others" type="javaee:faces-config-ordering-othersType" minOccurs="0" maxOccurs="1" />
+ </xsd:choice>
+ </xsd:complexType>
<xsd:complexType name="faces-config-application-resource-bundleType">
<xsd:sequence>
Modified: myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/impl/digister/DigesterFacesConfigUnmarshallerImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/impl/digister/DigesterFacesConfigUnmarshallerImplTest.java?rev=767260&r1=767259&r2=767260&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/impl/digister/DigesterFacesConfigUnmarshallerImplTest.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/test/java/org/apache/myfaces/config/impl/digister/DigesterFacesConfigUnmarshallerImplTest.java Tue Apr 21 19:06:35 2009
@@ -15,14 +15,17 @@
*/
package org.apache.myfaces.config.impl.digister;
+import java.util.List;
+
+import junit.framework.TestCase;
+
import org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl;
import org.apache.myfaces.config.impl.digester.elements.Application;
+import org.apache.myfaces.config.impl.digester.elements.ConfigOthersSlot;
import org.apache.myfaces.config.impl.digester.elements.FacesConfig;
+import org.apache.myfaces.config.impl.digester.elements.FacesConfigNameSlot;
import org.apache.myfaces.config.impl.digester.elements.LocaleConfig;
-
-import java.util.List;
-
-import junit.framework.TestCase;
+import org.apache.myfaces.config.impl.digester.elements.OrderSlot;
/**
* @author Mathias Broekelmann (latest modification by $Author$)
@@ -103,4 +106,55 @@
assertEquals("aa", cfg.getSupportedLocales().get(0));
assertEquals("bb", cfg.getSupportedLocales().get(1));
}
+
+ public void testAbsoluteOrderingConfig() throws Exception
+ {
+ FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream(
+ "absolute-ordering-config.xml"), "absolute-ordering-config.xml");
+ assertNotNull(cfg);
+ assertEquals("a",cfg.getName());
+
+ List<OrderSlot> orderList = cfg.getAbsoluteOrdering().getOrderList();
+
+ assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName());
+ assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName());
+ assertEquals(ConfigOthersSlot.class, orderList.get(2).getClass());
+ assertEquals("d", ((FacesConfigNameSlot) orderList.get(3)).getName());
+
+ assertTrue(cfg.getApplications().isEmpty());
+ assertTrue(cfg.getComponents().isEmpty());
+ assertTrue(cfg.getConverters().isEmpty());
+ assertTrue(cfg.getFactories().isEmpty());
+ assertTrue(cfg.getLifecyclePhaseListener().isEmpty());
+ assertTrue(cfg.getManagedBeans().isEmpty());
+ assertTrue(cfg.getNavigationRules().isEmpty());
+ assertTrue(cfg.getRenderKits().isEmpty());
+ assertTrue(cfg.getValidators().isEmpty());
+ }
+
+ public void testOrderingConfig() throws Exception
+ {
+ FacesConfig cfg = _impl.getFacesConfig(getClass().getResourceAsStream(
+ "ordering-config.xml"), "ordering-config.xml");
+ assertNotNull(cfg);
+ assertEquals("a",cfg.getName());
+
+ List<OrderSlot> orderList = cfg.getOrdering().getBeforeList();
+ assertEquals("b", ((FacesConfigNameSlot) orderList.get(0)).getName());
+ assertEquals("c", ((FacesConfigNameSlot) orderList.get(1)).getName());
+ assertEquals(ConfigOthersSlot.class, orderList.get(2).getClass());
+
+ orderList = cfg.getOrdering().getAfterList();
+ assertEquals("d", ((FacesConfigNameSlot) orderList.get(0)).getName());
+
+ assertTrue(cfg.getApplications().isEmpty());
+ assertTrue(cfg.getComponents().isEmpty());
+ assertTrue(cfg.getConverters().isEmpty());
+ assertTrue(cfg.getFactories().isEmpty());
+ assertTrue(cfg.getLifecyclePhaseListener().isEmpty());
+ assertTrue(cfg.getManagedBeans().isEmpty());
+ assertTrue(cfg.getNavigationRules().isEmpty());
+ assertTrue(cfg.getRenderKits().isEmpty());
+ assertTrue(cfg.getValidators().isEmpty());
+ }
}
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <name>A</name>
+ <!-- -->
+ <!-- ordering><before><name>B</name></before></ordering> -->
+ <ordering><before><others/></before></ordering>
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/a-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <name>B</name>
+ <!-- ordering><after><name>C</name></after></ordering> -->
+ <!-- ordering><before><name>C</name></before></ordering> -->
+ <ordering><after><name>C</name></after></ordering>
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/b-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <name>C</name>
+ <!-- ordering><before><others/></before></ordering>-->
+ <!-- ordering><before><name>A</name></before></ordering>-->
+ <ordering><after><others/></after></ordering>
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/c-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/empty-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <name>a</name>
+ <absolute-ordering>
+ <name>b</name>
+ <name>c</name>
+ <others/>
+ <name>d</name>
+ </absolute-ordering>
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/absolute-ordering-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml?rev=767260&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml (added)
+++ myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml Tue Apr 21 19:06:35 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+ <name>a</name>
+ <ordering>
+ <before>
+ <name>b</name>
+ <name>c</name>
+ <others/>
+ </before>
+ <after>
+ <name>d</name>
+ </after>
+ </ordering>
+</faces-config>
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/2_0_0/impl/src/test/resources/org/apache/myfaces/config/impl/digister/ordering-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL