From: Michael D. <mik...@us...> - 2004-05-11 19:27:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17081 Modified Files: Binder.cs Configuration.cs Log Message: Added code to use jcs-cache element in mapping file. NOTE: this is very likely in a future build to change to something like <cache> instead of <jcs-cache>. Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Binder.cs 3 May 2004 14:33:18 -0000 1.23 --- Binder.cs 11 May 2004 19:26:59 -0000 1.24 *************** *** 263,266 **** --- 263,274 ---- } break; + + case "jcs-cache": + model.Cache = Configuration.CreateCache( + subnode.Attributes["usage"].Value, + model.PersistentClazz.Name, + model ); + + break; } } *************** *** 1084,1087 **** --- 1092,1102 ---- else if ( "many-to-any".Equals(name) ) { Any element = new Any( model.Table ); model.Element = element; BindAny(subnode, element, true); } + else if ( "jcs-cache".Equals(name) ) + { + model.Cache = Configuration.CreateCache( + subnode.Attributes["usage"].Value, + model.Role, + model.Owner ); + } } Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Configuration.cs 29 Apr 2004 17:46:37 -0000 1.13 --- Configuration.cs 11 May 2004 19:26:59 -0000 1.14 *************** *** 703,706 **** --- 703,730 ---- } + public static ICacheConcurrencyStrategy CreateCache(string usage, string name, PersistentClass owner) + { + log.Info("creating cache region: " + name + ", usage: " + usage); + + ICache cache = new HashtableCache(name); + + switch (usage) + { + case "read-only": + if (owner.IsMutable) log.Warn("read-only cache configured for mutable: " + name); + return new ReadOnlyCache(cache); + + case "read-write": + return new ReadWriteCache(cache); + + case "nonstrict-read-write": + return new NonstrictReadWriteCache(cache); + + default: + throw new MappingException("jcs-cache usage attribute should be read-only, read-write, or nonstrict-read-write only"); + + } + } + /// <summary> /// Get the query language imports |