You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Gurkan Erdogdu <gu...@yahoo.com> on 2009/04/15 23:22:19 UTC

Re: svn commit: r765359 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ spi/deployer/ spi/ee/deployer/ spi/se/deployer/

where you close the FileInputStream in the statement

<<this.xmlConfigurator.configure(new FileInputStream(fileName), fileName);>>

Maybe re-written as
FileInputStream str = new FileInputStream(....);

finally{
    str.close();
}




________________________________
From: "struberg@apache.org" <st...@apache.org>
To: openwebbeans-commits@incubator.apache.org
Sent: Thursday, April 16, 2009 12:04:17 AM
Subject: svn commit: r765359 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ spi/deployer/ spi/ee/deployer/ spi/se/deployer/

Author: struberg
Date: Wed Apr 15 21:04:17 2009
New Revision: 765359

URL: http://svn.apache.org/viewvc?rev=765359&view=rev
Log:
OWB-89 rework xmlLocations to contain the file paths only and no more open InputStreams

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=765359&r1=765358&r2=765359&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java Wed Apr 15 21:04:17 2009
@@ -13,6 +13,8 @@
  */
package org.apache.webbeans.config;

+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
@@ -243,18 +245,24 @@

     }

-    protected void deployFromXML(MetaDataDiscoveryService scanner)
+    protected void deployFromXML(MetaDataDiscoveryService scanner) throws WebBeansDeploymentException
     {
        logger.info("Deploying configurations from XML files is started");

-        Map<String, InputStream> xmls = scanner.getWebBeansXmlLocations();
-        Set<String> keySet = xmls.keySet();
-        Iterator<String> it = keySet.iterator();
+        Set<String> xmlLocations = scanner.getWebBeansXmlLocations();
+        Iterator<String> it = xmlLocations.iterator();

         while (it.hasNext())
         {
             String fileName = it.next();
-            this.xmlConfigurator.configure(xmls.get(fileName), fileName);
+            try
+            {
+                this.xmlConfigurator.configure(new FileInputStream(fileName), fileName);
+            } 
+            catch (FileNotFoundException e)
+            {
+                throw new WebBeansDeploymentException(e);
+            }
         }

         logger.info("Deploying configurations from XML is ended succesfully");

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java?rev=765359&r1=765358&r2=765359&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java Wed Apr 15 21:04:17 2009
@@ -20,6 +20,7 @@
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@@ -30,7 +31,7 @@
public abstract class AbstractMetaDataDiscovery implements MetaDataDiscoveryService
{
     /** Location of the beans.xml files. */
-    private Map<String, InputStream> webBeansXmlLocations = new HashMap<String, InputStream>();
+    private Set<String> webBeansXmlLocations = new HashSet<String>();

     //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();

@@ -87,9 +88,9 @@
     /**
      * @return the wEBBEANS_XML_LOCATIONS
      */
-    public Map<String, InputStream> getWebBeansXmlLocations()
+    public Set<String> getWebBeansXmlLocations()
     {
-        return Collections.unmodifiableMap(webBeansXmlLocations);
+        return Collections.unmodifiableSet(webBeansXmlLocations);
     }

     /**
@@ -109,11 +110,14 @@
     {
         return annotationDB.getClassIndex();
     }
-    
-    protected void addWebBeansXmlLocation(String file, InputStream openStream)
+
+    /**
+     * add the given beans.xml path to the locations list 
+     * @param file location path
+     */
+    protected void addWebBeansXmlLocation(String file)
     {
-        webBeansXmlLocations.put(file, openStream);
-        
+        webBeansXmlLocations.add(file);
     }

}

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java?rev=765359&r1=765358&r2=765359&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/MetaDataDiscoveryService.java Wed Apr 15 21:04:17 2009
@@ -16,7 +16,6 @@
  */
package org.apache.webbeans.spi.deployer;

-import java.io.InputStream;
import java.util.Map;
import java.util.Set;

@@ -45,10 +44,9 @@
     public void scan() throws WebBeansDeploymentException;
    
     /**
-     * get the locations of the beans.xml files.
-     * @return key is the 
+     * @return the locations of the beans.xml files. 
      */
-    public Map<String, InputStream> getWebBeansXmlLocations();
+    public Set<String> getWebBeansXmlLocations();
    
     /**
      * Get all scanned classes and all annotations used by each very class.

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java?rev=765359&r1=765358&r2=765359&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java Wed Apr 15 21:04:17 2009
@@ -114,7 +114,7 @@

                 listURL.add(url);

-                addWebBeansXmlLocation(addPath.getFile(), addPath.openStream());
+                addWebBeansXmlLocation(addPath.getFile());
             }
         }

@@ -133,7 +133,7 @@

         if (url != null)
         {
-            addWebBeansXmlLocation(url.getFile(), url.openStream());
+            addWebBeansXmlLocation(url.getFile());

             return WarUrlFinder.findWebInfClassesPath(this.servletContext);
         }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java?rev=765359&r1=765358&r2=765359&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/se/deployer/MetaDataDiscoveryStandard.java Wed Apr 15 21:04:17 2009
@@ -17,8 +17,6 @@

import java.net.URL;
import java.util.Enumeration;
-import java.util.Map;
-import java.util.Set;

import org.apache.webbeans.spi.deployer.AbstractMetaDataDiscovery;
import org.apache.webbeans.util.WebBeansUtil;
@@ -58,7 +56,7 @@
             while (resources.hasMoreElements())
             {
                 URL resource = resources.nextElement();
-                addWebBeansXmlLocation(resource.getFile(), resource.openStream());
+                addWebBeansXmlLocation(resource.getFile());
             }

         }