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 2011/11/16 00:51:37 UTC

svn commit: r1202478 [7/8] - in /myfaces/shared/trunk: ./ core/ core/src/main/java/org/apache/myfaces/shared/application/ core/src/main/java/org/apache/myfaces/shared/component/ core/src/main/java/org/apache/myfaces/shared/config/ core/src/main/java/or...

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java Tue Nov 15 23:51:35 2011
@@ -38,23 +38,41 @@ public class ResourceHandlerCache
     private Boolean _resourceCacheEnabled = null;
     private Map<ResourceKey, ResourceValue> _resourceCacheMap = null;
 
-    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2")
-    private static final String RESOURCE_HANDLER_CACHE_SIZE_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
+    /**
+     * Controls the size of the cache used to check if a resource exists or not. 
+     * 
+     * <p>See org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED for details.</p>
+     */
+    @JSFWebConfigParam(defaultValue = "500", since = "2.0.2", group="resources", 
+            classType="java.lang.Integer", tags="performance")
+    private static final String RESOURCE_HANDLER_CACHE_SIZE_ATTRIBUTE = 
+        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_SIZE";
     private static final int RESOURCE_HANDLER_CACHE_DEFAULT_SIZE = 500;
 
-    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2")
-    private static final String RESOURCE_HANDLER_CACHE_ENABLED_ATTRIBUTE = "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
+    /**
+     * Enable or disable the cache used to "remember" if a resource handled by 
+     * the default ResourceHandler exists or not.
+     * 
+     */
+    @JSFWebConfigParam(defaultValue = "true", since = "2.0.2", group="resources", 
+            expectedValues="true,false", tags="performance")
+    private static final String RESOURCE_HANDLER_CACHE_ENABLED_ATTRIBUTE = 
+        "org.apache.myfaces.RESOURCE_HANDLER_CACHE_ENABLED";
     private static final boolean RESOURCE_HANDLER_CACHE_ENABLED_DEFAULT = true;
 
     public ResourceValue getResource(String resourceName, String libraryName,
             String contentType, String localePrefix)
     {
         if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
             return null;
+        }
 
         if (log.isLoggable(Level.FINE))
+        {
             log.log(Level.FINE, "Attemping to get resource from cache for "
                     + resourceName);
+        }
 
         ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix);
 
@@ -64,7 +82,9 @@ public class ResourceHandlerCache
     public boolean containsResource(String resourceName, String libraryName, String contentType, String localePrefix)
     {
         if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
             return false;
+        }
 
         ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix);
         return _resourceCacheMap.containsKey(key);
@@ -74,16 +94,22 @@ public class ResourceHandlerCache
             String contentType, String localePrefix, ResourceMeta resource, ResourceLoader loader)
     {
         if (!isResourceCachingEnabled())
+        {
             return;
+        }
 
         if (log.isLoggable(Level.FINE))
+        {
             log.log(Level.FINE, "Attemping to put resource to cache for "
                     + resourceName);
+        }
 
         if (_resourceCacheMap == null)
         {
             if (log.isLoggable(Level.FINE))
+            {
                 log.log(Level.FINE, "Initializing resource cache map");
+            }
             _resourceCacheMap = Collections
                     .synchronizedMap(new _ResourceMap<ResourceKey, ResourceValue>(
                             getMaxSize()));
@@ -102,12 +128,15 @@ public class ResourceHandlerCache
             //first, check to make sure that ProjectStage is production, if not, skip caching
             if (!facesContext.isProjectStage(ProjectStage.Production))
             {
-                return _resourceCacheEnabled = Boolean.FALSE;
+                _resourceCacheEnabled = Boolean.FALSE;
+                return _resourceCacheEnabled;
             }
 
             ExternalContext externalContext = facesContext.getExternalContext();
             if (externalContext == null)
+            {
                 return false; //don't cache right now, but don't disable it yet either
+            }
 
             //if in production, make sure that the cache is not explicitly disabled via context param
             _resourceCacheEnabled = WebConfigParamUtils.getBooleanInitParameter(externalContext, 
@@ -236,4 +265,4 @@ public class ResourceHandlerCache
             return size() > maxCapacity;
         }
     }
-}
\ No newline at end of file
+}

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceImpl.java Tue Nov 15 23:51:35 2011
@@ -116,12 +116,18 @@ public class ResourceImpl extends Resour
         {
             int c1 = delegate.read();
             
-            if (c1 == -1) return -1;
+            if (c1 == -1)
+            {
+                return -1;
+            }
             
             if ( ((char)c1) == '#')
             {
                 int c2 = delegate.read();
-                if (c2 == -1) return -1;
+                if (c2 == -1)
+                {
+                    return -1;
+                }
                 if (((char)c2) == '{')
                 {
                     //It is a value expression. We need
@@ -169,12 +175,16 @@ public class ResourceImpl extends Resour
                         }
                         catch(ELException e)
                         {
-                            ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (context, e, null);
+                            ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext (
+                                    context, e, null);
                             context.getApplication().publishEvent (context, ExceptionQueuedEvent.class, equecontext);
                             
                             Logger log = Logger.getLogger(ResourceImpl.class.getName());
                             if (log.isLoggable(Level.SEVERE))
-                                log.severe("Cannot evaluate EL expression "+convertToExpression(expressionList)+ " in resource " + getLibraryName()+":"+getResourceName());
+                            {
+                                log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
+                                        + " in resource " + getLibraryName() + ":" + getResourceName());
+                            }
                             
                             delegate.unread(c3);
                             for (int i = expressionList.size()-1; i >= 0; i--)

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoader.java Tue Nov 15 23:51:35 2011
@@ -18,7 +18,6 @@
  */
 package org.apache.myfaces.shared.resource;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Comparator;

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderUtils.java Tue Nov 15 23:51:35 2011
@@ -40,14 +40,14 @@ public class ResourceLoaderUtils
             "EEE, dd MMM yyyy HH:mm:ss zzz", "EEEEEE, dd-MMM-yy HH:mm:ss zzz",
             "EEE MMMM d HH:mm:ss yyyy" };
     
-    private static TimeZone __GMT = TimeZone.getTimeZone("GMT");
+    private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
 
     public static String formatDateHeader(long value)
     {
         SimpleDateFormat format = new SimpleDateFormat(
                 HTTP_RESPONSE_DATE_HEADER,
                 Locale.US);
-        format.setTimeZone(__GMT);
+        format.setTimeZone(GMT);
         return format.format(new Date(value));
     }
     
@@ -60,12 +60,11 @@ public class ResourceLoaderUtils
             {
                 SimpleDateFormat format = new SimpleDateFormat(
                         HTTP_REQUEST_DATE_HEADER[i], Locale.US);
-                format.setTimeZone(__GMT);
+                format.setTimeZone(GMT);
                 date = format.parse(value);
             }
             catch (ParseException e)
             {
-                ;
             }
         }
         if (date == null)

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceMetaImpl.java Tue Nov 15 23:51:35 2011
@@ -80,25 +80,37 @@ public class ResourceMetaImpl extends Re
         }
         if (_libraryName != null)
         {
-            if (firstSlashAdded) builder.append('/');
+            if (firstSlashAdded)
+            {
+                builder.append('/');
+            }
             builder.append(_libraryName);
             firstSlashAdded = true;
         }
         if (_libraryVersion != null)
         {
-            if (firstSlashAdded) builder.append('/');
+            if (firstSlashAdded)
+            {
+                builder.append('/');
+            }
             builder.append(_libraryVersion);
             firstSlashAdded = true;
         }
         if (_resourceName != null)
         {
-            if (firstSlashAdded) builder.append('/');
+            if (firstSlashAdded)
+            {
+                builder.append('/');
+            }
             builder.append(_resourceName);
             firstSlashAdded = true;
         }
         if (_resourceVersion != null)
         {
-            if (firstSlashAdded) builder.append('/');
+            if (firstSlashAdded)
+            {
+                builder.append('/');
+            }
             builder.append(_resourceVersion);
             builder.append(
                     _resourceName.substring(_resourceName.lastIndexOf('.')));

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java Tue Nov 15 23:51:35 2011
@@ -38,7 +38,8 @@ public class ClassElementHandler extends
     private List className = new ArrayList();
     private StringBuffer buffer ;
     
-    public ClassElementHandler(){
+    public ClassElementHandler()
+    {
         
         elementName.add("component-class");
         elementName.add("tag-class");
@@ -74,7 +75,9 @@ public class ClassElementHandler extends
          clazz = elementName.contains(qName);
          
          if(clazz)
+         {
              buffer = new StringBuffer();
+         }
         
     }
 
@@ -82,7 +85,8 @@ public class ClassElementHandler extends
         throws SAXException
     {
         
-        if(clazz){
+        if(clazz)
+        {
             className.add(buffer.toString());
             clazz = false;
         }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/Assert.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/Assert.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/Assert.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/Assert.java Tue Nov 15 23:51:35 2011
@@ -27,12 +27,16 @@ public class Assert
     public static void notNull(Object value)
     {
         if (value == null)
+        {
             throw new NullPointerException("The instance is null.");
+        }
     }
 
     public static void notNull(Object value, String fieldName)
     {
         if (value == null)
+        {
             throw new NullPointerException(fieldName + " is null.");
+        }
     }
 }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java Tue Nov 15 23:51:35 2011
@@ -67,14 +67,16 @@ public abstract class BiLevelCacheMap im
 
     public boolean isEmpty()
     {
-        synchronized (_cacheL2) {
+        synchronized (_cacheL2)
+        {
             return _cacheL1.isEmpty() && _cacheL2.isEmpty();
         }
     }
 
     public void clear()
     {
-        synchronized (_cacheL2) {
+        synchronized (_cacheL2)
+        {
             _cacheL1 = new HashMap(); // dafault size
             _cacheL2.clear();
         }
@@ -82,14 +84,16 @@ public abstract class BiLevelCacheMap im
 
     public boolean containsKey(Object key)
     {
-        synchronized (_cacheL2) {
+        synchronized (_cacheL2)
+        {
             return _cacheL1.containsKey(key) || _cacheL2.containsKey(key);
         }
     }
 
     public boolean containsValue(Object value)
     {
-        synchronized (_cacheL2) {
+        synchronized (_cacheL2)
+        {
             return _cacheL1.containsValue(value) || _cacheL2.containsValue(value);
         }
     }
@@ -117,14 +121,16 @@ public abstract class BiLevelCacheMap im
             // Has another thread merged caches while we were waiting on the mutex? Then check L1 again
             if (cacheL1 != _cacheL1)
             {
-                if ((retval = _cacheL1.get(key)) != null)
+                retval = _cacheL1.get(key);
+                if (retval != null)
                 {
                     // do not update miss count (it is not a miss anymore)
                     return retval;
                 }
             }
 
-            if ((retval = _cacheL2.get(key)) == null)
+            retval = _cacheL2.get(key);
+            if (retval == null)
             {
                 retval = newInstance(key);
                 if (retval != null)

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java Tue Nov 15 23:51:35 2011
@@ -23,14 +23,16 @@ package org.apache.myfaces.shared.util;
  *
  * @author Werner Punz
  */
-public class ClassLoaderExtension {
+public class ClassLoaderExtension
+{
     /**
      * standard forName for the loader
      *
      * @param name
      * @return
      */
-    public Class forName(String name) {
+    public Class forName(String name)
+    {
         return null;
     }
 }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java Tue Nov 15 23:51:35 2011
@@ -123,20 +123,25 @@ public final class ClassLoaderUtils
       ClassLoader loader = getContextClassLoader();
 
       if (loader != null)
-        clazz = loader.loadClass(name);
+      {
+          clazz = loader.loadClass(name);
+      }
     }
     catch (ClassNotFoundException e)
     {
       // treat as though loader not set
-      ;
     }
 
     if (clazz == null)
     {
       if (callerClassLoader != null)
-        clazz = callerClassLoader.loadClass(name);
+      {
+          clazz = callerClassLoader.loadClass(name);
+      }
       else
-        clazz = Class.forName(name);
+      {
+          clazz = Class.forName(name);
+      }
     }
 
     return clazz;
@@ -164,14 +169,20 @@ public final class ClassLoaderUtils
     ClassLoader loader = getContextClassLoader();
 
     if (loader != null)
-      url = loader.getResource(name);
+    {
+        url = loader.getResource(name);
+    }
 
     if (url == null)
     {
       if (callerClassLoader != null)
-        url = callerClassLoader.getResource(name);
+      {
+          url = callerClassLoader.getResource(name);
+      }
       else
-        url = ClassLoader.getSystemResource(name);
+      {
+          url = ClassLoader.getSystemResource(name);
+      }
     }
 
     return url;
@@ -199,14 +210,20 @@ public final class ClassLoaderUtils
     ClassLoader loader = getContextClassLoader();
 
     if (loader != null)
-      stream = loader.getResourceAsStream(name);
+    {
+        stream = loader.getResourceAsStream(name);
+    }
 
     if (stream == null)
     {
       if (callerClassLoader != null)
-        stream = callerClassLoader.getResourceAsStream(name);
+      {
+          stream = callerClassLoader.getResourceAsStream(name);
+      }
       else
-        stream = ClassLoader.getSystemResourceAsStream(name);
+      {
+          stream = ClassLoader.getSystemResourceAsStream(name);
+      }
     }
 
     return stream;
@@ -222,7 +239,8 @@ public final class ClassLoaderUtils
   {
       if (System.getSecurityManager() != null) 
       {
-          try {
+          try 
+          {
               ClassLoader cl = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
                       {
                           public ClassLoader run() throws PrivilegedActionException
@@ -287,7 +305,9 @@ public final class ClassLoaderUtils
               {
                 String line = in.readLine();
                 if (line == null)
-                  break;
+                {
+                    break;
+                }
                 
                 String className = _parseLine(line);
                 
@@ -314,7 +334,9 @@ public final class ClassLoaderUtils
         while(urls.hasMoreElements());
         
         if (services.size() == 1)
-          return Collections.singletonList(services.get(0));
+        {
+            return Collections.singletonList(services.get(0));
+        }
         
         return Collections.unmodifiableList(services);
       }
@@ -335,7 +357,9 @@ public final class ClassLoaderUtils
     // Eliminate any comments
     int hashIndex = line.indexOf('#');
     if (hashIndex >= 0)
-      line = line.substring(0, hashIndex);
+    {
+        line = line.substring(0, hashIndex);
+    }
 
     // and any whitespace
     line = line.trim();

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java Tue Nov 15 23:51:35 2011
@@ -126,7 +126,8 @@ public final class ClassUtils
 
     //~ Methods ------------------------------------------------------------------------------------
 
-    public synchronized static void addClassLoadingExtension(ClassLoaderExtension extension, boolean top) {
+    public synchronized static void addClassLoadingExtension(ClassLoaderExtension extension, boolean top)
+    {
       /**
        * now at the first look this looks somewhat strange
        * but to get the best performance access we assign new native
@@ -138,11 +139,13 @@ public final class ClassUtils
         ClassLoaderExtension [] retVal = new ClassLoaderExtension[classLoadingExtensions.length+1];
         ArrayList extensions = new ArrayList(classLoadingExtensions.length+1);
 
-        if(!top) {
+        if(!top)
+        {
             extensions.addAll(Arrays.asList(classLoadingExtensions));
         }
         extensions.add(extension);
-        if(top) {
+        if(top)
+        {
             extensions.addAll(Arrays.asList(classLoadingExtensions));
         }    
 
@@ -168,16 +171,21 @@ public final class ClassUtils
         ClassLoaderExtension [] loaderPlugins = classLoadingExtensions;
 
         int plugins = loaderPlugins.length;
-        for(int cnt = 0; cnt < loaderPlugins.length; cnt ++) {
+        for(int cnt = 0; cnt < loaderPlugins.length; cnt ++)
+        {
             ClassLoaderExtension extension = loaderPlugins[cnt];
             Class retVal = extension.forName(type);
-            if(retVal != null) {
+            if(retVal != null)
+            {
                 return retVal;
             }
         }
 
 
-        if (type == null) throw new NullPointerException("type");
+        if (type == null)
+        {
+            throw new NullPointerException("type");
+        }
         try
         {
             // Try WebApp ClassLoader first
@@ -230,7 +238,10 @@ public final class ClassUtils
     public static Class javaTypeToClass(String type)
         throws ClassNotFoundException
     {
-        if (type == null) throw new NullPointerException("type");
+        if (type == null)
+        {
+            throw new NullPointerException("type");
+        }
 
         // try common types and arrays of common types first
         Class clazz = (Class) COMMON_TYPES.get(type);
@@ -297,7 +308,8 @@ public final class ClassUtils
 
     /**
      * @param resource       Name of resource(s) to find in classpath
-     * @param defaultObject  The default object to use to determine the class loader (if none associated with current thread.)
+     * @param defaultObject  The default object to use to determine the class loader 
+     *                       (if none associated with current thread.)
      * @return Iterator over URL Objects
      */
     public static Iterator getResources(String resource, Object defaultObject)
@@ -323,7 +335,10 @@ public final class ClassUtils
     public static Object newInstance(String type)
         throws FacesException
     {
-        if (type == null) return null;
+        if (type == null)
+        {
+            return null;
+        }
         return newInstance(simpleClassForName(type));
     }
 
@@ -335,7 +350,9 @@ public final class ClassUtils
     public static Object newInstance(String type, Class[] expectedTypes)
     {
         if (type == null)
-            return null;        
+        {
+            return null;
+        }
         
         Class clazzForName = simpleClassForName(type);
         
@@ -404,7 +421,10 @@ public final class ClassUtils
 
     public static Object convertToType(Object value, Class desiredClass)
     {
-        if (value == null) return null;
+        if (value == null)
+        {
+            return null;
+        }
 
         try
         {
@@ -424,7 +444,8 @@ public final class ClassUtils
      * Gets the ClassLoader associated with the current thread.  Returns the class loader associated with
      * the specified default object if no context loader is associated with the current thread.
      *
-     * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
+     * @param defaultObject The default object to use to determine the class loader 
+     *        (if none associated with current thread.)
      * @return ClassLoader
      */
     protected static ClassLoader getCurrentLoader(Object defaultObject)
@@ -460,7 +481,8 @@ public final class ClassUtils
      * @param defaultObject The default implementation for the given ApplicationObject.
      * @return
      */    
-    public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject)
+    public static <T> T buildApplicationObject(Class<T> interfaceClass, 
+            Collection<String> classNamesIterator, T defaultObject)
     {
         return buildApplicationObject(interfaceClass, null, null, classNamesIterator, defaultObject);
     }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java Tue Nov 15 23:51:35 2011
@@ -36,8 +36,9 @@ public final class ExceptionUtils
     /**
      * <p>
      * returns a list of all throwables (including the one you passed in) wrapped by the given throwable.
-     * In contrast to a simple call to <code>getClause()</code> on each throwable it will also check if the throwable class
-     * contain a method <code>getRootCause()</code> (e.g. ServletException or JspException) and call it instead.
+     * In contrast to a simple call to <code>getClause()</code> on each throwable it will also check if 
+     * the throwable class contain a method <code>getRootCause()</code> (e.g. ServletException or JspException)
+     * and call it instead.
      * </p>
      * <p>
      * The first list element will your passed in exception, the last list element is the cause. 

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExternalContextUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExternalContextUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExternalContextUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ExternalContextUtils.java Tue Nov 15 23:51:35 2011
@@ -590,14 +590,16 @@ public final class ExternalContextUtils
     //Find bridge to tell if portal is supported
     if(context != null) 
     {
+      // Portlet 1.0 API found. In this case we have to consider that exists alternate
+      // bridge implementations like in WebSphere and others.
+      portlet10Supported = true;
+
       try
       {
         Class<?> bridge = ClassLoaderUtils.loadClass("javax.portlet.faces.Bridge");
         
         if(bridge != null)
         {
-          portlet10Supported = true;
-
           //Standard bridge defines a spec name which can be used to 
           //determine Portlet 2.0 Support.
           String specName = bridge.getPackage().getSpecificationTitle();
@@ -616,7 +618,13 @@ public final class ExternalContextUtils
       }
       catch (ClassNotFoundException e)
       {
-        _LOG.fine("Portlet API is present but bridge is not.  Portlet configurations are disabled.");
+        _LOG.fine("Portlet API is present but Standard Apache Portlet Bridge is not. " +
+                " This could happen if you are using an alternate Portlet Bridge solution.");
+        
+        if (resourceRequest != null)
+        {
+            portlet20Supported = true;
+        }
       }
     }
 

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java Tue Nov 15 23:51:35 2011
@@ -76,7 +76,8 @@ public class HashMapUtils
      /**
      * spit out each name/value pair
      */
-    public static String mapToString(Map map){
+    public static String mapToString(Map map)
+    {
         Set entries = map.entrySet();
         Iterator iter = entries.iterator();
         StringBuffer buff = new StringBuffer();

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java Tue Nov 15 23:51:35 2011
@@ -52,13 +52,17 @@ public final class LocaleUtils
         {
             Locale locale = Locale.getDefault();
             if(log.isLoggable(Level.WARNING))
-                log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : "+locale.toString());
+            {
+                log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : "
+                        + locale.toString());
+            }
             return locale;
         }
 
         int separatorCountry = localeString.indexOf('_');
         char separator;
-        if (separatorCountry >= 0) {
+        if (separatorCountry >= 0)
+        {
             separator = '_';
         }
         else
@@ -67,11 +71,14 @@ public final class LocaleUtils
             separator = '-';
         }
 
-        String language, country, variant;
+        String language;
+        String country;
+        String variant;
         if (separatorCountry < 0)
         {
             language = localeString;
-            country = variant = "";
+            country = "";
+            variant = "";
         }
         else
         {

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java Tue Nov 15 23:51:35 2011
@@ -200,7 +200,8 @@ public final class MessageUtils
                                   String forClientId,
                                   FacesContext facesContext)
     {
-        if(log.isLoggable(Level.FINEST)) {
+        if(log.isLoggable(Level.FINEST))
+        {
           log.finest("adding message " + messageId + " for clientId " + forClientId);
         }
         facesContext.addMessage(forClientId,
@@ -214,7 +215,8 @@ public final class MessageUtils
             String forClientId,
             FacesContext facesContext)
     {
-        if(log.isLoggable(Level.FINEST)) {
+        if(log.isLoggable(Level.FINEST))
+        {
           log.finest("adding message " + messageId + " for clientId " + forClientId);
         }
         facesContext.addMessage(forClientId,
@@ -233,7 +235,9 @@ public final class MessageUtils
     {
         String localizedStr = null;
         if(params == null || msgtext == null)
+        {
             return msgtext;
+        }
 
         if(locale != null)
         {
@@ -257,8 +261,11 @@ public final class MessageUtils
         {
             locale = context.getViewRoot().getLocale();
             if(locale == null)
+            {
                 locale = Locale.getDefault();
-        } else
+            }
+        }
+        else
         {
             locale = Locale.getDefault();
         }
@@ -276,10 +283,12 @@ public final class MessageUtils
         {
             try
             {
-                bundle = ResourceBundle.getBundle(bundleName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
+                bundle = ResourceBundle.getBundle(bundleName, locale, 
+                        org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
                 summary = bundle.getString(messageId);
             }
-            catch (MissingResourceException e) {
+            catch (MissingResourceException e)
+            {
                 // NoOp
             }
         }
@@ -288,14 +297,16 @@ public final class MessageUtils
         {
             try
             {
-                bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
+                bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, 
+                        org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
                 if(bundle == null)
                 {
                     throw new NullPointerException();
                 }
                 summary = bundle.getString(messageId);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
         }
@@ -316,7 +327,8 @@ public final class MessageUtils
             {
                 detail = bundle.getString(messageId + DETAIL_SUFFIX);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
             return new ParametrizableFacesMessage(summary, detail, params, locale);
@@ -329,14 +341,16 @@ public final class MessageUtils
                 detail = substituteParams(locale,
                     bundle.getString(messageId + DETAIL_SUFFIX), params);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
             return new FacesMessage(summary, detail);
         }
     }
     
-    public static FacesMessage getMessageFromBundle(String bundleBaseName, FacesContext context, Locale locale, String messageId, Object params[])
+    public static FacesMessage getMessageFromBundle(String bundleBaseName, 
+            FacesContext context, Locale locale, String messageId, Object params[])
     {
         String summary = null;
         String detail = null;
@@ -347,10 +361,12 @@ public final class MessageUtils
         {
             try
             {
-                bundle = ResourceBundle.getBundle(bundleName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
+                bundle = ResourceBundle.getBundle(bundleName, locale, 
+                        org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
                 summary = bundle.getString(messageId);
             }
-            catch (MissingResourceException e) {
+            catch (MissingResourceException e)
+            {
                 // NoOp
             }
         }
@@ -359,14 +375,16 @@ public final class MessageUtils
         {
             try
             {
-                bundle = ResourceBundle.getBundle(bundleBaseName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleBaseName));
+                bundle = ResourceBundle.getBundle(bundleBaseName, locale, 
+                        org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleBaseName));
                 if(bundle == null)
                 {
                     throw new NullPointerException();
                 }
                 summary = bundle.getString(messageId);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
         }
@@ -375,14 +393,16 @@ public final class MessageUtils
         {
             try
             {
-                bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
+                bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, 
+                        org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
                 if(bundle == null)
                 {
                     throw new NullPointerException();
                 }
                 summary = bundle.getString(messageId);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
         }
@@ -404,7 +424,8 @@ public final class MessageUtils
             {
                 detail = bundle.getString(messageId + DETAIL_SUFFIX);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
             return new ParametrizableFacesMessage(summary, detail, params, locale);
@@ -417,7 +438,8 @@ public final class MessageUtils
                 detail = substituteParams(locale,
                     bundle.getString(messageId + DETAIL_SUFFIX), params);
             }
-            catch(MissingResourceException e) {
+            catch(MissingResourceException e)
+            {
                 // NoOp
             }
             return new FacesMessage(summary, detail);
@@ -442,17 +464,21 @@ public final class MessageUtils
      * 
      * @return  currently applicable Locale for this request.
      */
-    public static Locale getCurrentLocale() {
+    public static Locale getCurrentLocale()
+    {
         return getCurrentLocale(FacesContext.getCurrentInstance());
     }
     
-    public static Locale getCurrentLocale(FacesContext context) {
+    public static Locale getCurrentLocale(FacesContext context)
+    {
         Locale locale;
         if(context != null && context.getViewRoot() != null)
         {
             locale = context.getViewRoot().getLocale();
             if(locale == null)
+            {
                 locale = Locale.getDefault();
+            }
         }
         else
         {
@@ -469,7 +495,8 @@ public final class MessageUtils
      * @param params parameters to set at localized message
      * @return generated FacesMessage
      */
-    public static FacesMessage getMessage(FacesMessage.Severity severity, String bundleBaseName, String messageId, Object params[])
+    public static FacesMessage getMessage(FacesMessage.Severity severity, String bundleBaseName, 
+            String messageId, Object params[])
     {
       FacesMessage msg = getMessage(bundleBaseName, messageId, params);
       msg.setSeverity(severity);
@@ -515,7 +542,8 @@ public final class MessageUtils
       {
           summary = bundle.getString(messageId);
       }
-      catch (MissingResourceException e) {
+      catch (MissingResourceException e)
+      {
         // NoOp
       }
 
@@ -532,7 +560,8 @@ public final class MessageUtils
           detail = substituteParams(bundle.getLocale(),
               bundle.getString(messageId + DETAIL_SUFFIX), params);
       }
-      catch(MissingResourceException e) {
+      catch(MissingResourceException e)
+      {
         // NoOp
       }
 
@@ -565,15 +594,20 @@ public final class MessageUtils
     public static FacesMessage getMessage(FacesContext context, String messageId, Object params[])
     {
         if(context == null || messageId == null)
+        {
             throw new NullPointerException(" context " + context + " messageId " + messageId);
+        }
         Locale locale = getCurrentLocale(context);
         if(null == locale)
+        {
             throw new NullPointerException(" locale " + locale);
+        }
         FacesMessage message = getMessage(locale, messageId, params);
         if(message != null)
         {
             return message;
-        } else
+        } 
+        else
         {
             // TODO /FIX:  Note that this has fallback behavior to default Locale for message,
             // but similar behavior above does not.  The methods should probably behave
@@ -582,18 +616,24 @@ public final class MessageUtils
         }
     }
     
-    public static FacesMessage getMessage(String bundleBaseName, FacesContext context, String messageId, Object params[])
+    public static FacesMessage getMessage(String bundleBaseName, FacesContext context, 
+            String messageId, Object params[])
     {
         if(context == null || messageId == null)
+        {
             throw new NullPointerException(" context " + context + " messageId " + messageId);
+        }
         Locale locale = getCurrentLocale(context);
         if(null == locale)
+        {
             throw new NullPointerException(" locale " + locale);
+        }
         FacesMessage message = getMessageFromBundle(bundleBaseName, context, locale, messageId, params);
         if(message != null)
         {
             return message;
-        } else
+        } 
+        else
         {
             // TODO /FIX:  Note that this has fallback behavior to default Locale for message,
             // but similar behavior above does not.  The methods should probably behave
@@ -602,14 +642,19 @@ public final class MessageUtils
         }
     }
     
-    public static Object getLabel(FacesContext facesContext, UIComponent component) {
+    public static Object getLabel(FacesContext facesContext, UIComponent component)
+    {
         Object label = component.getAttributes().get("label");
         if(label != null)
+        {
             return label;
+        }
         
         ValueExpression expression = component.getValueExpression("label");
         if(expression != null)
+        {
             return expression;
+        }
         
         //If no label is not specified, use clientId
         return component.getClientId( facesContext );
@@ -621,9 +666,11 @@ public final class MessageUtils
         if(context != null)
         {
             return context.getApplication();
-        } else
+        }
+        else
         {
-            ApplicationFactory afactory = (ApplicationFactory)FactoryFinder.getFactory("javax.faces.application.ApplicationFactory");
+            ApplicationFactory afactory = (ApplicationFactory)FactoryFinder.getFactory(
+                    "javax.faces.application.ApplicationFactory");
             return afactory.getApplication();
         }
     }

Added: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesClassLoader.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesClassLoader.java?rev=1202478&view=auto
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesClassLoader.java (added)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesClassLoader.java Tue Nov 15 23:51:35 2011
@@ -0,0 +1,221 @@
+/*
+ * 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.shared.util;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Custom ClassLoader that sets the current Thread's context ClassLoader as parent ClassLoader
+ * and uses the parent ClassLoader, myfaces-api and myfaces-impl ClassLoaders to locate Resources and Classes. 
+ *
+ * @author Jakob Korherr
+ */
+public class MyFacesClassLoader extends ClassLoader
+{
+
+    private static final String APPLICATION_MAP_KEY = MyFacesClassLoader.class.getName();
+
+    /**
+     * Returns the cached instance of the MyFacesClassLoader for this application or a new
+     * one if now cached instance is available yet.
+     *
+     * @param externalContext
+     * @return
+     */
+    public static final MyFacesClassLoader getCurrentInstance(ExternalContext externalContext)
+    {
+        if (externalContext == null)
+        {
+            // if no ExternalContext is available, return a new instance
+            // this may be the case in Unit tests or outside of the JSF lifecycle
+            return new MyFacesClassLoader();
+        }
+
+        Map<String, Object> applicationMap = externalContext.getApplicationMap();
+        MyFacesClassLoader classLoader = (MyFacesClassLoader) applicationMap.get(APPLICATION_MAP_KEY);
+
+        if (classLoader == null)
+        {
+            // no instance available for this application yet, create one and cache it
+            classLoader = new MyFacesClassLoader();
+            applicationMap.put(APPLICATION_MAP_KEY, classLoader);
+        }
+
+        return classLoader;
+    }
+
+    private static ClassLoader getContextClassLoaderFailsafe()
+    {
+        ClassLoader contextClassLoader = ClassLoaderUtils.getContextClassLoader();
+
+        if (contextClassLoader == null)
+        {
+            // fall back to the ClassLoader of this class if the current Thread has no ContextClassLoader
+            contextClassLoader = MyFacesClassLoader.class.getClassLoader();
+        }
+
+        return contextClassLoader;
+    }
+
+    private ClassLoader apiClassLoader;
+    private ClassLoader implClassLoader;
+
+    public MyFacesClassLoader()
+    {
+        // context ClassLoader is parent ClassLoader
+        super(getContextClassLoaderFailsafe());
+
+        apiClassLoader = FacesContext.class.getClassLoader(); // myfaces-api classloader
+        implClassLoader = getClass().getClassLoader();  // myfaces-impl (or tomahawk) classloader
+    }
+
+    @Override
+    public URL getResource(String s)
+    {
+        // context classloader
+        URL url = super.getResource(s);
+
+        if (url == null)
+        {
+            // try api
+            url = apiClassLoader.getResource(s);
+
+            if (url == null)
+            {
+                // try impl
+                url = implClassLoader.getResource(s);
+            }
+        }
+
+        return url;
+    }
+
+    @Override
+    public Enumeration<URL> getResources(String s) throws IOException
+    {
+        // use all 3 classloaders and merge without duplicates
+        Set<URL> urls = new HashSet<URL>(); // no duplicates
+
+        // context classloader
+        urls.addAll(Collections.list(super.getResources(s)));
+
+        // api classlaoder
+        urls.addAll(Collections.list(apiClassLoader.getResources(s)));
+
+        // impl classlaoder
+        urls.addAll(Collections.list(implClassLoader.getResources(s)));
+
+        return Collections.enumeration(urls);
+    }
+
+    @Override
+    public InputStream getResourceAsStream(String s)
+    {
+        // context classloader
+        InputStream stream = super.getResourceAsStream(s);
+
+        if (stream == null)
+        {
+            // try api
+            stream = apiClassLoader.getResourceAsStream(s);
+
+            if (stream == null)
+            {
+                // try impl
+                stream = implClassLoader.getResourceAsStream(s);
+            }
+        }
+
+        return stream;
+    }
+
+    @Override
+    public Class<?> loadClass(String s) throws ClassNotFoundException
+    {
+        Class<?> clazz = null;
+        ClassNotFoundException firstException = null;
+
+        try
+        {
+            // context classloader
+            clazz = super.loadClass(s);
+        }
+        catch (ClassNotFoundException cnfe)
+        {
+            firstException = cnfe;
+        }
+
+
+        if (clazz == null)
+        {
+            // try api
+            clazz = loadClassFailsafe(s, apiClassLoader);
+
+            if (clazz == null)
+            {
+                // try impl
+                clazz = loadClassFailsafe(s, implClassLoader);
+
+                if (clazz == null)
+                {
+                    // still null, throw first ClassNotFoundException
+                    throw firstException;
+                }
+            }
+        }
+
+        return clazz;
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (o instanceof MyFacesClassLoader)
+        {
+            MyFacesClassLoader other = (MyFacesClassLoader) o;
+
+            // same parent --> same ContextClassLoader --> same MyFacesClassLoader
+            return (other.getParent().equals(this.getParent()));
+        }
+
+        return false;
+    }
+
+    private Class<?> loadClassFailsafe(String s, ClassLoader classLaoder)
+    {
+        try
+        {
+            return classLaoder.loadClass(s);
+        }
+        catch (ClassNotFoundException cnfe)
+        {
+            return null;
+        }
+    }
+
+}

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java Tue Nov 15 23:51:35 2011
@@ -29,11 +29,11 @@ import java.util.NoSuchElementException;
  */
 public final class NullEnumeration implements Enumeration
 {
-    private static final NullEnumeration s_nullEnumeration = new NullEnumeration();
+    private static final NullEnumeration NULL_ENUMERATION = new NullEnumeration();
 
     public static final NullEnumeration instance()
     {
-        return s_nullEnumeration;
+        return NULL_ENUMERATION;
     }
 
     public boolean hasMoreElements()

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ParametrizableFacesMessage.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ParametrizableFacesMessage.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ParametrizableFacesMessage.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ParametrizableFacesMessage.java Tue Nov 15 23:51:35 2011
@@ -50,7 +50,10 @@ public class ParametrizableFacesMessage 
             String summary, String detail, Object[] args, Locale locale)
     {
         super(summary, detail);
-        if(locale == null) throw new NullPointerException("locale");
+        if(locale == null)
+        {
+            throw new NullPointerException("locale");
+        }
         _locale = locale;
         _args = args;
     }
@@ -59,7 +62,10 @@ public class ParametrizableFacesMessage 
             String summary, String detail, Object[] args, Locale locale)
     {
         super(severity, summary, detail);
-        if(locale == null) throw new NullPointerException("locale");
+        if(locale == null)
+        {
+            throw new NullPointerException("locale");
+        }
         _locale = locale;
         _args = args;
     }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java Tue Nov 15 23:51:35 2011
@@ -69,7 +69,8 @@ public class SelectItemsIterator impleme
 
     public SelectItemsIterator(UIComponent selectItemsParent, FacesContext facesContext)
     {
-        _children = selectItemsParent.getChildCount() > 0 ? selectItemsParent.getChildren().iterator() : _EMPTY_UICOMPONENT_ITERATOR; 
+        _children = selectItemsParent.getChildCount() > 0 ? 
+                selectItemsParent.getChildren().iterator() : _EMPTY_UICOMPONENT_ITERATOR; 
         _facesContext = facesContext;
     }
 
@@ -136,7 +137,8 @@ public class SelectItemsIterator impleme
                     ValueExpression expression = uiSelectItem.getValueExpression("value");
                     throw new IllegalArgumentException("ValueExpression '"
                             + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
-                            + RendererUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
+                            + RendererUtils.getPathToComponent(child) + 
+                            " does not reference an Object of type SelectItem");
                 }
                 _nextItem = (SelectItem) item;
                 return true;

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java Tue Nov 15 23:51:35 2011
@@ -28,7 +28,6 @@ import java.security.AccessController;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
 import java.util.Random;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -89,7 +88,8 @@ import org.apache.myfaces.shared.util.se
  * @author Dennis C. Byrne
  * @see org.apache.myfaces.webapp.StartupServletContextListener
  */
-public final class StateUtils {
+public final class StateUtils
+{
 
     //private static final Log log = LogFactory.getLog(StateUtils.class);
     private static final Logger log = Logger.getLogger(StateUtils.class.getName());
@@ -104,7 +104,8 @@ public final class StateUtils {
     /**
      * Indicate if the view state is encrypted or not. By default, encryption is enabled.
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.USE_ENCRYPTION",since="1.1",defaultValue="true",expectedValues="true,false")
+    @JSFWebConfigParam(name="org.apache.myfaces.USE_ENCRYPTION",since="1.1",
+            defaultValue="true",expectedValues="true,false",group="state")
     public static final String USE_ENCRYPTION = INIT_PREFIX + "USE_ENCRYPTION";
     
     /**
@@ -113,32 +114,34 @@ public final class StateUtils {
      * for instructions on how to configure an application for 
      * different encryption strengths.
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.SECRET",since="1.1")
+    @JSFWebConfigParam(name="org.apache.myfaces.SECRET",since="1.1",group="state")
     public static final String INIT_SECRET = INIT_PREFIX + "SECRET";
     
     /**
      * Indicate the encryption algorithm used for encrypt the view state.
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM",since="1.1",defaultValue="DES")
+    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM",since="1.1",
+            defaultValue="DES",group="state",tags="performance")
     public static final String INIT_ALGORITHM = INIT_PREFIX + "ALGORITHM";
 
     /**
      * If is set to "false", the secret key used for encryption algorithm is not cached. This is used
      * when the returned SecretKey for encryption algorithm is not thread safe. 
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.SECRET.CACHE",since="1.1")
+    @JSFWebConfigParam(name="org.apache.myfaces.SECRET.CACHE",since="1.1",group="state")
     public static final String INIT_SECRET_KEY_CACHE = INIT_SECRET + ".CACHE";
     
     /**
      * Defines the initialization vector (Base64 encoded) used for the encryption algorithm
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.IV",since="1.1")
+    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.IV",since="1.1",group="state")
     public static final String INIT_ALGORITHM_IV = INIT_ALGORITHM + ".IV";
     
     /**
      * Defines the default mode and padding used for the encryption algorithm
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.PARAMETERS",since="1.1",defaultValue="ECB/PKCS5Padding")
+    @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.PARAMETERS",since="1.1",
+            defaultValue="ECB/PKCS5Padding",group="state")
     public static final String INIT_ALGORITHM_PARAM = INIT_ALGORITHM + ".PARAMETERS";
     
     /**
@@ -146,13 +149,14 @@ public final class StateUtils {
      * by state manager into a byte array. The expected class must implement
      * org.apache.myfaces.shared.util.serial.SerialFactory interface.
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.SERIAL_FACTORY", since="1.1")
+    @JSFWebConfigParam(name="org.apache.myfaces.SERIAL_FACTORY", since="1.1",group="state",tags="performance")
     public static final String SERIAL_FACTORY = INIT_PREFIX + "SERIAL_FACTORY";
     
     /**
      * Indicate if the view state should be compressed before encrypted(optional) and encoded
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.COMPRESS_STATE_IN_CLIENT",since="1.1",defaultValue="false",expectedValues="true,false")
+    @JSFWebConfigParam(name="org.apache.myfaces.COMPRESS_STATE_IN_CLIENT",since="1.1",defaultValue="false",
+            expectedValues="true,false",group="state",tags="performance")
     public static final String COMPRESS_STATE_IN_CLIENT = INIT_PREFIX + "COMPRESS_STATE_IN_CLIENT";
 
     public static final String DEFAULT_MAC_ALGORITHM = "HmacSHA1";
@@ -161,21 +165,22 @@ public final class StateUtils {
      * Indicate the algorithm used to calculate the Message Authentication Code that is
      * added to the view state.
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.MAC_ALGORITHM",defaultValue="HmacSHA1")
+    @JSFWebConfigParam(name="org.apache.myfaces.MAC_ALGORITHM",defaultValue="HmacSHA1",
+            group="state",tags="performance")
     public static final String INIT_MAC_ALGORITHM = "org.apache.myfaces.MAC_ALGORITHM";
     
     /**
      * Define the initialization code that are used to initialize the secret key used
      * on the Message Authentication Code algorithm
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.MAC_SECRET")
+    @JSFWebConfigParam(name="org.apache.myfaces.MAC_SECRET",group="state")
     public static final String INIT_MAC_SECRET = "org.apache.myfaces.MAC_SECRET";
 
     /**
      * If is set to "false", the secret key used for MAC algorithm is not cached. This is used
      * when the returned SecretKey for mac algorithm is not thread safe. 
      */
-    @JSFWebConfigParam(name="org.apache.myfaces.MAC_SECRET.CACHE")
+    @JSFWebConfigParam(name="org.apache.myfaces.MAC_SECRET.CACHE",group="state")
     public static final String INIT_MAC_SECRET_KEY_CACHE = "org.apache.myfaces.MAC_SECRET.CACHE";
     
     /** Utility class, do not instatiate */
@@ -184,7 +189,8 @@ public final class StateUtils {
         //nope
     }
 
-    private static void testConfiguration(ExternalContext ctx){
+    private static void testConfiguration(ExternalContext ctx)
+    {
 
         String algorithmParams = ctx.getInitParameter(INIT_ALGORITHM_PARAM);
         
@@ -202,10 +208,12 @@ public final class StateUtils {
         if (algorithmParams != null && algorithmParams.startsWith("CBC") )
         {
             if(iv == null)
+            {
                 throw new FacesException(INIT_ALGORITHM_PARAM +
-                                    " parameter has been set with CBC mode," +
-                                    " but no initialization vector has been set " +
-                                    " with " + INIT_ALGORITHM_IV);
+                        " parameter has been set with CBC mode," +
+                        " but no initialization vector has been set " +
+                        " with " + INIT_ALGORITHM_IV);
+            }
         }
 
     }
@@ -213,7 +221,9 @@ public final class StateUtils {
     public static boolean enableCompression(ExternalContext ctx)
     {
         if(ctx == null)
+        {
             throw new NullPointerException("ExternalContext ctx");
+        }
     
         return "true".equals(ctx.getInitParameter(COMPRESS_STATE_IN_CLIENT));
     }
@@ -222,7 +232,9 @@ public final class StateUtils {
     {
         
         if(ctx == null)
+        {
             throw new NullPointerException("ExternalContext ctx");
+        }
         
         return ! "false".equals(ctx.getInitParameter(USE_ENCRYPTION));
     }
@@ -231,12 +243,17 @@ public final class StateUtils {
      * This fires during the Render Response phase, saving state.
      */
 
-    public static final String construct(Object object, ExternalContext ctx){
+    public static final String construct(Object object, ExternalContext ctx)
+    {
         byte[] bytes = getAsByteArray(object, ctx);
         if( enableCompression(ctx) )
-                bytes = compress(bytes);
+        {
+            bytes = compress(bytes);
+        }
         if(isSecure(ctx))
-                bytes = encrypt(bytes, ctx);
+        {
+            bytes = encrypt(bytes, ctx);
+        }
         bytes = encode(bytes);
         try
         {
@@ -265,7 +282,9 @@ public final class StateUtils {
         SerialFactory serialFactory = (SerialFactory) ctx.getApplicationMap().get(SERIAL_FACTORY);
         
         if(serialFactory == null)
+        {
             throw new NullPointerException("serialFactory");
+        }
         
         try
         {
@@ -288,7 +307,9 @@ public final class StateUtils {
     {
 
         if (ctx == null)
+        {
             throw new NullPointerException("ExternalContext ctx");
+        }
 
         testConfiguration(ctx);
         
@@ -370,14 +391,20 @@ public final class StateUtils {
         try
         {
             if(log.isLoggable(Level.FINE))
-                log.fine("Processing state : "+string);
+            {
+                log.fine("Processing state : " + string);
+            }
 
             bytes = string.getBytes(ZIP_CHARSET);
             bytes = decode(bytes);
             if(isSecure(ctx))
+            {
                 bytes = decrypt(bytes, ctx);
+            }
             if( enableCompression(ctx) )
+            {
                 bytes = decompress(bytes);
+            }
             return getAsObject(bytes, ctx);
         }
         catch (Throwable e)
@@ -398,7 +425,9 @@ public final class StateUtils {
     public static final byte[] decompress(byte[] bytes)
     {
         if(bytes == null)
+        {
             throw new NullPointerException("byte[] bytes");
+        }
         
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -431,7 +460,9 @@ public final class StateUtils {
     public static byte[] decrypt(byte[] secure, ExternalContext ctx)
     {
         if (ctx == null)
+        {
             throw new NullPointerException("ExternalContext ctx");
+        }
 
         testConfiguration(ctx);
                 
@@ -518,7 +549,9 @@ public final class StateUtils {
             SerialFactory serialFactory = (SerialFactory) ctx.getApplicationMap().get(SERIAL_FACTORY);
             
             if(serialFactory == null)
+            {
                 throw new NullPointerException("serialFactory");
+            }
             
             ObjectInputStream s = null;
             Exception pendingException = null;
@@ -533,7 +566,8 @@ public final class StateUtils {
                     {
                         //Put IOException and ClassNotFoundException as "checked" exceptions,
                         //so AccessController wrap them in a PrivilegedActionException
-                        public Object run() throws  PrivilegedActionException, IOException, ClassNotFoundException
+                        public Object run() throws PrivilegedActionException, 
+                                                   IOException, ClassNotFoundException
                         {
                             return ois.readObject();
                         }
@@ -624,23 +658,27 @@ public final class StateUtils {
           System.out.println(new String(bytes, ZIP_CHARSET));
     }
 
-    private static byte[] findInitializationVector(ExternalContext ctx) {
+    private static byte[] findInitializationVector(ExternalContext ctx)
+    {
         
         byte[] iv = null;
-        String _iv = ctx.getInitParameter(INIT_ALGORITHM_IV);
+        String ivString = ctx.getInitParameter(INIT_ALGORITHM_IV);
         
-        if(_iv == null)
+        if(ivString == null)
         {
-            _iv = ctx.getInitParameter(INIT_ALGORITHM_IV.toLowerCase());
+            ivString = ctx.getInitParameter(INIT_ALGORITHM_IV.toLowerCase());
         }
         
-        if (_iv != null)
-            iv = new Base64().decode(_iv.getBytes());
+        if (ivString != null)
+        {
+            iv = new Base64().decode(ivString.getBytes());
+        }
         
         return iv;
     }
 
-    private static String findAlgorithmParams(ExternalContext ctx) {
+    private static String findAlgorithmParams(ExternalContext ctx)
+    {
         
         String algorithmParams = ctx.getInitParameter(INIT_ALGORITHM_PARAM);
         
@@ -662,7 +700,8 @@ public final class StateUtils {
         return algorithmParams;
     }
 
-    private static String findAlgorithm(ExternalContext ctx) {
+    private static String findAlgorithm(ExternalContext ctx)
+    {
         
         String algorithm = ctx.getInitParameter(INIT_ALGORITHM);
         
@@ -674,7 +713,8 @@ public final class StateUtils {
         return findAlgorithm( algorithm );
     }
     
-    private static String findAlgorithm(ServletContext ctx) {
+    private static String findAlgorithm(ServletContext ctx)
+    {
 
         String algorithm = ctx.getInitParameter(INIT_ALGORITHM);
         
@@ -686,7 +726,8 @@ public final class StateUtils {
         return findAlgorithm( algorithm );
     }
     
-    private static String findAlgorithm(String initParam) {
+    private static String findAlgorithm(String initParam)
+    {
         
         if (initParam == null)
         {
@@ -712,13 +753,18 @@ public final class StateUtils {
      * stored in application scope where it can be used for all requests.
      */
     
-    public static void initSecret(ServletContext ctx){
+    public static void initSecret(ServletContext ctx)
+    {
         
         if(ctx == null)
+        {
             throw new NullPointerException("ServletContext ctx");
+        }
         
         if (log.isLoggable(Level.FINE))
+        {
             log.fine("Storing SecretKey @ " + INIT_SECRET_KEY_CACHE);
+        }
 
         // Create and store SecretKey on application scope
         String cache = ctx.getInitParameter(INIT_SECRET_KEY_CACHE);
@@ -732,11 +778,14 @@ public final class StateUtils {
         {
             String algorithm = findAlgorithm(ctx);
             // you want to create this as few times as possible
-            ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx, algorithm), algorithm));
+            ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(
+                    findSecret(ctx, algorithm), algorithm));
         }
 
         if (log.isLoggable(Level.FINE))
+        {
             log.fine("Storing SecretKey @ " + INIT_MAC_SECRET_KEY_CACHE);
+        }
         
         String macCache = ctx.getInitParameter(INIT_MAC_SECRET_KEY_CACHE);
         
@@ -749,7 +798,8 @@ public final class StateUtils {
         {
             String macAlgorithm = findMacAlgorithm(ctx);
             // init mac secret and algorithm 
-            ctx.setAttribute(INIT_MAC_SECRET_KEY_CACHE, new SecretKeySpec(findMacSecret(ctx, macAlgorithm), macAlgorithm));
+            ctx.setAttribute(INIT_MAC_SECRET_KEY_CACHE, new SecretKeySpec(
+                    findMacSecret(ctx, macAlgorithm), macAlgorithm));
         }
     }
     
@@ -793,8 +843,10 @@ public final class StateUtils {
         }
         
         if( ! ( secretKey instanceof SecretKey ) )
+        {
             throw new ClassCastException("Did not find an instance of SecretKey "
                     + "in application scope using the key '" + INIT_SECRET_KEY_CACHE + "'");
+        }
 
         
         return (SecretKey) secretKey;
@@ -824,7 +876,8 @@ public final class StateUtils {
         return findSecret(secret, algorithm);
     }
     
-    private static byte[] findSecret(String secret, String algorithm) {
+    private static byte[] findSecret(String secret, String algorithm)
+    {
         byte[] bytes = null;
         
         if(secret == null)
@@ -835,7 +888,9 @@ public final class StateUtils {
                 bytes = kg.generateKey().getEncoded();
                 
                 if(log.isLoggable(Level.FINE))
+                {
                     log.fine("generated random password of length " + bytes.length);
+                }
             }
             catch (NoSuchAlgorithmException e)
             {
@@ -845,7 +900,9 @@ public final class StateUtils {
                 new Random().nextBytes(bytes);
                 
                 if(log.isLoggable(Level.FINE))
+                {
                     log.fine("generated random password of length " + length);
+                }
             }
         }
         else 
@@ -856,7 +913,8 @@ public final class StateUtils {
         return bytes;
     }
 
-    private static String findMacAlgorithm(ExternalContext ctx) {
+    private static String findMacAlgorithm(ExternalContext ctx)
+    {
         
         String algorithm = ctx.getInitParameter(INIT_MAC_ALGORITHM);
         
@@ -869,7 +927,8 @@ public final class StateUtils {
 
     }
     
-    private static String findMacAlgorithm(ServletContext ctx) {
+    private static String findMacAlgorithm(ServletContext ctx)
+    {
 
         String algorithm = ctx.getInitParameter(INIT_MAC_ALGORITHM);
         
@@ -882,7 +941,8 @@ public final class StateUtils {
         
     }
     
-    private static String findMacAlgorithm(String initParam) {
+    private static String findMacAlgorithm(String initParam)
+    {
         
         if (initParam == null)
         {
@@ -938,8 +998,10 @@ public final class StateUtils {
         }
         
         if( ! ( secretKey instanceof SecretKey ) )
+        {
             throw new ClassCastException("Did not find an instance of SecretKey "
                     + "in application scope using the key '" + INIT_MAC_SECRET_KEY_CACHE + "'");
+        }
 
         
         return (SecretKey) secretKey;
@@ -969,7 +1031,8 @@ public final class StateUtils {
         return findMacSecret(secret, algorithm);
     }
 
-    private static byte[] findMacSecret(String secret, String algorithm) {
+    private static byte[] findMacSecret(String secret, String algorithm)
+    {
         byte[] bytes = null;
         
         if(secret == null)
@@ -980,7 +1043,9 @@ public final class StateUtils {
                 bytes = kg.generateKey().getEncoded();
                 
                 if(log.isLoggable(Level.FINE))
+                {
                     log.fine("generated random mac password of length " + bytes.length);
+                }
             }
             catch (NoSuchAlgorithmException e)
             {
@@ -990,7 +1055,9 @@ public final class StateUtils {
                 new Random().nextBytes(bytes);
                 
                 if(log.isLoggable(Level.FINE))
+                {
                     log.fine("generated random mac password of length " + length);
+                }
             }
         }
         else 

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StringUtils.java?rev=1202478&r1=1202477&r2=1202478&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StringUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StringUtils.java Tue Nov 15 23:51:35 2011
@@ -18,8 +18,6 @@
  */
 package org.apache.myfaces.shared.util;
 
-import org.apache.myfaces.shared.util.ArrayUtils;
-
 import java.util.ArrayList;
 
 
@@ -267,31 +265,33 @@ public final class StringUtils
             return "";
         }
 
-        int end_ = str.indexOf(quote, begin);
+        int endInt = str.indexOf(quote, begin);
 
         // If no quotes, return the original string
         // and save StringBuffer allocation/char copying
-        if (end_ < 0)
+        if (endInt < 0)
         {
             return str.substring(begin, end);
         }
 
         StringBuffer sb     = new StringBuffer(end - begin);
-        int          begin_ = begin; // need begin later
-        for (; (end_ >= 0) && (end_ < end);
-            end_ = str.indexOf(quote, begin_ = end_ + 2))
+        int          beginInt = begin; // need begin later
+        do
         {
-            if (((end_ + 1) >= end) || (str.charAt(end_ + 1) != quote))
+            if (((endInt + 1) >= end) || (str.charAt(endInt + 1) != quote))
             {
                 throw new IllegalArgumentException(
                     "Internal quote not doubled in string '"
                     + str.substring(begin, end) + "'");
             }
 
-            sb.append(substring(str, begin_, end_)).append(quote);
+            sb.append(substring(str, beginInt, endInt)).append(quote);
+            beginInt = endInt + 2;
+            endInt = str.indexOf(quote, beginInt);
         }
+        while ((endInt >= 0) && (endInt < end));
 
-        return sb.append(substring(str, begin_, end)).toString();
+        return sb.append(substring(str, beginInt, end)).toString();
     }
 
     /**
@@ -330,15 +330,15 @@ public final class StringUtils
             return str.substring(begin, end);
         }
 
-        int _end = end - 1;
-        if ((str.length() < 2) || (str.charAt(_end) != quote))
+        int endInt = end - 1;
+        if ((str.length() < 2) || (str.charAt(endInt) != quote))
         {
             throw new IllegalArgumentException(
                 "Closing quote missing in string '"
                 + substring(str, begin, end) + "'");
         }
 
-        return dequote(str, begin + 1, _end, quote);
+        return dequote(str, begin + 1, endInt, quote);
     }
 
     public static String replace(String str, String repl, String with)
@@ -358,9 +358,11 @@ public final class StringUtils
         StringBuffer out     =
             new StringBuffer((lendiff <= 0) ? str.length()
                 : (str.length() + (10 * lendiff)));
-        for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + len))
+        while(pos >= 0)
         {
             out.append(substring(str, lastindex, pos)).append(with);
+            lastindex = pos + len;
+            pos = str.indexOf(repl, lastindex);
         }
 
         return out.append(substring(str, lastindex, str.length())).toString();
@@ -383,9 +385,11 @@ public final class StringUtils
             new StringBuffer((lendiff <= 0) ? str.length()
                 : (str.length() + (10 * lendiff)));
         int          lastindex = 0;
-        for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + 1))
+        while( pos >= 0)
         {
             out.append(substring(str, lastindex, pos)).append(with);
+            lastindex = pos + 1;
+            pos = str.indexOf(repl, lastindex);
         }
 
         return out.append(substring(str, lastindex, len)).toString();
@@ -396,11 +400,13 @@ public final class StringUtils
     {
         int lastindex = 0;
         int len = repl.length();
-        for (int index = s.indexOf(repl); index >= 0;
-                    index = s.indexOf(repl, lastindex = index + len))
+        int index = s.indexOf(repl);
+        while (index >= 0)
         {
             // we have search string at position index
             out.append(substring(s, lastindex, index)).append(with);
+            lastindex = index + len;
+            index = s.indexOf(repl, lastindex);
         }
 
         return out.append(substring(s, lastindex, len));
@@ -417,21 +423,23 @@ public final class StringUtils
      */
     public static String[] splitLongString(String str, char separator)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }
 
         int       oldPos = 0;
         ArrayList list = new ArrayList();
-        for (
-            int pos = str.indexOf(separator); pos >= 0;
-                    pos = str.indexOf(separator, (oldPos = (pos + 1))))
+        int pos = str.indexOf(separator);
+        while(pos >= 0)
         {
             list.add(substring(str, oldPos, pos));
+            oldPos = (pos + 1);
+            pos = str.indexOf(separator, oldPos);
         }
 
+
         list.add(substring(str, oldPos, len));
 
         return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
@@ -453,8 +461,8 @@ public final class StringUtils
     public static String[] splitLongString(
         String str, char separator, char quote)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }
@@ -518,8 +526,8 @@ public final class StringUtils
      */
     public static String[] splitShortString(String str, char separator)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return org.apache.myfaces.shared.util.ArrayUtils.EMPTY_STRING_ARRAY;
         }
@@ -540,11 +548,14 @@ public final class StringUtils
         int      oldPos = 0;
 
         // Step 3: retrieve substrings
-        for (
-            int pos = str.indexOf(separator), i = 0; pos >= 0;
-                    pos = str.indexOf(separator, (oldPos = (pos + 1))))
+        int pos = str.indexOf(separator);
+        int i = 0;
+        
+        while (pos >= 0)
         {
             list[i++] = substring(str, oldPos, pos);
+            oldPos = (pos + 1);
+            pos = str.indexOf(separator, oldPos);
         }
 
         list[lastTokenIndex] = substring(str, oldPos, len);
@@ -569,8 +580,8 @@ public final class StringUtils
     public static String[] splitShortString(
         String str, char separator, char quote)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }