myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r743106 - in /myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config: FacesConfigurator.java impl/digester/DigesterFacesConfigDispenserImpl.java
Date Tue, 10 Feb 2009 21:22:14 GMT
Author: bommel
Date: Tue Feb 10 21:22:12 2009
New Revision: 743106

URL: http://svn.apache.org/viewvc?rev=743106&view=rev
Log:
minor cleanup

Modified:
    myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java

Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=743106&r1=743105&r2=743106&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
(original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
Tue Feb 10 21:22:12 2009
@@ -207,14 +207,15 @@
             lastModified = resModified;
 
 
-        List configFilesList = getConfigFilesList();
-
-        for (int i = 0; i < configFilesList.size(); i++) {
-            String systemId = (String) configFilesList.get(i);
+        List<String> configFilesList = getConfigFilesList();
 
+        for (String systemId : configFilesList)
+        {
             resModified = getResourceLastModified(systemId);
-                if (resModified > lastModified)
-                    lastModified = resModified;
+            if (resModified > lastModified)
+            {
+                lastModified = resModified;
+            }
 
         }
 
@@ -347,18 +348,17 @@
             {
                 URL url = (URL) it.next();
 
-                for (int i = 0; i < li.size(); i++)
+                for (VersionInfo versionInfo : li)
                 {
-                    VersionInfo versionInfo = li.get(i);
                     if (checkJar(versionInfo, url))
+                    {
                         break;
+                    }
                 }
             }
 
-            for (int i = 0; i < li.size(); i++)
+            for (VersionInfo versionInfo : li)
             {
-                VersionInfo versionInfo = li.get(i);
-
                 if (versionInfo.getUsedVersion() != null)
                 {
                     if (log.isInfoEnabled())
@@ -457,9 +457,8 @@
     {
         try
         {
-            for (Iterator<String> iterator = FACTORY_NAMES.iterator(); iterator.hasNext();)
+            for (String factoryName : FACTORY_NAMES)
             {
-                String factoryName = iterator.next();
                 Iterator it = ClassUtils.getResources(META_INF_SERVICES_RESOURCE_PREFIX +
factoryName, this);
                 while (it.hasNext())
                 {
@@ -475,13 +474,24 @@
                     catch (IOException e)
                     {
                         throw new FacesException("Unable to read class name from file " +
url.toExternalForm(), e);
+                    } finally {
+                        if (br != null)
+                        {
+                            br.close();
+                        }
+                        if (isr != null) {
+                            isr.close();
+                        }
+                        if (stream != null) {
+                            stream.close();
+                        }
                     }
-                    br.close();
-                    isr.close();
-                    stream.close();
+
 
                     if (log.isInfoEnabled())
+                    {
                         log.info("Found " + factoryName + " factory implementation: " + className);
+                    }
 
                     if (factoryName.equals(FactoryFinder.APPLICATION_FACTORY))
                     {
@@ -565,9 +575,9 @@
 
     private void feedContextSpecifiedConfig() throws IOException, SAXException
     {
-        List configFilesList = getConfigFilesList();
-        for (int i = 0; i < configFilesList.size(); i++) {
-            String systemId = (String) configFilesList.get(i);
+        List<String> configFilesList = getConfigFilesList();
+        for (String systemId : configFilesList)
+        {
             InputStream stream = _externalContext.getResourceAsStream(systemId);
             if (stream == null)
             {
@@ -575,15 +585,18 @@
                 continue;
             }
 
-            if (log.isInfoEnabled()) log.info("Reading config " + systemId);
+            if (log.isInfoEnabled())
+            {
+                log.info("Reading config " + systemId);
+            }
             getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId));
             stream.close();
         }
     }
 
-    private List getConfigFilesList() {
+    private List<String> getConfigFilesList() {
         String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
-        List configFilesList = new ArrayList();
+        List<String> configFilesList = new ArrayList<String>();
         if (configFiles != null)
         {
             StringTokenizer st = new StringTokenizer(configFiles, ",", false);
@@ -733,9 +746,6 @@
                 .getVariableResolverIterator(), new VariableResolverImpl()));
     }
 
-    /**
-     * @return
-     */
     protected RuntimeConfig getRuntimeConfig()
     {
         if(_runtimeConfig == null) 

Modified: myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java?rev=743106&r1=743105&r2=743106&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
(original)
+++ myfaces/core/trunk_1.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
Tue Feb 10 21:22:12 2009
@@ -47,7 +47,6 @@
         FacesConfigDispenser<FacesConfig>
 {
 
-    private List<FacesConfig> configs = new ArrayList<FacesConfig>();
     private List<String> applicationFactories = new ArrayList<String>();
     private List<String> facesContextFactories = new ArrayList<String>();
     private List<String> lifecycleFactories = new ArrayList<String>();
@@ -76,16 +75,13 @@
     /**
      * Add another unmarshalled faces config object.
      * 
-     * @param facesConfig
+     * @param config
      *            unmarshalled faces config object
      */
     public void feed(FacesConfig config)
     {
-        configs.add(config);
-        for (Iterator iterator = config.getFactories().iterator(); iterator
-                .hasNext();)
+        for (Factory factory : config.getFactories())
         {
-            Factory factory = (Factory) iterator.next();
             applicationFactories.addAll(factory.getApplicationFactory());
             facesContextFactories.addAll(factory.getFacesContextFactory());
             lifecycleFactories.addAll(factory.getLifecycleFactory());
@@ -94,10 +90,8 @@
         components.putAll(config.getComponents());
         validators.putAll(config.getValidators());
 
-        for (Iterator iterator = config.getApplications().iterator(); iterator
-                .hasNext();)
+        for (Application application : config.getApplications())
         {
-            Application application = (Application) iterator.next();
             if (!application.getDefaultRenderkitId().isEmpty())
             {
                 defaultRenderKitId = application
@@ -123,19 +117,16 @@
             resourceBundles.addAll(application.getResourceBundle());
             elResolvers.addAll(application.getElResolver());
         }
-        for (Iterator iterator = config.getConverters().iterator(); iterator
-                .hasNext();)
-        {
-            Converter converter = (Converter) iterator.next();
+        for (Converter converter : config.getConverters()) {
 
             if (converter.getConverterId() != null)
             {
-                converterById.put(converter.getConverterId(), converter
+                converterById.put(converter.getConverterId(),converter
                         .getConverterClass());
             }
             else
             {
-                converterByClass.put(converter.getForClass(), converter
+                converterByClass.put(converter.getForClass(),converter
                         .getConverterClass());
             }
 



Mime
View raw message