[Castore-commits] Utils.java 1.22 1.23

mathieu grimault grimault-m at adullact1.hosting.cri74.org
Ven 8 Déc 17:23:43 CET 2006


Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/common
In directory adullact1:/tmp/cvs-serv25455/src/java/fr/emn/castor/common

Modified Files:
	Utils.java 
Log Message:
Modification de la logique de récup d'une ressource en stream afin de minimiser les logs et les appels inutiles

Index: Utils.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/common/Utils.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Utils.java	7 Dec 2006 09:10:47 -0000	1.22
--- Utils.java	8 Dec 2006 16:23:40 -0000	1.23
***************
*** 131,156 ****
       */
      public static InputStream getResourceAsStream(final String name) {
!         try {
!             return new FileInputStream(new File(name));
!         } catch (FileNotFoundException e) {
!             if (log.isDebugEnabled()) {
!                 log.debug(
!                 	"Ressource not found under " + 
!                 	name +  " Trying classloader..."
!                 );
!             }
!             InputStream resource = Utils.class.getResourceAsStream(name);
!             if (resource != null) {
                  if (log.isDebugEnabled()) {
!                     log.debug("...ok");
                  }
!                 return resource;
!             }
!             if (log.isDebugEnabled()) {
!                 log.debug("...fail !");
!             }
!             return null;
!         }
      }
  
      /**
--- 131,160 ----
       */
      public static InputStream getResourceAsStream(final String name) {
!     	InputStream resource = Utils.class.getResourceAsStream(name);
!     	if (resource == null) {
!             try {
!             	resource = new FileInputStream(new File(name));
!             	if (resource != null) {
!                     if (log.isDebugEnabled()) {
!                         log.debug(
!                         	"Ressource not found in the classloader, " + 
!                         	"Trying under " + name + "...ok"
!                         );
!                     }
!                 }
!             } catch (FileNotFoundException e) {
                  if (log.isDebugEnabled()) {
!                 	if (log.isDebugEnabled()) {
!                         log.debug(
!                         	"Ressource not found in the classloader, " + 
!                         	"Trying under " + name + "...fail"
!                         );
!                     }
                  }
!             }	
!     	}
!     	return resource;
      }
+     
  
      /**




Plus d'informations sur la liste de diffusion Castore-commits