myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r639075 - /myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
Date Wed, 19 Mar 2008 23:28:35 GMT
Author: jwaldman
Date: Wed Mar 19 16:28:32 2008
New Revision: 639075

URL: http://svn.apache.org/viewvc?rev=639075&view=rev
Log:
TRINIDAD-1017 different css file hashcodes if same jar with skin-addition in classpath twice
fixed on trunk_1.2.x
Changed SkinUtils.java to check the URL to META-INF/trinidad-skins.xml and don't process an
URL that has already been processed.

Modified:
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java?rev=639075&r1=639074&r2=639075&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
(original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinUtils.java
Wed Mar 19 16:28:32 2008
@@ -28,9 +28,11 @@
 import java.util.Collections;
 import java.util.Enumeration;
 
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 
+import java.util.Set;
 import java.util.Stack;
 
 import javax.faces.context.ExternalContext;
@@ -318,7 +320,7 @@
 
   /**
    * register the Trinidad skins: simpleDesktopSkin, simplePdaSkin,
-   * and minimalDesktopSkin, minimalPdaSkin, and blafPlusDesktopSkin.
+   * and minimalDesktopSkin, minimalPdaSkin, and portlet skins.
    * @param skinFactory
    */
   private static void _registerTrinidadSkins(
@@ -354,10 +356,10 @@
 
   /**
    * Parse the trinidad-skins.xml file for SkinExtensions and SkinAdditionNodes and add each
-   * SkinExtension to the skinFactory.
+   * SkinExtension to the skinFactory and each SkinAddition to its skin.
    * First find all the trinidad-skins.xml files that are in META-INF directory, and 
-   * add those skins to the skin factory.
-   * Then find the WEB-INF/trinidad-skins.xml file and add those skins to the skin factory.
+   * add those skins and skin additions.
+   * Then find the WEB-INF/trinidad-skins.xml file and add those skins and skin additions.
    * The skins are ordered so that the 'extended' skins are registered before the skins that
extend
    * them.
    * @param context
@@ -647,7 +649,7 @@
   }
   
   /**
-   * Get the WEB-INF/trinidad-skins.xml file, parse it, and return a List SkinNode objects.

+   * Get the WEB-INF/trinidad-skins.xml file, parse it, and return a List of SkinsNode objects.

    * @param context ServletContext used to getResourceAsStream
    * @return List of SkinNodes (skin elements) found in trinidad-skins.xml
    */
@@ -680,34 +682,56 @@
         
     List<SkinsNode> allSkinsNodes = new ArrayList<SkinsNode>(); 
     ClassLoader loader = Thread.currentThread().getContextClassLoader();     
-    
+
     try
     {
   
       Enumeration<URL> urls = loader.getResources(_META_INF_CONFIG_FILE);
+      Set<String> urlPaths = new HashSet<String>(16);
+      
       while (urls.hasMoreElements())
       {
         URL url = urls.nextElement();
         
-        _LOG.finest("Processing:{0}", url);
-        try
+        // if url matches one we've already processed, skip it
+        boolean successfullyAdded = urlPaths.add(url.getPath());
+
+        if (!successfullyAdded)
         {
-          // parse the config file and register the skin's additional stylesheets.
-          InputStream in = url.openStream();
-          if (in != null)
+          if (_LOG.isFinest())
           {
-            SkinsNode  metaInfSkinsNode = 
-              _getSkinsNodeFromInputStream(null, null, in, _getDefaultManager(), 
-                                           _META_INF_CONFIG_FILE);
-              
-            allSkinsNodes.add(metaInfSkinsNode);
-            in.close();
+            _LOG.finest("Skipping skin URL:{0} because it was already processed. " +
+              "It was on the classpath more than once.", url);
           }
+          // continue to the next url
         }
-        catch (Exception e)
+        else
         {
-         _LOG.warning("ERR_PARSING", url);
-         _LOG.warning(e);
+          _LOG.finest("Processing skin URL:{0}", url);
+          InputStream in = url.openStream();
+          try
+          {
+            // parse the config file and register the skin's additional stylesheets.
+  
+            if (in != null)
+            {
+              SkinsNode  metaInfSkinsNode = 
+                _getSkinsNodeFromInputStream(null, null, in, _getDefaultManager(), 
+                                             _META_INF_CONFIG_FILE);
+  
+              allSkinsNodes.add(metaInfSkinsNode);
+              
+            }
+          }
+          catch (Exception e)
+          {
+           _LOG.warning("ERR_PARSING", url);
+           _LOG.warning(e);
+          }
+          finally
+          {
+            in.close();
+          }     
         }
       }
     }
@@ -719,7 +743,7 @@
     
     return allSkinsNodes;
   } 
-
+  
   private static Skin _getDefaultBaseSkin(
     SkinFactory factory,
     String      renderKitId)
@@ -761,8 +785,8 @@
   }
   
   /**
-   * Get the skin id and stylesheet name from each SkinAdditionNode and
-   * get the skin and register the styleSheetName with the skin
+   * Get the skin id and other information from each SkinAdditionNode and
+   * get the skin and register the SkinAddition with the skin
    * @param fContext
    * @param skinFactory
    * @param skinAdditionNodeList



Mime
View raw message