[hibernate-commits] Hibernate SVN: r10710 - branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Nov 3 10:35:51 EST 2006


Author: steve.ebersole at jboss.com
Date: 2006-11-03 10:35:48 -0500 (Fri, 03 Nov 2006)
New Revision: 10710

Modified:
   branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
Log:
HHH-2108 : fixed cacheable files

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java	2006-11-03 15:33:09 UTC (rev 10709)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Configuration.java	2006-11-03 15:35:48 UTC (rev 10710)
@@ -309,14 +309,15 @@
 	}
 
 	/**
-	 * Add a cacheable mapping file.  A cached file is a serialized representation
+	 * Add a cached mapping file.  A cached file is a serialized representation
 	 * of the DOM structure of a particular mapping.  It is saved from a previous
 	 * call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
 	 * the name of the original mapping file.
 	 * </p>
-	 * If a cached file exists and is newer than the incoming xml file, the cached
-	 * file will be read directly. Otherwise xmlFile is read (and cached in
-	 * serializable form for use next time) and used.
+	 * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than
+	 * <tt>xmlFile</tt> the <tt>".bin"</tt> file will be read directly. Otherwise
+	 * xmlFile is read and then serialized to <tt>xmlFile + ".bin"</tt> for use
+	 * the next time.
 	 *
 	 * @param xmlFile The cacheable mapping file to be added.
 	 * @return this (for method chaining purposes)
@@ -340,6 +341,9 @@
 				catch ( SerializationException e ) {
 					log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
 				}
+				catch ( FileNotFoundException e ) {
+					log.warn( "I/O reported cached file could not be found : " + cachedFile.getPath(), e );
+				}
 			}
 
 			// if doc is null, then for whatever reason, the cached file cannot be used...
@@ -350,10 +354,15 @@
 
 				log.info( "Reading mappings from file: " + xmlFile );
 				List errors = new ArrayList();
-				doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
-				if ( errors.size() != 0 ) {
-					throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+				try {
+					doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
+					if ( errors.size() != 0 ) {
+						throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
+					}
 				}
+				catch( DocumentException e){
+					throw new MappingException( "invalid mapping", e );
+				}
 
 				try {
 					log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
@@ -362,15 +371,21 @@
 				catch ( SerializationException e ) {
 					log.warn( "Could not write cached file: " + cachedFile, e );
 				}
+				catch ( FileNotFoundException e ) {
+					log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
+				}
 			}
 
 			add( doc );
 			return this;
 
 		}
-		catch ( MappingException e ) {
+		catch ( InvalidMappingException e ) {
 			throw e;
 		}
+		catch  ( MappingNotFoundException e ) {
+			throw e;
+		}
 		catch ( Exception e ) {
 			throw new InvalidMappingException( "file", xmlFile.toString(), e );
 		}




More information about the hibernate-commits mailing list