You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael D. <mik...@us...> - 2004-10-05 15:26:39
|
Update of /cvsroot/nhibernate/nhibernate/external-bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26229/external-bin Added Files: Tag: alpha_avalon-proxy Apache.Avalon.DynamicProxy.pdb Log Message: much work done to implement proxies with classes and virtual properties. All test that are being run now pass with proxy="some class" --- NEW FILE: Apache.Avalon.DynamicProxy.pdb --- (This appears to be a binary file; contents omitted.) |
From: Michael D. <mik...@us...> - 2004-10-05 15:26:32
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26229/src/NHibernate/Impl Modified Files: Tag: alpha_avalon-proxy SessionImpl.cs Log Message: much work done to implement proxies with classes and virtual properties. All test that are being run now pass with proxy="some class" Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.44.2.2 retrieving revision 1.44.2.3 diff -C2 -d -r1.44.2.2 -r1.44.2.3 *** SessionImpl.cs 3 Oct 2004 16:58:14 -0000 1.44.2.2 --- SessionImpl.cs 5 Oct 2004 15:25:05 -0000 1.44.2.3 *************** *** 994,998 **** IClassPersister persister = GetPersister( li.PersistentClass ); Key key = new Key( li.Identifier, persister ); ! if ( !proxiesByKey.Contains(key) ) proxiesByKey[key] = proxy; // any earlier proxy takes precedence NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).Session = this; } --- 994,1002 ---- IClassPersister persister = GetPersister( li.PersistentClass ); Key key = new Key( li.Identifier, persister ); ! if ( !proxiesByKey.Contains(key) ) ! { ! proxiesByKey[key] = proxy; // any earlier proxy takes precedence ! } ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).Session = this; } *************** *** 1921,1926 **** else { ! //TODO: Get the proxy - there is some CGLIB code here ! proxy = null; proxiesByKey[key] = proxy; --- 1925,1936 ---- else { ! IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); ! proxy = generator.GetProxy( ! p.MappedClass ! , p.ConcreteProxyClass ! , p.ProxyInterfaces ! , p.ProxyIdentifierProperty ! , key.Identifier ! , this ); proxiesByKey[key] = proxy; *************** *** 2123,2127 **** { IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); ! proxy = generator.GetProxy( clazz, persister.ProxyInterfaces, persister.ProxyIdentifierProperty, id, this ); } proxiesByKey[key] = proxy; --- 2133,2137 ---- { IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); ! proxy = generator.GetProxy( clazz, persister.ConcreteProxyClass, persister.ProxyInterfaces, persister.ProxyIdentifierProperty, id, this ); } proxiesByKey[key] = proxy; *************** *** 2748,2752 **** { LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); ! if ( li.Session!=this ) throw new TransientObjectException("The proxy was not associated with this session"); return li.Identifier; } --- 2758,2765 ---- { LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); ! if ( li.Session!=this ) ! { ! throw new TransientObjectException("The proxy was not associated with this session"); ! } return li.Identifier; } *************** *** 3881,3885 **** if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); --- 3894,3898 ---- if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); |
From: Michael D. <mik...@us...> - 2004-10-05 15:23:10
|
Update of /cvsroot/nhibernate/nhibernate/external-bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25034 Removed Files: Tag: alpha_avalon-proxy Apache.Avalon.DynamicProxy.pdb Log Message: should have been commited as binary. --- Apache.Avalon.DynamicProxy.pdb DELETED --- |
From: Michael D. <mik...@us...> - 2004-10-04 21:15:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4420 Modified Files: IQuery.cs Log Message: Noticed IQuery was missing SetBoolean Index: IQuery.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/IQuery.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IQuery.cs 16 Jul 2004 03:27:03 -0000 1.8 --- IQuery.cs 4 Oct 2004 21:15:34 -0000 1.9 *************** *** 170,199 **** IQuery SetAnsiString(int position, string val); ! IQuery SetString(int position, string val); ! IQuery SetCharacter(int position, char val); IQuery SetByte(int position, byte val); IQuery SetInt16(int position, short val); IQuery SetInt32(int position, int val); IQuery SetInt64(int position, long val); IQuery SetSingle(int position, float val); ! IQuery SetDouble(int position, double val); ! IQuery SetBinary(int position, byte[] val); ! IQuery SetDecimal(int position, decimal val); ! IQuery SetDateTime(int position, DateTime val); IQuery SetTime(int position, DateTime val); IQuery SetTimestamp(int position, DateTime val); IQuery SetAnsiString(string name, string val); ! IQuery SetString(string name, string val); ! IQuery SetCharacter(string name, char val); IQuery SetByte(string name, byte val); IQuery SetInt16(string name, short val); IQuery SetInt32(string name, int val); IQuery SetInt64(string name, long val); IQuery SetSingle(string name, float val); ! IQuery SetDouble(string name, double val); ! IQuery SetBinary(string name, byte[] val); ! IQuery SetDecimal(string name, decimal val); ! IQuery SetDateTime(string name, DateTime val); IQuery SetTime(string name, DateTime val); IQuery SetTimestamp(string name, DateTime val); --- 170,201 ---- IQuery SetAnsiString(int position, string val); ! IQuery SetBinary(int position, byte[] val); ! IQuery SetBoolean(int position, bool val); IQuery SetByte(int position, byte val); + IQuery SetCharacter(int position, char val); + IQuery SetDateTime(int position, DateTime val); + IQuery SetDecimal(int position, decimal val); + IQuery SetDouble(int position, double val); IQuery SetInt16(int position, short val); IQuery SetInt32(int position, int val); IQuery SetInt64(int position, long val); IQuery SetSingle(int position, float val); ! IQuery SetString(int position, string val); IQuery SetTime(int position, DateTime val); IQuery SetTimestamp(int position, DateTime val); IQuery SetAnsiString(string name, string val); ! IQuery SetBinary(string name, byte[] val); ! IQuery SetBoolean(string name, bool val); IQuery SetByte(string name, byte val); + IQuery SetCharacter(string name, char val); + IQuery SetDateTime(string name, DateTime val); + IQuery SetDecimal(string name, decimal val); + IQuery SetDouble(string name, double val); IQuery SetInt16(string name, short val); IQuery SetInt32(string name, int val); IQuery SetInt64(string name, long val); IQuery SetSingle(string name, float val); ! IQuery SetString(string name, string val); IQuery SetTime(string name, DateTime val); IQuery SetTimestamp(string name, DateTime val); |
From: Michael D. <mik...@us...> - 2004-10-04 13:13:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18488 Modified Files: Tag: alpha_avalon-proxy AvalonLazyInitializer.cs LazyInitializer.cs Log Message: Fixed typo pointed out by Peter. Index: LazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/LazyInitializer.cs,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** LazyInitializer.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 --- LazyInitializer.cs 4 Oct 2004 13:13:04 -0000 1.1.2.3 *************** *** 104,108 **** /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> to write the object to.</param> ! protected abstract void AddSerailizationInfo(SerializationInfo info); public object Identifier --- 104,108 ---- /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> to write the object to.</param> ! protected abstract void AddSerializationInfo(SerializationInfo info); public object Identifier *************** *** 189,193 **** // let the specific LazyInitializer write its requirements for deserialization // into the stream. ! AddSerailizationInfo( info ); // don't need a return value for proxy. --- 189,193 ---- // let the specific LazyInitializer write its requirements for deserialization // into the stream. ! AddSerializationInfo( info ); // don't need a return value for proxy. Index: AvalonLazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/Attic/AvalonLazyInitializer.cs,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** AvalonLazyInitializer.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 --- AvalonLazyInitializer.cs 4 Oct 2004 13:13:04 -0000 1.1.2.3 *************** *** 34,38 **** ! protected override void AddSerailizationInfo(SerializationInfo info) { // the AvalonProxyDeserializer will be the Type that is actually serialized for this --- 34,38 ---- ! protected override void AddSerializationInfo(SerializationInfo info) { // the AvalonProxyDeserializer will be the Type that is actually serialized for this |
From: Michael D. <mik...@us...> - 2004-10-04 01:43:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30348/NHibernate.Test Modified Files: Tag: alpha_avalon-proxy FooBarTest.cs Log Message: implemented some of the test that were being ignored because proxy of interfaces was not implemented. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.67.2.1 retrieving revision 1.67.2.2 diff -C2 -d -r1.67.2.1 -r1.67.2.2 *** FooBarTest.cs 27 Sep 2004 03:41:45 -0000 1.67.2.1 --- FooBarTest.cs 4 Oct 2004 01:42:46 -0000 1.67.2.2 *************** *** 348,355 **** [Test] - [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void ForceOuterJoin() { ! } --- 348,384 ---- [Test] public void ForceOuterJoin() { ! if( ((Engine.ISessionFactoryImplementor)sessions).EnableJoinedFetch==false ) ! { ! // don't bother to run the test if we can't test it ! return; ! } ! ! ISession s = sessions.OpenSession(); ! Glarch g = new Glarch(); ! FooComponent fc = new FooComponent(); ! fc.Glarch = g; ! FooProxy f = new Foo(); ! FooProxy f2 = new Foo(); ! f.Component = fc; ! f.TheFoo = f2; ! s.Save( f2 ); ! object id = s.Save( f ); ! object gid = s.GetIdentifier( f.Component.Glarch ); ! s.Flush(); ! s.Close(); ! ! s = sessions.OpenSession(); ! f = (FooProxy)s.Load( typeof(Foo), id ); ! Assert.IsFalse( NHibernate.IsInitialized( f ) ); ! Assert.IsTrue( NHibernate.IsInitialized( f.Component.Glarch ) ); //outer-join="true" ! Assert.IsFalse( NHibernate.IsInitialized( f.TheFoo ) ); //outer-join="auto" ! Assert.AreEqual( gid, s.GetIdentifier( f.Component.Glarch ) ); ! s.Delete( f ); ! s.Delete( f.TheFoo ); ! s.Flush(); ! s.Close(); ! } *************** *** 507,511 **** [Test] - [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void NamedParams() { --- 536,539 ---- *************** *** 523,531 **** s.Save(bar2); - // TODO: at this point it fails because of SessionImpl.ProxyFor IList list = s.Find("from Bar bar left join bar.Baz baz left join baz.CascadingBars b where bar.Name like 'Bar %'"); object row = list[0]; Assert.IsTrue( row is object[] && ( (object[])row).Length==3 ); } --- 551,597 ---- s.Save(bar2); IList list = s.Find("from Bar bar left join bar.Baz baz left join baz.CascadingBars b where bar.Name like 'Bar %'"); object row = list[0]; Assert.IsTrue( row is object[] && ( (object[])row).Length==3 ); + IQuery q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "left join bar.Baz baz left join baz.CascadingBars b " + + "where (bar.Name in (:nameList) or bar.Name in (:nameList)) and bar.String = :stringVal" ); + + IList nameList = new ArrayList(); + nameList.Add( "bar" ); + nameList.Add( "Bar" ); + nameList.Add( "Bar Two" ); + q.SetParameterList( "nameList", nameList ); + q.SetParameter( "stringVal", "a string" ); + list = q.List(); + // a check for SAPDialect here + Assert.AreEqual( 2, list.Count ); + + q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "inner join bar.Baz baz inner join baz.CascadingBars b " + + "where bar.Name like 'bar%'" ); + list = q.List(); + Assert.AreEqual( 1, list.Count ); + + q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "left join bar.Baz baz left join baz.CascadingBars b " + + "where bar.Name like :name and b.Name like :name" ); + + // add a check for HSQLDialect + q.SetString( "name", "Bar%" ); + list = q.List(); + Assert.AreEqual( 1, list.Count ); + + s.Delete( baz ); + s.Delete( bar2 ); + s.Flush(); + s.Close(); } *************** *** 1474,1478 **** [Test] - //[Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void Load() { --- 1540,1543 ---- *************** *** 2702,2708 **** [Test] - [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void ProxyArray() { } --- 2767,2819 ---- [Test] public void ProxyArray() { + ISession s = sessions.OpenSession(); + GlarchProxy g = new Glarch(); + Glarch g1 = new Glarch(); + Glarch g2 = new Glarch(); + g.ProxyArray = new GlarchProxy[] { g1, g2 }; + Glarch g3 = new Glarch(); + s.Save( g3 ); + g2.ProxyArray = new GlarchProxy[] { null, g3, g }; + + object emptyObject = new object(); + IDictionary hashset = new Hashtable(); + hashset.Add( g1, emptyObject ); + hashset.Add( g2, emptyObject ); + g.ProxySet = hashset; + s.Save( g ); + s.Save( g1 ); + s.Save( g2 ); + object id = s.GetIdentifier( g ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + g = (GlarchProxy)s.Load( typeof(Glarch), id ); + Assert.AreEqual( 2, g.ProxyArray.Length, "array of proxies" ); + Assert.IsNotNull( g.ProxyArray[0], "array of proxies" ); + Assert.IsNull( g.ProxyArray[1].ProxyArray[0], "deferred load test" ); + Assert.AreEqual( g, g.ProxyArray[1].ProxyArray[2], "deferred load test" ); + Assert.AreEqual( 2, g.ProxySet.Count, "set of proxies" ); + + IEnumerator enumer = s.Enumerable( "from g in class NHibernate.DomainModel.Glarch" ).GetEnumerator(); + while( enumer.MoveNext() ) + { + s.Delete( enumer.Current ); + } + + s.Flush(); + s.Disconnect(); + + // serialize and then deserialize the session. + System.IO.Stream stream = new System.IO.MemoryStream(); + System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + formatter.Serialize(stream, s); + stream.Position = 0; + s = (ISession)formatter.Deserialize(stream); + stream.Close(); + + s.Close(); } *************** *** 2989,2993 **** [Test] - [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void LoadAfterDelete() { --- 3100,3103 ---- *************** *** 3016,3024 **** bool somevalue = ( (FooProxy)s.Load( typeof(Foo), id )).Boolean; } - // this won't work until Proxies are implemented because now it throws an - // ObjectNotFoundException catch(LazyInitializationException lie) { ! Assert.IsNotNull(lie); //getting ride of 'lie' is never used compile warning err = true; } --- 3126,3132 ---- bool somevalue = ( (FooProxy)s.Load( typeof(Foo), id )).Boolean; } catch(LazyInitializationException lie) { ! Assert.IsNotNull( lie ); //getting ride of 'lie' is never used compile warning err = true; } *************** *** 3252,3273 **** [Test] - [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void ProxiesInCollections() { ! } ! [Test] ! [Ignore("Test not written yet.")] ! public void Service() ! { } [Test] [Ignore("Test not written yet.")] ! public void PSCache() { } - } } --- 3360,3431 ---- [Test] public void ProxiesInCollections() { ! ISession s = sessions.OpenSession(); ! Baz baz = new Baz(); ! Bar bar = new Bar(); ! Bar bar2 = new Bar(); ! s.Save( bar ); ! object bar2id = s.Save( bar2 ); ! baz.FooArray = new Foo[] { bar, bar2 }; ! object emptyObject = new object(); ! IDictionary hashset = new Hashtable(); ! bar = new Bar(); ! s.Save( bar ); ! hashset.Add( bar, emptyObject ); ! baz.FooSet = hashset; ! hashset = new Hashtable(); ! hashset.Add( new Bar(), emptyObject ); ! hashset.Add( new Bar(), emptyObject ); ! baz.CascadingBars = hashset; ! ArrayList list = new ArrayList(); ! list.Add( new Foo() ); ! baz.FooBag = list; ! object id = s.Save( baz ); ! IEnumerator enumer = baz.CascadingBars.Keys.GetEnumerator(); ! enumer.MoveNext(); ! object bid = ((Bar)enumer.Current).Key; ! s.Flush(); ! s.Close(); ! ! s = sessions.OpenSession(); ! BarProxy barprox = (BarProxy)s.Load( typeof(Bar), bid ); ! BarProxy bar2prox = (BarProxy)s.Load( typeof(Bar), bar2id ); ! Assert.IsTrue( bar2prox is Proxy.INHibernateProxy ); ! Assert.IsTrue( barprox is Proxy.INHibernateProxy ); ! baz = (Baz)s.Load( typeof(Baz), id ); ! enumer = baz.CascadingBars.Keys.GetEnumerator(); ! enumer.MoveNext(); ! BarProxy b1 = (BarProxy)enumer.Current; ! enumer.MoveNext(); ! BarProxy b2 = (BarProxy)enumer.Current; ! Assert.IsTrue( ! ( b1==barprox && !(b2 is Proxy.INHibernateProxy) ) ! || ( b2==barprox && !(b1 is Proxy.INHibernateProxy) ) ); //one-to-many ! Assert.IsTrue( baz.FooArray[0] is Proxy.INHibernateProxy ); //many-to-many ! Assert.AreEqual( bar2prox, baz.FooArray[1] ); ! if( ((Engine.ISessionFactoryImplementor)sessions).EnableJoinedFetch ) ! { ! enumer = baz.FooBag.GetEnumerator(); ! enumer.MoveNext(); ! Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); // many-to-many outer-join="true" ! } ! ! enumer = baz.FooSet.Keys.GetEnumerator(); ! enumer.MoveNext(); ! Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); //one-to-many ! s.Delete( "from o in class Baz" ); ! s.Delete( "from o in class Foo" ); ! s.Flush(); ! s.Close(); } [Test] [Ignore("Test not written yet.")] ! public void Service() { } } } |
From: Michael D. <mik...@us...> - 2004-10-04 01:43:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30348/NHibernate.DomainModel/NHSpecific Modified Files: Tag: alpha_avalon-proxy AvalonProxyImpl.cs Log Message: implemented some of the test that were being ignored because proxy of interfaces was not implemented. Index: AvalonProxyImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific/Attic/AvalonProxyImpl.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** AvalonProxyImpl.cs 27 Sep 2004 03:41:45 -0000 1.1.2.1 --- AvalonProxyImpl.cs 4 Oct 2004 01:42:46 -0000 1.1.2.2 *************** *** 6,9 **** --- 6,10 ---- /// Summary description for AvalonProxyImpl. /// </summary> + [Serializable] public class AvalonProxyImpl : AvalonProxy { |
From: Michael D. <mik...@us...> - 2004-10-04 01:43:56
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30348/NHibernate.Test/NHSpecificTest Modified Files: Tag: alpha_avalon-proxy AvalonProxyFixture.cs Log Message: implemented some of the test that were being ignored because proxy of interfaces was not implemented. Index: AvalonProxyFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/Attic/AvalonProxyFixture.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** AvalonProxyFixture.cs 27 Sep 2004 03:42:02 -0000 1.1.2.1 --- AvalonProxyFixture.cs 4 Oct 2004 01:42:45 -0000 1.1.2.2 *************** *** 31,35 **** s = sessions.OpenSession(); ! ap = (AvalonProxy)s.Load( typeof(AvalonProxyImpl), ap.Id ); Assert.IsFalse( NHibernate.IsInitialized( ap ) ); int id = ap.Id; --- 31,35 ---- s = sessions.OpenSession(); ! ap = (AvalonProxy)s.Load( typeof(AvalonProxyImpl), ap.Id ); Assert.IsFalse( NHibernate.IsInitialized( ap ) ); int id = ap.Id; *************** *** 42,45 **** --- 42,73 ---- } + [Test] + public void ProxySerialize() + { + ISession s = sessions.OpenSession(); + AvalonProxy ap = new AvalonProxyImpl(); + ap.Id = 1; + ap.Name = "first proxy"; + s.Save( ap ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + ap = (AvalonProxy)s.Load( typeof(AvalonProxyImpl), ap.Id ); + Assert.AreEqual( 1, ap.Id ); + s.Disconnect(); + + // serialize and then deserialize the session. + System.IO.Stream stream = new System.IO.MemoryStream(); + System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + formatter.Serialize(stream, s); + stream.Position = 0; + s = (ISession)formatter.Deserialize(stream); + stream.Close(); + + + s.Close(); + } + } } |
From: Michael D. <mik...@us...> - 2004-10-04 00:37:49
|
Update of /cvsroot/nhibernate/nhibernate/external-bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18206 Modified Files: Tag: alpha_avalon-proxy Apache.Avalon.DynamicProxy.dll Added Files: Tag: alpha_avalon-proxy Apache.Avalon.DynamicProxy.pdb Log Message: updated to latest code. it is a debug build from my local machine so I put the pdb into cvs. not a big deal since this is an experimental branch anyway. Index: Apache.Avalon.DynamicProxy.dll =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/external-bin/Attic/Apache.Avalon.DynamicProxy.dll,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 Binary files /tmp/cvs9daabb and /tmp/cvsG3HM45 differ --- NEW FILE: Apache.Avalon.DynamicProxy.pdb --- Microsoft C/C++ MSF 7.00 |
From: Michael D. <mik...@us...> - 2004-10-03 18:20:48
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7021/Proxy Modified Files: Tag: alpha_avalon-proxy AvalonLazyInitializer.cs AvalonProxyGenerator.cs IProxyGenerator.cs LazyInitializer.cs ProxyGeneratorFactory.cs Added Files: Tag: alpha_avalon-proxy AvalonProxyDeserializer.cs Removed Files: Tag: alpha_avalon-proxy SerializableProxy.cs Log Message: serialization of proxies is now working. Index: AvalonProxyGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/Attic/AvalonProxyGenerator.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** AvalonProxyGenerator.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 --- AvalonProxyGenerator.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 *************** *** 2,7 **** --- 2,10 ---- using System.Collections; using System.Reflection; + using System.Reflection.Emit; using Apache.Avalon.DynamicProxy; + using Apache.Avalon.DynamicProxy.Builder; + using Apache.Avalon.DynamicProxy.Builder.CodeGenerators; using NHibernate.Engine; *************** *** 10,14 **** { /// <summary> ! /// An <see cref="IProxyGenerator"/> for the Apache.Avalon.DynamicProxy library. /// </summary> public class AvalonProxyGenerator : IProxyGenerator --- 13,17 ---- { /// <summary> ! /// An <see cref="IProxyGenerator"/> that uses the Apache.Avalon.DynamicProxy library. /// </summary> public class AvalonProxyGenerator : IProxyGenerator *************** *** 16,20 **** private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(AvalonProxyGenerator) ); ! private ProxyGenerator _generator = new ProxyGenerator(); /// <summary> --- 19,25 ---- private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(AvalonProxyGenerator) ); ! private ProxyGenerator _generator; ! private DefaultProxyBuilder _defaultBuilder; ! private GeneratorContext _context; /// <summary> *************** *** 22,26 **** /// </summary> internal AvalonProxyGenerator() ! { } --- 27,59 ---- /// </summary> internal AvalonProxyGenerator() ! { ! _defaultBuilder = new DefaultProxyBuilder( ); ! ! // the EnhanceTypeDelegate will add custom code gen that DynamicProxy does not provide ! // by default. ! _context = new GeneratorContext( new EnhanceTypeDelegate( EnhanceInterfaceType ), null ); ! ! // only create the genator once so I should be okay with the DefaultProxyBuilder ! // maintaining the ModuleScope ! _generator = new ProxyGenerator(); ! ! } ! ! /// <summary> ! /// Marks the Proxy with the <see cref="SerializableAttribute"/>. ! /// </summary> ! /// <param name="mainType"></param> ! /// <param name="handlerFieldBuilder"></param> ! /// <param name="constructorBuilder"></param> ! /// <remarks> ! /// The proxy itself is not really serializable, it is replaced with a different object during ! /// serialization. This object knows how to recreate the proxy during the deserialization ! /// process. ! /// </remarks> ! private void EnhanceInterfaceType(TypeBuilder mainType, FieldBuilder handlerFieldBuilder, ConstructorBuilder constructorBuilder) ! { ! ConstructorInfo serAttConstructor = typeof(SerializableAttribute).GetConstructor( new System.Type[0] ); ! CustomAttributeBuilder serializableAttBuilder = new CustomAttributeBuilder( serAttConstructor, new object[0] ); ! mainType.SetCustomAttribute( serializableAttBuilder ); } *************** *** 54,58 **** } ! object generatedProxy = _generator.CreateProxy( interfaces, initializer ); return (INHibernateProxy)generatedProxy; --- 87,92 ---- } ! System.Type proxyType = _defaultBuilder.CreateCustomInterfaceProxy( interfaces, _context ); ! object generatedProxy = Activator.CreateInstance( proxyType, new object[] { initializer } ); return (INHibernateProxy)generatedProxy; *************** *** 66,70 **** #endregion - } } --- 100,103 ---- Index: IProxyGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/Attic/IProxyGenerator.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** IProxyGenerator.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 --- IProxyGenerator.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 *************** *** 22,27 **** /// <returns>A fully built <c>INHibernateProxy</c>.</returns> INHibernateProxy GetProxy(System.Type persistentClass, System.Type[] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session); - - } } --- 22,25 ---- Index: LazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/LazyInitializer.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** LazyInitializer.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 --- LazyInitializer.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using System.Reflection; + using System.Runtime.Serialization; using NHibernate.Engine; *************** *** 31,36 **** protected PropertyInfo _identifierPropertyInfo; protected bool _overridesEquals; ! private SerializableProxy _serializableProxy; ! /// <summary> /// Create a LazyInitializer to handle all of the Methods/Properties that are called --- 32,36 ---- protected PropertyInfo _identifierPropertyInfo; protected bool _overridesEquals; ! /// <summary> /// Create a LazyInitializer to handle all of the Methods/Properties that are called *************** *** 99,107 **** /// <summary> ! /// Converts this Proxy into a Serializable Class that knows how to create a ! /// Proxy during the Deserialization process. /// </summary> ! /// <returns>SerializableProxy that can Deserialize this LazyInitializer.</returns> ! protected abstract SerializableProxy SerializableProxy() ; public object Identifier --- 99,108 ---- /// <summary> ! /// Adds all of the information into the SerializationInfo that is needed to ! /// reconstruct the proxy during deserialization or to replace the proxy ! /// with the instantiated target. /// </summary> ! /// <param name="info">The <see cref="SerializationInfo"/> to write the object to.</param> ! protected abstract void AddSerailizationInfo(SerializationInfo info); public object Identifier *************** *** 172,180 **** /// which indicates that the Proxy will need to forward to the real implementation. /// </returns> ! public virtual object Invoke(MethodInfo method, params object[] args) { // all Proxies must implement INHibernateProxy which extends ISerializable if( method.Name.Equals("GetObjectData") ) { if( _target==null & _session!=null ) { --- 173,184 ---- /// which indicates that the Proxy will need to forward to the real implementation. /// </returns> ! public virtual object Invoke(MethodBase method, params object[] args) { // all Proxies must implement INHibernateProxy which extends ISerializable if( method.Name.Equals("GetObjectData") ) { + SerializationInfo info = (SerializationInfo)args[0]; + StreamingContext context = (StreamingContext)args[1]; + if( _target==null & _session!=null ) { *************** *** 183,198 **** } ! if( _target==null ) ! { ! if( _serializableProxy==null ) ! { ! _serializableProxy = SerializableProxy(); ! } ! return _serializableProxy; ! } ! else ! { ! return _target; ! } } else if( !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals("GetHashCode") ) --- 187,196 ---- } ! // let the specific LazyInitializer write its requirements for deserialization ! // into the stream. ! AddSerailizationInfo( info ); ! ! // don't need a return value for proxy. ! return null; } else if( !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals("GetHashCode") ) *************** *** 204,208 **** } else if( _identifierPropertyInfo!=null && method.Equals( _identifierPropertyInfo.GetGetMethod(true) ) ) - // .Name.Equals( "get_" + _identifierPropertyInfo.Name ) ) -> this was removed because of null _identifierPropertyInfo problems { return _id; --- 202,205 ---- *************** *** 225,297 **** } - - #region Helper Class for all of the Parameters to InvokeMember - - protected class InvokeMemberParams - { - private string _methodName; - private BindingFlags _invokeAttr; - private static IDictionary _knownPrefixes; - - static InvokeMemberParams () - { - BindingFlags defaultFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - _knownPrefixes = new Hashtable(6); - _knownPrefixes.Add("", defaultFlags | BindingFlags.InvokeMethod); - _knownPrefixes.Add("get", defaultFlags | BindingFlags.GetProperty); - _knownPrefixes.Add("set", defaultFlags | BindingFlags.SetProperty); - } - - private InvokeMemberParams(string methodName, BindingFlags invokeAttr) - { - _methodName = methodName; - _invokeAttr = invokeAttr; - } - - public BindingFlags InvokeAttr - { - get { return _invokeAttr; } - } - - public string MethodName - { - get { return _methodName; } - } - - public static InvokeMemberParams GetInvokeMemberParams(string methodName) - { - int indexOfFirstUnderscore = methodName.IndexOf("_"); - string prefix = String.Empty; - - string method; - BindingFlags flags; - - // there was no underscore found in the name - has to be a method that - // is being called. - if(indexOfFirstUnderscore==-1) - { - return new InvokeMemberParams(methodName, (BindingFlags)_knownPrefixes[""] ); - } - - prefix = methodName.Substring(0, indexOfFirstUnderscore); - - // there was an underscore found - is this a property get_/set_ or just a bad naming - // convention that someone is following - if(_knownPrefixes.Contains(prefix)) - { - method = methodName.Substring(indexOfFirstUnderscore + 1, methodName.Length - (indexOfFirstUnderscore + 1) ); - flags = (BindingFlags)_knownPrefixes[prefix]; - - return new InvokeMemberParams(method, flags); - } - else - { - // bad naming convention was used - an "_" in a method name??? - return new InvokeMemberParams(methodName, (BindingFlags)_knownPrefixes[""] ); - } - } - } - #endregion - } } --- 222,225 ---- --- SerializableProxy.cs DELETED --- Index: AvalonLazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/Attic/AvalonLazyInitializer.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** AvalonLazyInitializer.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 --- AvalonLazyInitializer.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using System.Reflection; + using System.Runtime.Serialization; using Apache.Avalon.DynamicProxy; *************** *** 10,14 **** { /// <summary> ! /// A <see cref="NLazyInitiliazer"/> built using Avalon's Dynamic Class Generator. /// </summary> public class AvalonLazyInitializer : LazyInitializer, IInvocationHandler --- 11,15 ---- { /// <summary> ! /// A <see cref="LazyInitiliazer"/> for use with Avalon's Dynamic Class Generator. /// </summary> public class AvalonLazyInitializer : LazyInitializer, IInvocationHandler *************** *** 33,39 **** ! protected override SerializableProxy SerializableProxy() { ! return new SerializableProxy( _persistentClass, _interfaces, _id, _identifierPropertyInfo ); } --- 34,48 ---- ! protected override void AddSerailizationInfo(SerializationInfo info) { ! // the AvalonProxyDeserializer will be the Type that is actually serialized for this ! // proxy. ! info.SetType( typeof(AvalonProxyDeserializer) ); ! ! info.AddValue( "_target", _target ); ! info.AddValue( "_persistentClass", _persistentClass ); ! info.AddValue( "_interfaces", _interfaces ); ! info.AddValue( "_identifierPropertyInfo", _identifierPropertyInfo ); ! info.AddValue( "_id", _id ); } *************** *** 51,59 **** object result = base.Invoke( method, arguments ); ! // the base NLazyInitializer could not handle it so we need to Invoke // the method/property against the real class. if(result==InvokeImplementation) { - InvokeMemberParams invokeParams = InvokeMemberParams.GetInvokeMemberParams( method.Name ); return method.Invoke( GetImplementation(), arguments ); } --- 60,67 ---- object result = base.Invoke( method, arguments ); ! // the base LazyInitializer could not handle it so we need to Invoke // the method/property against the real class. if(result==InvokeImplementation) { return method.Invoke( GetImplementation(), arguments ); } Index: ProxyGeneratorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/Attic/ProxyGeneratorFactory.cs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** ProxyGeneratorFactory.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 --- ProxyGeneratorFactory.cs 3 Oct 2004 16:58:13 -0000 1.1.2.2 *************** *** 15,19 **** private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(ProxyGeneratorFactory) ); ! private static AvalonProxyGenerator _generator = new AvalonProxyGenerator(); public static IProxyGenerator GetProxyGenerator() --- 15,19 ---- private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(ProxyGeneratorFactory) ); ! private static IProxyGenerator _generator = new AvalonProxyGenerator(); public static IProxyGenerator GetProxyGenerator() --- NEW FILE: AvalonProxyDeserializer.cs --- using System; using System.Reflection; using System.Runtime.Serialization; namespace NHibernate.Proxy { /// <summary> /// Deserializes an Avalon generated Proxy into either another Proxy that is regenerated /// or into the target that the generated Proxy was proxying. /// </summary> [Serializable] public class AvalonProxyDeserializer : IObjectReference { // these fields are set during the GetObjectData call in AvalonLazyInitializer. private object _target = null; private System.Type _persistentClass = null; private System.Type[] _interfaces = null; private PropertyInfo _identifierPropertyInfo = null; private object _id = null; #region IObjectReference Members /// <summary> /// Converts a SerializableProxy into the dynamically generated Proxy on the Client side /// or just returns the object that was the target behind the Proxy if it was loaded. /// </summary> /// <param name="context"></param> /// <returns></returns> public object GetRealObject(StreamingContext context) { if( _target==null ) { IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); object proxy = generator.GetProxy( _persistentClass , _interfaces , _identifierPropertyInfo , _id , null ); return proxy; } else { // this object was not serialized as a proxy but instead as the real object // there is nothing to do with it other than return it and let the framework // put it into the deserialized object stream. return _target; } } #endregion } } |
From: Michael D. <mik...@us...> - 2004-10-03 18:07:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7021/Impl Modified Files: Tag: alpha_avalon-proxy SessionImpl.cs Log Message: serialization of proxies is now working. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.44.2.1 retrieving revision 1.44.2.2 diff -C2 -d -r1.44.2.1 -r1.44.2.2 *** SessionImpl.cs 27 Sep 2004 03:42:02 -0000 1.44.2.1 --- SessionImpl.cs 3 Oct 2004 16:58:14 -0000 1.44.2.2 *************** *** 47,50 **** --- 47,58 ---- private IDictionary proxiesByKey; //key=Key, value=HibernateProxy + // these are used to serialize the proxiesByKey Dictionary - I was not able to + // have a Hashtable serialize fully by the time that SessionImpl OnDeserialization + // was getting called - I think I'm not completely understanding the sequence of + // deserialization events. When SessionImpl was getting the OnDeserialization called + // the proxies were not fully deserialized. + private ArrayList tmpProxiesKey; + private ArrayList tmpProxiesProxy; + //IdentityMaps are serializable in NH private IdentityMap entries;//key=Object, value=Entry *************** *** 386,389 **** --- 394,399 ---- protected SessionImpl(SerializationInfo info, StreamingContext context) { + log.Info( "recreating session from special ctor used during deserialization" ); + this.factory = (SessionFactoryImpl)info.GetValue( "factory", typeof(SessionFactoryImpl) ); this.autoClose = info.GetBoolean("autoClose"); *************** *** 393,397 **** this.callAfterTransactionCompletionFromDisconnect = info.GetBoolean("callAfterTransactionCompletionFromDisconnect"); this.entitiesByKey = (IDictionary)info.GetValue( "entitiesByKey", typeof(IDictionary) ); ! this.proxiesByKey = (IDictionary)info.GetValue( "proxiesByKey", typeof(IDictionary) ); this.nullifiables = (IDictionary)info.GetValue( "nullifiables", typeof(IDictionary) ); this.interceptor = (IInterceptor)info.GetValue( "interceptor", typeof(IInterceptor) ); --- 403,413 ---- this.callAfterTransactionCompletionFromDisconnect = info.GetBoolean("callAfterTransactionCompletionFromDisconnect"); this.entitiesByKey = (IDictionary)info.GetValue( "entitiesByKey", typeof(IDictionary) ); ! ! // we did not actually serializing the IDictionary but instead the proxies in an arraylist ! // because of deserailization issues I couldn't figure out. ! //this.proxiesByKey = (IDictionary)info.GetValue( "proxiesByKey", typeof(IDictionary) ); ! tmpProxiesKey = (ArrayList)info.GetValue( "tmpProxiesKey", typeof(ArrayList) ); ! tmpProxiesProxy = (ArrayList)info.GetValue( "tmpProxiesProxy", typeof(ArrayList) ); ! this.nullifiables = (IDictionary)info.GetValue( "nullifiables", typeof(IDictionary) ); this.interceptor = (IInterceptor)info.GetValue( "interceptor", typeof(IInterceptor) ); *************** *** 415,424 **** void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { ! if ( IsConnected ) throw new InvalidOperationException("Cannot serialize a Session while connected"); ! if ( insertions.Count!=0 || deletions.Count!=0 ) throw new InvalidOperationException("Cannot serialize a Session which has work waiting to be flushed"); - log.Info("serializing session"); - info.AddValue( "factory", factory, typeof(SessionFactoryImpl) ); info.AddValue( "autoClose", autoClose ); --- 431,446 ---- void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { ! log.Info( "writting session to serializer" ); ! ! if ( IsConnected ) ! { ! throw new InvalidOperationException("Cannot serialize a Session while connected"); ! } ! ! if ( insertions.Count!=0 || deletions.Count!=0 ) ! { throw new InvalidOperationException("Cannot serialize a Session which has work waiting to be flushed"); + } info.AddValue( "factory", factory, typeof(SessionFactoryImpl) ); info.AddValue( "autoClose", autoClose ); *************** *** 428,432 **** info.AddValue( "callAfterTransactionCompletionFromDisconnect", callAfterTransactionCompletionFromDisconnect ); info.AddValue( "entitiesByKey", entitiesByKey, typeof(IDictionary) ); ! info.AddValue( "proxiesByKey", proxiesByKey, typeof(IDictionary) ); info.AddValue( "nullifiables", nullifiables, typeof(IDictionary) ); info.AddValue( "interceptor", interceptor, typeof(IInterceptor) ); --- 450,470 ---- info.AddValue( "callAfterTransactionCompletionFromDisconnect", callAfterTransactionCompletionFromDisconnect ); info.AddValue( "entitiesByKey", entitiesByKey, typeof(IDictionary) ); ! ! // the IDictionary should not be serialized because the objects inside of it are not ! // fully deserialized until after the session is deserialized. Instead use two ArrayList ! // to hold the values because they don't have the deserialization complexities that ! // hashtables do. ! //info.AddValue( "proxiesByKey", proxiesByKey, typeof(IDictionary) ); ! tmpProxiesKey = new ArrayList( proxiesByKey.Count ); ! tmpProxiesProxy = new ArrayList( proxiesByKey.Count ); ! foreach(DictionaryEntry de in proxiesByKey) ! { ! tmpProxiesKey.Add( de.Key ); ! tmpProxiesProxy.Add( de.Value ); ! } ! ! info.AddValue( "tmpProxiesKey", tmpProxiesKey ); ! info.AddValue( "tmpProxiesProxy", tmpProxiesProxy ); ! info.AddValue( "nullifiables", nullifiables, typeof(IDictionary) ); info.AddValue( "interceptor", interceptor, typeof(IInterceptor) ); *************** *** 448,452 **** void IDeserializationCallback.OnDeserialization(Object sender) { ! log.Info("deserializing session"); // don't need any section for IdentityMaps because .net does not have a problem --- 486,490 ---- void IDeserializationCallback.OnDeserialization(Object sender) { ! log.Info("OnDeserialization of the session."); // don't need any section for IdentityMaps because .net does not have a problem *************** *** 469,476 **** } ! // TODO: figure out why proxies are having problems. The enumerator appears to be throwing ! // a null reference exception when the proxiesByKey.Count==0 ! foreach(object proxy in proxiesByKey.Values) { if (proxy is INHibernateProxy) { --- 507,527 ---- } ! ! // recreate the proxiesByKey hashtable from the two arraylists. ! proxiesByKey = new Hashtable( tmpProxiesKey.Count ); ! for(int i=0; i<tmpProxiesKey.Count; i++) { + proxiesByKey.Add( tmpProxiesKey[i], tmpProxiesProxy[i] ); + } + + // we can't remove an entry from an IDictionary while enumerating so store the ones + // to remove in this list + ArrayList keysToRemove = new ArrayList(); + + foreach( DictionaryEntry de in proxiesByKey ) + { + object key = de.Key; + object proxy = de.Value; + if (proxy is INHibernateProxy) { *************** *** 479,487 **** else { ! // the proxy was pruned during the serialization process ! proxiesByKey.Remove(proxy); } } foreach(EntityEntry e in entries.Values) { --- 530,545 ---- else { ! // the proxy was pruned during the serialization process because ! // the target had been instantiated. ! keysToRemove.Add( key ); } } + for( int i=0; i<keysToRemove.Count; i++ ) + { + proxiesByKey.Remove( keysToRemove[i] ); + } + + foreach(EntityEntry e in entries.Values) { |
From: Michael D. <mik...@us...> - 2004-10-03 16:59:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7021 Modified Files: Tag: alpha_avalon-proxy NHibernate-1.1.csproj Log Message: serialization of proxies is now working. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.48.2.1 retrieving revision 1.48.2.2 diff -C2 -d -r1.48.2.1 -r1.48.2.2 *** NHibernate-1.1.csproj 27 Sep 2004 03:41:44 -0000 1.48.2.1 --- NHibernate-1.1.csproj 3 Oct 2004 16:58:14 -0000 1.48.2.2 *************** *** 1374,1377 **** --- 1374,1382 ---- /> <File + RelPath = "Proxy\AvalonProxyDeserializer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Proxy\AvalonProxyGenerator.cs" SubType = "Code" *************** *** 1404,1412 **** /> <File - RelPath = "Proxy\SerializableProxy.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "SqlCommand\Alias.cs" SubType = "Code" --- 1409,1412 ---- |
From: Michael D. <mik...@us...> - 2004-09-30 21:01:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21895/NHibernate/Impl Modified Files: BatcherImpl.cs Log Message: Fixed up logging of open commands and readers. Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BatcherImpl.cs 30 Sep 2004 18:24:22 -0000 1.8 --- BatcherImpl.cs 30 Sep 2004 21:00:59 -0000 1.9 *************** *** 240,244 **** // turning around and calling a diff method. CloseQueryCommand( cmd, reader ); ! LogClosePreparedCommands(); } --- 240,246 ---- // turning around and calling a diff method. CloseQueryCommand( cmd, reader ); ! // CloseQueryCommand contains the logging so we don't need to call it ! // here - putting it in CloseQueryCommand(IDbCommand) will ensure it always gets called. ! //LogClosePreparedCommands(); } *************** *** 287,291 **** } ! // CloseCommand( cmd, null ); } --- 289,293 ---- } ! LogClosePreparedCommands(); } *************** *** 345,361 **** private static void LogOpenPreparedCommands() { ! if ( log.IsDebugEnabled ) { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } - openCommandCount++; } private static void LogClosePreparedCommands() { ! openCommandCount--; ! ! if ( log.IsDebugEnabled ) { log.Debug( "done closing: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } --- 347,362 ---- private static void LogOpenPreparedCommands() { ! if( log.IsDebugEnabled ) { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); + openCommandCount++; } } private static void LogClosePreparedCommands() { ! if( log.IsDebugEnabled ) { + openCommandCount--; log.Debug( "done closing: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); } *************** *** 364,373 **** private static void LogOpenReaders() { ! openReaderCount++; } private static void LogCloseReaders() { ! openReaderCount--; } --- 365,380 ---- private static void LogOpenReaders() { ! if( log.IsDebugEnabled ) ! { ! openReaderCount++; ! } } private static void LogCloseReaders() { ! if( log.IsDebugEnabled ) ! { ! openReaderCount--; ! } } |
From: Peter S. <sz...@us...> - 2004-09-30 18:24:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24026 Modified Files: BatcherImpl.cs Log Message: Fixed a log line Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BatcherImpl.cs 15 Sep 2004 13:18:32 -0000 1.7 --- BatcherImpl.cs 30 Sep 2004 18:24:22 -0000 1.8 *************** *** 240,244 **** // turning around and calling a diff method. CloseQueryCommand( cmd, reader ); ! //LogClosePreparedCommands(); } --- 240,244 ---- // turning around and calling a diff method. CloseQueryCommand( cmd, reader ); ! LogClosePreparedCommands(); } |
From: Michael D. <mik...@us...> - 2004-09-28 02:42:55
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14004 Modified Files: NHibernate-1.1.csproj Removed Files: IPersistentEnum.cs Log Message: removed IPersistentEnum - not in use anywhere. --- IPersistentEnum.cs DELETED --- Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** NHibernate-1.1.csproj 22 Sep 2004 22:32:49 -0000 1.48 --- NHibernate-1.1.csproj 28 Sep 2004 02:42:43 -0000 1.49 *************** *** 170,178 **** /> <File - RelPath = "IPersistentEnum.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "IQuery.cs" SubType = "Code" --- 170,173 ---- |
From: Michael D. <mik...@us...> - 2004-09-28 01:10:30
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101 Modified Files: NHibernate.Test-1.1.csproj NHibernate.Test.build Log Message: Added more ways to Configure NH-127 - added hibernate.cfg.xml as an embedded resource. Index: NHibernate.Test.build =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test.build,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NHibernate.Test.build 10 Aug 2004 16:40:15 -0000 1.7 --- NHibernate.Test.build 28 Sep 2004 01:10:16 -0000 1.8 *************** *** 58,61 **** --- 58,65 ---- </references> + <resources prefix="NHibernate.Test" dynamicprefix="true"> + <includes name="hibernate.cfg.xml" /> + </resources> + <sources> <includes name="**/*.cs" /> Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** NHibernate.Test-1.1.csproj 27 Sep 2004 01:49:45 -0000 1.43 --- NHibernate.Test-1.1.csproj 28 Sep 2004 01:10:16 -0000 1.44 *************** *** 156,160 **** <File RelPath = "hibernate.cfg.xml" ! BuildAction = "Content" /> <File --- 156,160 ---- <File RelPath = "hibernate.cfg.xml" ! BuildAction = "EmbeddedResource" /> <File |
From: Michael D. <mik...@us...> - 2004-09-28 01:09:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CfgTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28822 Modified Files: ConfigurationFixture.cs Log Message: Added more ways to Configure NH-127 Index: ConfigurationFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ConfigurationFixture.cs 27 Aug 2004 04:21:22 -0000 1.7 --- ConfigurationFixture.cs 28 Sep 2004 01:09:18 -0000 1.8 *************** *** 24,28 **** public void ReadCfgXmlFromDefaultFile() { - Configuration cfg = new Configuration(); cfg.Configure(); --- 24,27 ---- *************** *** 61,64 **** --- 60,78 ---- } + /// <summary> + /// Verify that NHibernate can read the configuration from a manifest resource in an + /// Assembly and that the values override what is in the app.config. + /// </summary> + [Test] + public void ReadCfgXmlFromAssembly() + { + Configuration cfg = new Configuration(); + cfg.Configure( this.GetType().Assembly, "NHibernate.Test.hibernate.cfg.xml" ); + + Assert.AreEqual( "true 1, false 0, yes 'Y', no 'N'", cfg.Properties[Cfg.Environment.QuerySubstitutions]); + Assert.AreEqual( "Server=localhost;initial catalog=nhibernate;User Id=;Password=", cfg.Properties[Cfg.Environment.ConnectionString]); + } + + } } |
From: Michael D. <mik...@us...> - 2004-09-28 01:08:51
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28688 Modified Files: Configuration.cs Log Message: Added more ways to Configure NH-127 Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Configuration.cs 9 Aug 2004 03:14:08 -0000 1.20 --- Configuration.cs 28 Sep 2004 01:08:40 -0000 1.21 *************** *** 679,684 **** public Configuration Configure() { ! Configure("hibernate.cfg.xml"); ! return this; } --- 679,683 ---- public Configuration Configure() { ! return Configure("hibernate.cfg.xml"); } *************** *** 693,704 **** public Configuration Configure(string resource) { XmlDocument doc = new XmlDocument(); XmlValidatingReader validatingReader = null; ! XmlTextReader reader = null; ! try { - reader = new XmlTextReader(resource); validatingReader = new XmlValidatingReader( reader ); validatingReader.ValidationType = ValidationType.Schema; --- 692,746 ---- public Configuration Configure(string resource) { + XmlTextReader reader = new XmlTextReader( resource ); + return Configure( reader ); + } + + /// <summary> + /// Configure NHibernate using a resource contained in an Assembly. + /// </summary> + /// <param name="assembly">The <see cref="Assembly"/> that contains the resource.</param> + /// <param name="resourceName">The name of the manifest resource being requested.</param> + /// <returns>A Configuration object initialized from the manifest resource.</returns> + /// <remarks> + /// Calling Configure(Assembly, string) will overwrite the values set in app.config or web.config + /// </remarks> + public Configuration Configure(Assembly assembly, string resourceName) + { + if( assembly==null || resourceName==null ) + { + throw new HibernateException( "Could not configure NHibernate.", new ArgumentException( "A null value was passed in.", "assembly or resourceName" ) ); + } + + Stream stream = assembly.GetManifestResourceStream( resourceName ); + if (stream==null) + { + // resource does not exist - throw appropriate exception + throw new HibernateException( "A ManifestResourceStream could not be created for the resource " + resourceName + " in Assembly " + assembly.FullName ); + } + + return Configure( new XmlTextReader( stream ) ); + } + + /// <summary> + /// Configure NHibernate using the specified XmlTextReader. + /// </summary> + /// <param name="reader">The <see cref="XmlTextReader"/> that contains the Xml to configure NHibernate.</param> + /// <returns>A Configuration object initialized with the file.</returns> + /// <remarks> + /// Calling Configure(XmlTextReader) will overwrite the values set in app.config or web.config + /// </remarks> + public Configuration Configure(XmlTextReader reader) + { + if( reader==null ) + { + throw new HibernateException( "Could not configure NHibernate.", new ArgumentException( "A null value was passed in.", "reader" ) ); + } + XmlDocument doc = new XmlDocument(); XmlValidatingReader validatingReader = null; ! try { validatingReader = new XmlValidatingReader( reader ); validatingReader.ValidationType = ValidationType.Schema; *************** *** 715,720 **** catch (Exception e) { ! log.Error("Problem parsing configuraiton " + resource, e); ! throw new HibernateException("problem parsing configuration " + resource + ": " + e); } --- 757,762 ---- catch (Exception e) { ! log.Error("Problem parsing configuration", e); ! throw new HibernateException("problem parsing configuration : " + e); } *************** *** 726,730 **** foreach(XmlNode mapElement in sfNode.ChildNodes) { - //string elemname = mapElement.Name; string elemname = mapElement.LocalName; if ( "mapping".Equals(elemname) ) --- 768,771 ---- |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:26
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate.DomainModel Modified Files: Tag: alpha_avalon-proxy FooBar.hbm.xml Glarch.hbm.xml NHibernate.DomainModel-1.1.csproj Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/FooBar.hbm.xml,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** FooBar.hbm.xml 1 Sep 2004 00:10:11 -0000 1.17 --- FooBar.hbm.xml 27 Sep 2004 03:41:45 -0000 1.17.2.1 *************** *** 11,20 **** dynamic-update="true" dynamic-insert="true" > - <!-- - proxy doesn't work yet - proxy="NHibernate.DomainModel.FooProxy, NHibernate.DomainModel" - --> - <jcs-cache usage="nonstrict-read-write"/> --- 11,16 ---- dynamic-update="true" dynamic-insert="true" + proxy="NHibernate.DomainModel.FooProxy, NHibernate.DomainModel" > <jcs-cache usage="nonstrict-read-write"/> *************** *** 155,171 **** name="NHibernate.DomainModel.Trivial, NHibernate.DomainModel" discriminator-value="T" /> ! <!-- ! proxy doesn't work yet ! proxy="NHibernate.DomainModel.FooProxy, NHibernate.DomainModel" ! --> ! <subclass name="NHibernate.DomainModel.Abstract, NHibernate.DomainModel" discriminator-value="null" > ! <!-- ! proxy doesn't work yet ! proxy="NHibernate.DomainModel.AbstractProxy, NHibernate.DomainModel" ! --> <set name="Abstracts"> <key column="abstract_id"/> --- 151,162 ---- name="NHibernate.DomainModel.Trivial, NHibernate.DomainModel" discriminator-value="T" + proxy="NHibernate.DomainModel.FooProxy, NHibernate.DomainModel" /> ! <subclass name="NHibernate.DomainModel.Abstract, NHibernate.DomainModel" discriminator-value="null" + proxy="NHibernate.DomainModel.AbstractProxy, NHibernate.DomainModel" > ! <set name="Abstracts"> <key column="abstract_id"/> *************** *** 173,184 **** </set> <property name="Time" column="the_time"/> <subclass name="NHibernate.DomainModel.Bar, NHibernate.DomainModel" discriminator-value="B" > - <!-- - proxy doesn't work yet - proxy="NHibernate.DomainModel.BarProxy, NHibernate.DomainModel" - --> <many-to-one name="Baz"/> <property name="BarString"> --- 164,173 ---- </set> <property name="Time" column="the_time"/> + <subclass name="NHibernate.DomainModel.Bar, NHibernate.DomainModel" discriminator-value="B" + proxy="NHibernate.DomainModel.BarProxy, NHibernate.DomainModel" > <many-to-one name="Baz"/> <property name="BarString"> Index: NHibernate.DomainModel-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHibernate.DomainModel-1.1.csproj,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -C2 -d -r1.24 -r1.24.2.1 *** NHibernate.DomainModel-1.1.csproj 1 Sep 2004 00:10:11 -0000 1.24 --- NHibernate.DomainModel-1.1.csproj 27 Sep 2004 03:41:45 -0000 1.24.2.1 *************** *** 613,616 **** --- 613,630 ---- /> <File + RelPath = "NHSpecific\AvalonProxy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecific\AvalonProxyImpl.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "NHSpecific\AvalonProxyImpl.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File RelPath = "NHSpecific\BasicBinary.cs" SubType = "Code" Index: Glarch.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Glarch.hbm.xml,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -C2 -d -r1.9 -r1.9.2.1 *** Glarch.hbm.xml 31 Aug 2004 21:22:58 -0000 1.9 --- Glarch.hbm.xml 27 Sep 2004 03:41:45 -0000 1.9.2.1 *************** *** 5,14 **** table="`glarchez`" dynamic-update="true" > - <!-- - proxy doesn't work yet - proxy="NHibernate.DomainModel.GlarchProxy, NHibernate.DomainModel" - --> - <!-- <jcs-cache usage="read-write" /> --> <!-- commented out in h2.0.3 also --> --- 5,10 ---- table="`glarchez`" dynamic-update="true" + proxy="NHibernate.DomainModel.GlarchProxy, NHibernate.DomainModel" > <!-- <jcs-cache usage="read-write" /> --> <!-- commented out in h2.0.3 also --> |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate Modified Files: Tag: alpha_avalon-proxy NHibernate-1.1.csproj NHibernate.build NHibernate.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -C2 -d -r1.48 -r1.48.2.1 *** NHibernate-1.1.csproj 22 Sep 2004 22:32:49 -0000 1.48 --- NHibernate-1.1.csproj 27 Sep 2004 03:41:44 -0000 1.48.2.1 *************** *** 100,103 **** --- 100,108 ---- HintPath = "..\..\external-bin\HashCodeProvider.dll" /> + <Reference + Name = "Apache.Avalon.DynamicProxy" + AssemblyName = "Apache.Avalon.DynamicProxy" + HintPath = "..\..\external-bin\Apache.Avalon.DynamicProxy.dll" + /> </References> </Build> *************** *** 1364,1373 **** /> <File ! RelPath = "Proxy\HibernateProxy.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Proxy\HibernateProxyHelper.cs" SubType = "Code" BuildAction = "Compile" --- 1369,1388 ---- /> <File ! RelPath = "Proxy\AvalonLazyInitializer.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Proxy\AvalonProxyGenerator.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Proxy\INHibernateProxy.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Proxy\IProxyGenerator.cs" SubType = "Code" BuildAction = "Compile" *************** *** 1379,1382 **** --- 1394,1412 ---- /> <File + RelPath = "Proxy\NHibernateProxyHelper.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Proxy\ProxyGeneratorFactory.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Proxy\SerializableProxy.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "SqlCommand\Alias.cs" SubType = "Code" Index: NHibernate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate.cs,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -C2 -d -r1.22 -r1.22.2.1 *** NHibernate.cs 25 Aug 2004 03:59:07 -0000 1.22 --- NHibernate.cs 27 Sep 2004 03:41:45 -0000 1.22.2.1 *************** *** 249,255 **** return; } ! else if ( proxy is HibernateProxy ) { ! HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) proxy ).Initialize(); } else if ( proxy is PersistentCollection ) --- 249,255 ---- return; } ! else if ( proxy is INHibernateProxy ) { ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).Initialize(); } else if ( proxy is PersistentCollection ) *************** *** 266,272 **** public static bool IsInitialized(object proxy) { ! if ( proxy is HibernateProxy ) { ! return !HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) proxy ).IsUninitialized; } else if ( proxy is PersistentCollection ) --- 266,272 ---- public static bool IsInitialized(object proxy) { ! if ( proxy is INHibernateProxy ) { ! return !NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).IsUninitialized; } else if ( proxy is PersistentCollection ) *************** *** 288,294 **** public System.Type GetClass(object proxy) { ! if(proxy is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) proxy ).GetImplementation().GetType(); } else --- 288,294 ---- public System.Type GetClass(object proxy) { ! if(proxy is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).GetImplementation().GetType(); } else Index: NHibernate.build =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate.build,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** NHibernate.build 13 Sep 2004 23:15:29 -0000 1.1 --- NHibernate.build 27 Sep 2004 03:41:45 -0000 1.1.2.1 *************** *** 74,77 **** --- 74,78 ---- <includes name="System.XML.dll" /> <includes name="System.Data.dll" /> + <includes name="Apache.Avalon.DynamicProxy.dll" /> <includes name="log4net.dll" /> <includes name="HashCodeProvider.dll" /> |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate/Persister Modified Files: Tag: alpha_avalon-proxy AbstractEntityPersister.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: AbstractEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractEntityPersister.cs,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -C2 -d -r1.26 -r1.26.2.1 *** AbstractEntityPersister.cs 21 Sep 2004 09:58:24 -0000 1.26 --- AbstractEntityPersister.cs 27 Sep 2004 03:42:02 -0000 1.26.2.1 *************** *** 650,672 **** // PROXIES System.Type pi = model.ProxyInterface; ! hasProxy = pi!=null; ArrayList pis = new ArrayList(); ! pis.Add(typeof(HibernateProxy)); ! //pis.Add( typeof(INHibernateProxy) ); ! // != null because we use arraylist instead of hashset ! // mono does not like a null value passed into Equals() ! if ( pi!=null && !mappedClass.Equals(pi) ) { ! pis.Add(pi); } concreteProxyClass = pi; ! if (hasProxy) { ! foreach(Subclass sc in model.SubclassCollection) { pi = sc.ProxyInterface; ! if (pi==null) throw new MappingException( "All subclasses must also have proxies: " + mappedClass.Name); ! if ( !sc.PersistentClazz.Equals(pi) ) pis.Add(pi); } } --- 650,686 ---- // PROXIES System.Type pi = model.ProxyInterface; ! hasProxy = ( pi!=null ); ArrayList pis = new ArrayList(); ! pis.Add( typeof(INHibernateProxy) ); ! ! // mono does not like a null value passed into Equals() so check ! // that first ! if( pi!=null && !mappedClass.Equals(pi) ) { ! // if the <class> name="type" is not the same type as the proxy="type" ! // then add the proxy's type to the list. They will ! // be different types when the <class> is a class and the proxy is ! // an interface, or when a <class> is an interface and the proxy interface ! // is diff (why would you do that??). They will be the same type ! // when the <class> is an interface and the proxy interface is the same ! // interface. ! pis.Add( pi ); } + concreteProxyClass = pi; ! if( hasProxy ) { ! foreach( Subclass sc in model.SubclassCollection ) { pi = sc.ProxyInterface; ! if( pi==null ) ! { ! throw new MappingException( "All subclasses must also have proxies: " + mappedClass.Name); ! } ! if( !sc.PersistentClazz.Equals(pi) ) ! { ! pis.Add(pi); ! } } } |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate.Test Modified Files: Tag: alpha_avalon-proxy FooBarTest.cs NHibernate.Test-1.1.csproj Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.67 retrieving revision 1.67.2.1 diff -C2 -d -r1.67 -r1.67.2.1 *** FooBarTest.cs 20 Sep 2004 02:27:01 -0000 1.67 --- FooBarTest.cs 27 Sep 2004 03:41:45 -0000 1.67.2.1 *************** *** 1474,1478 **** [Test] ! [Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void Load() { --- 1474,1478 ---- [Test] ! //[Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void Load() { *************** *** 1882,1885 **** --- 1882,1887 ---- ISession sOld = sessions.OpenSession(); GlarchProxy gOld = (GlarchProxy)sOld.Load( typeof(Glarch), gid ); + // unproxy gOld + gOld = (GlarchProxy)Proxy.NHibernateProxyHelper.GetLazyInitializer( (Proxy.INHibernateProxy)gOld ).GetImplementation(); sOld.Close(); *************** *** 1901,1904 **** --- 1903,1907 ---- bool isStale = false; sOld = sessions.OpenSession(); + gOld.Name = "should not update"; try Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.43 retrieving revision 1.43.2.1 diff -C2 -d -r1.43 -r1.43.2.1 *** NHibernate.Test-1.1.csproj 27 Sep 2004 01:49:45 -0000 1.43 --- NHibernate.Test-1.1.csproj 27 Sep 2004 03:42:02 -0000 1.43.2.1 *************** *** 302,305 **** --- 302,310 ---- /> <File + RelPath = "NHSpecificTest\AvalonProxyFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NHSpecificTest\BasicBinaryFixture.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate.Test/NHSpecificTest Added Files: Tag: alpha_avalon-proxy AvalonProxyFixture.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. --- NEW FILE: AvalonProxyFixture.cs --- using System; using NHibernate.DomainModel.NHSpecific; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest { /// <summary> /// Summary description for AvalonProxyFixture. /// </summary> [TestFixture] public class AvalonProxyFixture : TestCase { [SetUp] public void SetUp() { ExportSchema( new string[] { "NHSpecific.AvalonProxyImpl.hbm.xml"}, true ); } [Test] public void Proxy() { ISession s = sessions.OpenSession(); AvalonProxy ap = new AvalonProxyImpl(); ap.Id = 1; ap.Name = "first proxy"; s.Save( ap ); s.Flush(); s.Close(); s = sessions.OpenSession(); ap = (AvalonProxy)s.Load( typeof(AvalonProxyImpl), ap.Id ); Assert.IsFalse( NHibernate.IsInitialized( ap ) ); int id = ap.Id; Assert.IsFalse( NHibernate.IsInitialized( ap ), "get id should not have initialized it." ); string name = ap.Name; Assert.IsTrue( NHibernate.IsInitialized( ap ), "get name should have initialized it." ); s.Delete( ap ); s.Flush(); s.Close(); } } } |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate/Impl Modified Files: Tag: alpha_avalon-proxy QueryImpl.cs SessionImpl.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.44 retrieving revision 1.44.2.1 diff -C2 -d -r1.44 -r1.44.2.1 *** SessionImpl.cs 23 Sep 2004 13:08:59 -0000 1.44 --- SessionImpl.cs 27 Sep 2004 03:42:02 -0000 1.44.2.1 *************** *** 436,439 **** --- 436,440 ---- info.AddValue( "arrayHolders", arrayHolders, typeof(IdentityMap) ); } + #endregion *************** *** 470,486 **** // TODO: figure out why proxies are having problems. The enumerator appears to be throwing // a null reference exception when the proxiesByKey.Count==0 ! // foreach(object proxy in proxiesByKey.Values) ! // { ! // object proxy = proxyEnumer.Current; ! // if (proxy is HibernateProxy) ! // { ! // HibernateProxyHelper.GetLazyInitializer(proxy as HibernateProxy).SetSession(this); ! // } ! // else ! // { ! // // the proxy was pruned during the serialization process ! // proxiesByKey.Remove(proxy); ! // } ! // } foreach(EntityEntry e in entries.Values) --- 471,486 ---- // TODO: figure out why proxies are having problems. The enumerator appears to be throwing // a null reference exception when the proxiesByKey.Count==0 ! foreach(object proxy in proxiesByKey.Values) ! { ! if (proxy is INHibernateProxy) ! { ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy)proxy ).Session = this; ! } ! else ! { ! // the proxy was pruned during the serialization process ! proxiesByKey.Remove(proxy); ! } ! } foreach(EntityEntry e in entries.Values) *************** *** 611,617 **** public LockMode GetCurrentLockMode(object obj) { ! if ( obj is HibernateProxy ) { ! obj = (HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj)).GetImplementation(this); if (obj==null) return LockMode.None; } --- 611,617 ---- public LockMode GetCurrentLockMode(object obj) { ! if ( obj is INHibernateProxy ) { ! obj = (NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj)).GetImplementation(this); if (obj==null) return LockMode.None; } *************** *** 905,910 **** private void ReassociateProxy(Object value) { ! HibernateProxy proxy = (HibernateProxy) value; ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); } --- 905,910 ---- private void ReassociateProxy(Object value) { ! INHibernateProxy proxy = (INHibernateProxy) value; ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); } *************** *** 912,919 **** private object UnproxyAndReassociate(object maybeProxy) { ! if ( maybeProxy is HibernateProxy ) { ! HibernateProxy proxy = (HibernateProxy) maybeProxy; ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object --- 912,919 ---- private object UnproxyAndReassociate(object maybeProxy) { ! if ( maybeProxy is INHibernateProxy ) { ! INHibernateProxy proxy = (INHibernateProxy) maybeProxy; ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object *************** *** 930,934 **** /// <param name="li"></param> /// <param name="proxy"></param> ! private void ReassociateProxy(LazyInitializer li, HibernateProxy proxy) { if ( li.Session!=this ) --- 930,934 ---- /// <param name="li"></param> /// <param name="proxy"></param> ! private void ReassociateProxy(LazyInitializer li, INHibernateProxy proxy) { if ( li.Session!=this ) *************** *** 937,941 **** Key key = new Key( li.Identifier, persister ); if ( !proxiesByKey.Contains(key) ) proxiesByKey[key] = proxy; // any earlier proxy takes precedence ! HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) proxy ).SetSession(this); } } --- 937,941 ---- Key key = new Key( li.Identifier, persister ); if ( !proxiesByKey.Contains(key) ) proxiesByKey[key] = proxy; // any earlier proxy takes precedence ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).Session = this; } } *************** *** 1001,1008 **** private bool IsUnsaved(object obj, bool earlyInsert, object self) { ! if ( obj is HibernateProxy ) { // if its an uninitialized proxy, it can't be transietn ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); if ( li.GetImplementation(this)==null ) { --- 1001,1008 ---- private bool IsUnsaved(object obj, bool earlyInsert, object self) { ! if ( obj is INHibernateProxy ) { // if its an uninitialized proxy, it can't be transietn ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); if ( li.GetImplementation(this)==null ) { *************** *** 1470,1476 **** if (obj==null) throw new NullReferenceException("attempted to update null"); ! if ( obj is HibernateProxy ) { ! object pid = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; if( !id.Equals(pid) ) throw new HibernateException("The given proxy had a different identifier value to the given identifier: " + pid + "!=" + id); --- 1470,1476 ---- if (obj==null) throw new NullReferenceException("attempted to update null"); ! if ( obj is INHibernateProxy ) { ! object pid = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; if( !id.Equals(pid) ) throw new HibernateException("The given proxy had a different identifier value to the given identifier: " + pid + "!=" + id); *************** *** 1879,1885 **** public object ProxyFor(IClassPersister persister, Key key, object impl) { ! if ( !persister.HasProxy ) return impl; object proxy = proxiesByKey[key]; ! if (proxy!=null) { return NarrowProxy(proxy, persister, key, impl); --- 1879,1891 ---- public object ProxyFor(IClassPersister persister, Key key, object impl) { ! // added key==null because the java version of HashMap allows ! // a null key, but an IDictionary does not ! if( !persister.HasProxy || key==null ) ! { ! return impl; ! } ! object proxy = proxiesByKey[key]; ! if( proxy!=null ) { return NarrowProxy(proxy, persister, key, impl); *************** *** 2058,2067 **** if ( persister.HasProxy ) { ! proxy = null; //TODO: Create the proxy ! // this is the spot that is causing the problems with FooBarTest.FetchInitializedCollection ! // when the following code "Assert.IsTrue( baz.fooBag.Count==2 );" is being executed. This ! // is causing a null value to be returned when a "Proxied" version of the class is expected. ! // So the method ThrowObjectNotFound is throwing an exception because it is given a null object ! // - hence the error looks like it can't find a row in the DB. } proxiesByKey[key] = proxy; --- 2064,2069 ---- if ( persister.HasProxy ) { ! IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); ! proxy = generator.GetProxy( clazz, persister.ProxyInterfaces, persister.ProxyIdentifierProperty, id, this ); } proxiesByKey[key] = proxy; *************** *** 2685,2691 **** public object GetIdentifier(object obj) { ! if (obj is HibernateProxy) { ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); if ( li.Session!=this ) throw new TransientObjectException("The proxy was not associated with this session"); return li.Identifier; --- 2687,2693 ---- public object GetIdentifier(object obj) { ! if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); if ( li.Session!=this ) throw new TransientObjectException("The proxy was not associated with this session"); return li.Identifier; *************** *** 2707,2713 **** public object GetEntityIdentifier(object obj) { ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; } else --- 2709,2715 ---- public object GetEntityIdentifier(object obj) { ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; } else *************** *** 2720,2724 **** public bool IsSaved(object obj) { ! if(obj is HibernateProxy) return true; EntityEntry entry = GetEntry(obj); --- 2722,2726 ---- public bool IsSaved(object obj) { ! if(obj is INHibernateProxy) return true; EntityEntry entry = GetEntry(obj); *************** *** 2748,2754 **** if (obj==null) return null; ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; } else --- 2750,2756 ---- if (obj==null) return null; ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; } else *************** *** 3802,3808 **** public bool Contains(object obj) { ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Session==this; } else --- 3804,3810 ---- public bool Contains(object obj) { ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Session==this; } else *************** *** 3819,3825 **** public void Evict(object obj) { ! if (obj is HibernateProxy) { ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); --- 3821,3827 ---- public void Evict(object obj) { ! if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); Index: QueryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/QueryImpl.cs,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** QueryImpl.cs 22 Aug 2004 06:25:06 -0000 1.14 --- QueryImpl.cs 27 Sep 2004 03:42:02 -0000 1.14.2.1 *************** *** 152,156 **** } public IQuery SetEntity(int position, object val) { ! SetParameter(position, val, NHibernate.Entity( HibernateProxyHelper.GetClass(val))); return this; } --- 152,156 ---- } public IQuery SetEntity(int position, object val) { ! SetParameter(position, val, NHibernate.Entity( NHibernateProxyHelper.GetClass(val))); return this; } *************** *** 224,228 **** } public IQuery SetEntity(string name, object val) { ! SetParameter(name, val, NHibernate.Entity( HibernateProxyHelper.GetClass( val ) ) ); return this; } --- 224,228 ---- } public IQuery SetEntity(string name, object val) { ! SetParameter(name, val, NHibernate.Entity( NHibernateProxyHelper.GetClass( val ) ) ); return this; } *************** *** 243,247 **** private IType GuessType(object param) { ! System.Type clazz = HibernateProxyHelper.GetClass(param); return GuessType(clazz); } --- 243,247 ---- private IType GuessType(object param) { ! System.Type clazz = NHibernateProxyHelper.GetClass(param); return GuessType(clazz); } |
From: Michael D. <mik...@us...> - 2004-09-27 03:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate/Proxy Modified Files: Tag: alpha_avalon-proxy LazyInitializer.cs Added Files: Tag: alpha_avalon-proxy AvalonLazyInitializer.cs AvalonProxyGenerator.cs INHibernateProxy.cs IProxyGenerator.cs NHibernateProxyHelper.cs ProxyGeneratorFactory.cs SerializableProxy.cs Removed Files: Tag: alpha_avalon-proxy HibernateProxy.cs HibernateProxyHelper.cs IHibernateProxy.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. --- NEW FILE: SerializableProxy.cs --- using System; using System.Reflection; using System.Runtime.Serialization; namespace NHibernate.Proxy { /// <summary> /// Serializable "container" for a NHibernate Proxy. /// </summary> /// <remarks> /// <para> /// A NHibernate Proxy is not actually Serialized from Server to Client because /// it is a dynamically generated Type that does not exist in the Client AppDomain. /// </para> /// <para> /// This Class holds all of the information needed to rebuild the NHibernate Proxy /// during Deserialization. /// </para> /// </remarks> [Serializable] public class SerializableProxy : IObjectReference { private System.Type _persistentClass; private System.Type[] _interfaces; private object _id; private PropertyInfo _identifierPropertyInfo; /// <summary> /// Construct a container that can recreate the Proxy after Serialization. /// </summary> /// <param name="persistentClass">The PersistentClass to rebuild the Proxy for.</param> /// <param name="interfaces">The Interfaces for the Proxy.</param> /// <param name="id">The value of the id for the Proxy.</param> /// <param name="identifierPropertyInfo">The Identifier Property.</param> public SerializableProxy(System.Type persistentClass, System.Type[] interfaces, object id, PropertyInfo identifierPropertyInfo) { _persistentClass = persistentClass; _interfaces = interfaces; _id = id; _identifierPropertyInfo = identifierPropertyInfo; // don't need to do anything fancy here - in java a java.lang.reflect.Method is not serializable // so it had to be converted into a Class and Method Name to rebuild the Method object, but in // .NET the PropertyInfo is marked as serializable... } #region IObjectReference Members /// <summary> /// Converts a Serializable Proxy into the dynamically generated Proxy on the Client side. /// </summary> /// <param name="context"></param> /// <returns></returns> /// <remarks> /// This is called after the Deserialization ctor of this Class has been called. /// </remarks> public object GetRealObject(StreamingContext context) { IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); object proxy = generator.GetProxy(_persistentClass, _interfaces, _identifierPropertyInfo, _id, null); return proxy; } #endregion } } --- HibernateProxyHelper.cs DELETED --- --- NEW FILE: NHibernateProxyHelper.cs --- using System; namespace NHibernate.Proxy { /// <summary> /// NHibernateProxyHelper provides convenience methods for working with /// objects that might be instances of Classes or the Proxied version of /// the Class. /// </summary> public sealed class NHibernateProxyHelper { private NHibernateProxyHelper() { //can't instantiate } /// <summary> /// Gets the NLazyInitializer that is used by the Proxy. /// </summary> /// <param name="proxy">The Proxy object</param> /// <returns>A reference to NLazyInitializer that contains the details of the Proxied object.</returns> public static LazyInitializer GetLazyInitializer(INHibernateProxy proxy) { // have to hard code in "handler" - very dependant on them not changing their // implementation - email Hammet about this - or atleast to provide a static // field object fieldValue = proxy.GetType().GetField( "handler" ).GetValue(proxy); return (LazyInitializer)fieldValue; } /// <summary> /// Convenience method to figure out the underlying type for the object regardless of it /// is a Proxied object or the real object. /// </summary> /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> public static System.Type GetClass(object obj) { if (obj is INHibernateProxy) { INHibernateProxy proxy = (INHibernateProxy) obj; LazyInitializer li = GetLazyInitializer(proxy); return li.PersistentClass; } else { return obj.GetType(); } } } } --- NEW FILE: AvalonProxyGenerator.cs --- using System; using System.Collections; using System.Reflection; using Apache.Avalon.DynamicProxy; using NHibernate.Engine; namespace NHibernate.Proxy { /// <summary> /// An <see cref="IProxyGenerator"/> for the Apache.Avalon.DynamicProxy library. /// </summary> public class AvalonProxyGenerator : IProxyGenerator { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(AvalonProxyGenerator) ); private ProxyGenerator _generator = new ProxyGenerator(); /// <summary> /// Initializes a new instance of the <see cref="AvalonProxyGenerator"/> class. /// </summary> internal AvalonProxyGenerator() { } #region IProxyGenerator Methods /// <summary> /// Build a proxy using the Apache.Avalon.DynamicProxy library. /// </summary> /// <param name="persistentClass">.</param> /// <param name="interfaces">The extra interfaces the Proxy should implement.</param> /// <param name="identifierPropertyInfo">The PropertyInfo to get/set the Id.</param> /// <param name="id">The value for the Id.</param> /// <param name="session">The Session the proxy is in.</param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> public INHibernateProxy GetProxy(System.Type persistentClass, System.Type[] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session) { try { AvalonLazyInitializer initializer = new AvalonLazyInitializer( persistentClass, interfaces, id, identifierPropertyInfo, session ); // if the pc is an interface then we need to add the interface to the // interfaces array that was passed in because it only includes the extra // interfaces for that persistent class. if( persistentClass.IsInterface ) { System.Type[] temp = new System.Type[ interfaces.Length + 1 ]; interfaces.CopyTo( temp, 0 ); temp[ interfaces.Length ] = persistentClass; interfaces = temp; } object generatedProxy = _generator.CreateProxy( interfaces, initializer ); return (INHibernateProxy)generatedProxy; } catch(Exception e) { log.Error("Avalon Dynamic Class Generator failed", e); throw new HibernateException( "Avalon Dynamic Class Generator failed", e); } } #endregion } } --- IHibernateProxy.cs DELETED --- --- NEW FILE: IProxyGenerator.cs --- using System; using System.Reflection; using NHibernate.Engine; namespace NHibernate.Proxy { /// <summary> /// Summary description for IProxyGenerator. /// </summary> public interface IProxyGenerator { /// <summary> /// Build a proxy using the Apache.Avalon.DynamicProxy library. /// </summary> /// <param name="persistentClass">The PersistentClass to proxy.</param> /// <param name="interfaces">The extra interfaces the Proxy should implement.</param> /// <param name="identifierPropertyInfo">The PropertyInfo to get/set the Id.</param> /// <param name="id">The value for the Id.</param> /// <param name="session">The Session the proxy is in.</param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> INHibernateProxy GetProxy(System.Type persistentClass, System.Type[] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session); } } --- NEW FILE: INHibernateProxy.cs --- using System; using System.Runtime.Serialization; namespace NHibernate.Proxy { /// <summary> /// A marker interface so NHibernate can know if it is dealing with /// an object that is a Proxy. All NHibernate Proxies will be Serializable. /// This does not mean that all Mapped Classes have to be Serializable. /// </summary> /// <remarks> /// This interface should not be implemented by anything other than /// the Dynamically generated Proxy. It has to be public scope because /// the Proxies are created in a seperate DLL than NHibernate. /// </remarks> public interface INHibernateProxy : ISerializable { } } Index: LazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/LazyInitializer.cs,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** LazyInitializer.cs 22 Apr 2003 14:07:21 -0000 1.1 --- LazyInitializer.cs 27 Sep 2004 03:42:03 -0000 1.1.2.1 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Reflection; *************** *** 5,169 **** using NHibernate.Util; - using log4net; - namespace NHibernate.Proxy { /// <summary> ! /// Summary description for LazyInitializer. /// </summary> ! public abstract class LazyInitializer { ! protected static readonly object INVOKE_IMPLEMENTATION = new object(); ! protected object target = null; ! protected object id; ! protected ISessionImplementor session; ! protected System.Type persistentClass; ! protected MethodInfo getIdentifierMethod; ! protected bool overridesEquals; ! public LazyInitializer(System.Type persistentClass, object id, MethodInfo getIdentifierMethod, ISessionImplementor session) { ! this.id = id; ! this.session = session; ! this.persistentClass = persistentClass; ! this.getIdentifierMethod = getIdentifierMethod; ! overridesEquals = ReflectHelper.OverridesEquals(persistentClass); } ! ! public void Initialize() { ! if (target==null) { ! if ( session==null ) { ! throw new HibernateException("Could not initialize proxy - no Session"); } ! else if ( !session.IsOpen ) { ! throw new HibernateException("Could not initialize proxy - the owning Session was closed"); } ! else { ! target = session.ImmediateLoad(persistentClass, id); } } } ! private void InitializeWrapExceptions() { ! try { Initialize(); } ! catch (Exception e) { ! LogManager.GetLogger( typeof(LazyInitializer) ).Error("Exception initializing proxy", e); throw new LazyInitializationException(e); } } ! protected abstract object SerializableProxy(); ! protected object Invoke(MethodInfo method, object[] args) { ! ! string methodName = method.Name; ! int pars = method.GetParameters().Length; ! if ( pars==0 ) { ! if ( "WriteReplace".Equals(methodName) ) { ! if (target==null && session!=null ) target = session.GetEntity( ! new Key( id, session.Factory.GetPersister(persistentClass) ) ! ); ! if (target==null) { ! /*if ( session==null || !session.isOpen() ) { ! return session.getFactory().getPersister(persistentClass).instantiate(id); //A little "empty" object ! } ! else {*/ ! return SerializableProxy(); ! //} } ! else { ! return target; } - } ! else if ( !overridesEquals && getIdentifierMethod!=null && "GetHashCode".Equals(methodName) ) { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return id.GetHashCode(); } ! else if ( method.Equals(getIdentifierMethod) ) { ! return id; } ! else if ( "Finalize".Equals( methodName ) ) { ! return null; } - } ! else if ( pars==1 && !overridesEquals && getIdentifierMethod!=null && "Equals".Equals(methodName) ) { ! // less dodgy because Hibernate forces == to be same as identifier equals ! return (bool) id.Equals( getIdentifierMethod.Invoke( args[0], null ) ); } ! // otherwise: ! return INVOKE_IMPLEMENTATION; ! ! /*try { ! return method.invoke( getImplementation(), args ); } - catch (InvocationTargetException ite) { - throw ite.getTargetException(); - }*/ } ! public object Identifier { ! get { ! return id; } ! } ! ! public System.Type PersistentClass { ! get { ! return persistentClass; } ! } ! ! public bool IsUninitialized { ! get { ! return target == null; } ! } ! ! public ISessionImplementor Session { ! get { ! return session; } ! } ! ! public void SetSession(ISessionImplementor s) { ! if (s!=session) { ! if ( session!=null && session.IsOpen ) { ! //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); } ! else { ! session = s; } } } - /// <summary> - /// Return the underlying persistent object, initializing if necessary - /// </summary> - public object GetImplementation() { - InitializeWrapExceptions(); - return target; - } - - /// <summary> - /// Return the underlying persistent object in the given Session, or null - /// </summary> - /// <param name="s"></param> - /// <returns></returns> - public object GetImplementation(ISessionImplementor s) { - return s.GetEntity( new Key( - Identifier, - s.Factory.GetPersister( PersistentClass ) - ) ); - } } ! } \ No newline at end of file --- 6,297 ---- using NHibernate.Util; namespace NHibernate.Proxy { /// <summary> ! /// Provides the base functionallity to Handle Member calls into a dynamically ! /// generated NHibernate Proxy. /// </summary> ! /// <remarks> ! /// This could be an extension point later if the .net framework ever gets a Proxy ! /// class that is similar to the java.lang.reflect.Proxy or if a library similar ! /// to cglib was made in .net. ! /// </remarks> ! public abstract class LazyInitializer ! { ! /// <summary> ! /// If this is returned by Invoke then the subclass needs to Invoke the ! /// method call against the object that is being proxied. ! /// </summary> ! protected static readonly object InvokeImplementation = new object(); ! protected object _target = null; ! protected object _id; ! protected ISessionImplementor _session; ! protected System.Type _persistentClass; ! protected PropertyInfo _identifierPropertyInfo; ! protected bool _overridesEquals; ! private SerializableProxy _serializableProxy; ! ! /// <summary> ! /// Create a LazyInitializer to handle all of the Methods/Properties that are called ! /// on the Proxy. ! /// </summary> ! /// <param name="persistentClass">The Class to Proxy.</param> ! /// <param name="id">The Id of the Object we are Proxying.</param> ! /// <param name="identifierPropertyInfo">The PropertyInfo for the <id> property.</param> ! /// <param name="session">The ISession this Proxy is in.</param> ! protected LazyInitializer(System.Type persistentClass, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session) ! { ! _persistentClass = persistentClass; ! _id = id; ! _session = session; ! _identifierPropertyInfo = identifierPropertyInfo; ! _overridesEquals = ReflectHelper.OverridesEquals(_persistentClass); } ! ! /// <summary> ! /// Perform an ImmediateLoad of the actual object for the Proxy. ! /// </summary> ! /// <exception cref="HibernateException"> ! /// Thrown when the Proxy has no Session or the Session is not open. ! /// </exception> ! public void Initialize() ! { ! if( _target==null ) ! { ! if( _session==null ) ! { ! throw new HibernateException( "Could not initialize proxy - no Session." ); } ! else if( _session.IsOpen==false ) ! { ! throw new HibernateException( "Could not initialize proxy - the owning Session was closed." ); } ! else ! { ! _target = _session.ImmediateLoad( _persistentClass, _id ); } } } ! /// <summary> ! /// Initializes the Proxy. ! /// </summary> ! /// <remarks> ! /// If an Exception is thrown then it will be logged and wrapped into a ! /// <see cref="LazyInitializationException" />. ! /// </remarks> ! /// <exception cref="LazyInitializationException"> ! /// Thrown whenever a problem is encountered during the Initialization of the Proxy. ! /// </exception> ! private void InitializeWrapExceptions() ! { ! try ! { Initialize(); } ! catch( Exception e ) ! { ! log4net.LogManager.GetLogger(typeof(LazyInitializer)).Error("Exception initializing proxy.", e); throw new LazyInitializationException(e); } } ! /// <summary> ! /// Converts this Proxy into a Serializable Class that knows how to create a ! /// Proxy during the Deserialization process. ! /// </summary> ! /// <returns>SerializableProxy that can Deserialize this LazyInitializer.</returns> ! protected abstract SerializableProxy SerializableProxy() ; ! public object Identifier ! { ! get { return _id; } ! } ! public System.Type PersistentClass ! { ! get { return _persistentClass; } ! } ! public bool IsUninitialized ! { ! get { return (_target==null); } ! } ! public ISessionImplementor Session ! { ! get { return _session; } ! set ! { ! if(value!=_session) ! { ! if( _session!=null && _session.IsOpen ) ! { ! //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); } ! else ! { ! _session = value; } } ! } ! } ! ! /// <summary> ! /// Return the Underlying Persistent Object, initializing if necessary. ! /// </summary> ! /// <returns>The Persistent Object this proxy is Proxying.</returns> ! public object GetImplementation() ! { ! InitializeWrapExceptions(); ! return _target; ! } ! ! /// <summary> ! /// Return the Underlying Persistent Object in a given <see cref="ISession"/>, or null. ! /// </summary> ! /// <param name="s">The Session to get the object from.</param> ! /// <returns>The Persistent Object this proxy is Proxying, or <c>null</c>.</returns> ! public object GetImplementation(ISessionImplementor s) ! { ! Key key = new Key( Identifier, s.Factory.GetPersister(PersistentClass) ); ! return s.GetEntity(key); ! } ! ! /// <summary> ! /// Invokes the method if this is something that the LazyInitializer can handle ! /// without the underlying proxied object being instantiated. ! /// </summary> ! /// <param name="methodName">The name of the method/property to Invoke.</param> ! /// <param name="args">The arguments to pass the method/property.</param> ! /// <returns> ! /// The result of the Invoke if the underlying proxied object is not needed. If the ! /// underlying proxied object is needed then it returns the result <see cref="InvokeImplementation"/> ! /// which indicates that the Proxy will need to forward to the real implementation. ! /// </returns> ! public virtual object Invoke(MethodInfo method, params object[] args) ! { ! // all Proxies must implement INHibernateProxy which extends ISerializable ! if( method.Name.Equals("GetObjectData") ) ! { ! if( _target==null & _session!=null ) ! { ! Key key = new Key(_id, _session.Factory.GetPersister( _persistentClass ) ); ! _target = _session.GetEntity( key ); } ! ! if( _target==null ) ! { ! if( _serializableProxy==null ) ! { ! _serializableProxy = SerializableProxy(); ! } ! return _serializableProxy; } ! else ! { ! return _target; } } ! else if( !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals("GetHashCode") ) ! { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return _id.GetHashCode(); ! } ! else if( _identifierPropertyInfo!=null && method.Equals( _identifierPropertyInfo.GetGetMethod(true) ) ) ! // .Name.Equals( "get_" + _identifierPropertyInfo.Name ) ) -> this was removed because of null _identifierPropertyInfo problems ! { ! return _id; ! } ! else if( method.Name.Equals( "Dispose" ) ) ! { ! return null; } ! else if ( args.Length==1 && !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals( "Equals" ) ) ! { ! // less dodgy because NHibernate forces == to be the same as Identifier Equals ! return _id.Equals( _identifierPropertyInfo.GetValue( _target, null ) ); ! } ! ! else ! { ! return InvokeImplementation; } } ! #region Helper Class for all of the Parameters to InvokeMember ! ! protected class InvokeMemberParams ! { ! private string _methodName; ! private BindingFlags _invokeAttr; ! private static IDictionary _knownPrefixes; ! ! static InvokeMemberParams () ! { ! BindingFlags defaultFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; ! _knownPrefixes = new Hashtable(6); ! _knownPrefixes.Add("", defaultFlags | BindingFlags.InvokeMethod); ! _knownPrefixes.Add("get", defaultFlags | BindingFlags.GetProperty); ! _knownPrefixes.Add("set", defaultFlags | BindingFlags.SetProperty); } ! ! private InvokeMemberParams(string methodName, BindingFlags invokeAttr) ! { ! _methodName = methodName; ! _invokeAttr = invokeAttr; } ! ! public BindingFlags InvokeAttr ! { ! get { return _invokeAttr; } } ! ! public string MethodName ! { ! get { return _methodName; } } ! ! public static InvokeMemberParams GetInvokeMemberParams(string methodName) ! { ! int indexOfFirstUnderscore = methodName.IndexOf("_"); ! string prefix = String.Empty; ! ! string method; ! BindingFlags flags; ! ! // there was no underscore found in the name - has to be a method that ! // is being called. ! if(indexOfFirstUnderscore==-1) ! { ! return new InvokeMemberParams(methodName, (BindingFlags)_knownPrefixes[""] ); } ! ! prefix = methodName.Substring(0, indexOfFirstUnderscore); ! ! // there was an underscore found - is this a property get_/set_ or just a bad naming ! // convention that someone is following ! if(_knownPrefixes.Contains(prefix)) ! { ! method = methodName.Substring(indexOfFirstUnderscore + 1, methodName.Length - (indexOfFirstUnderscore + 1) ); ! flags = (BindingFlags)_knownPrefixes[prefix]; ! ! return new InvokeMemberParams(method, flags); ! } ! else ! { ! // bad naming convention was used - an "_" in a method name??? ! return new InvokeMemberParams(methodName, (BindingFlags)_knownPrefixes[""] ); } } } + #endregion } ! } --- NEW FILE: AvalonLazyInitializer.cs --- using System; using System.Collections; using System.Reflection; using Apache.Avalon.DynamicProxy; using NHibernate.Engine; namespace NHibernate.Proxy { /// <summary> /// A <see cref="NLazyInitiliazer"/> built using Avalon's Dynamic Class Generator. /// </summary> public class AvalonLazyInitializer : LazyInitializer, IInvocationHandler { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(AvalonLazyInitializer) ); private System.Type[] _interfaces; /// <summary> /// /// </summary> /// <param name="persistentClass"></param> /// <param name="interfaces"></param> /// <param name="id"></param> /// <param name="identifierProperty"></param> /// <param name="session"></param> internal AvalonLazyInitializer(System.Type persistentClass, System.Type[] interfaces, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session) : base (persistentClass, id, identifierPropertyInfo, session) { _interfaces = interfaces; } protected override SerializableProxy SerializableProxy() { return new SerializableProxy( _persistentClass, _interfaces, _id, _identifierPropertyInfo ); } #region Apache.Avalon.DynamicProxy.IInvocationHandler Members /// <summary> /// Invoke the actual Property/Method using the Proxy or instantiate the actual /// object and use it when the Proxy can't handle the method. /// </summary> /// <param name="methodName">The name of the Method/Property to Invoke.</param> /// <param name="args">The parameters for the Method/Property</param> /// <returns>The result just like the actual object was called.</returns> public object Invoke(object proxy, MethodInfo method, params object[] arguments) { object result = base.Invoke( method, arguments ); // the base NLazyInitializer could not handle it so we need to Invoke // the method/property against the real class. if(result==InvokeImplementation) { InvokeMemberParams invokeParams = InvokeMemberParams.GetInvokeMemberParams( method.Name ); return method.Invoke( GetImplementation(), arguments ); } else { return result; } } #endregion } } --- NEW FILE: ProxyGeneratorFactory.cs --- using System; using System.Reflection; using Apache.Avalon.DynamicProxy; using NHibernate.Engine; namespace NHibernate.Proxy { /// <summary> /// A Factory for getting the ProxyGenerator. /// </summary> public sealed class ProxyGeneratorFactory { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(ProxyGeneratorFactory) ); private static AvalonProxyGenerator _generator = new AvalonProxyGenerator(); public static IProxyGenerator GetProxyGenerator() { return _generator; } } } --- HibernateProxy.cs DELETED --- |