springnet-commits Mailing List for Spring Framework .NET (Page 56)
Brought to you by:
aseovic,
markpollack
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(33) |
Aug
(163) |
Sep
(491) |
Oct
(289) |
Nov
(336) |
Dec
(84) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(227) |
Feb
(413) |
Mar
(128) |
Apr
(232) |
May
(92) |
Jun
(299) |
Jul
(386) |
Aug
(228) |
Sep
(237) |
Oct
(426) |
Nov
(325) |
Dec
(405) |
2006 |
Jan
(315) |
Feb
(311) |
Mar
(152) |
Apr
(177) |
May
(443) |
Jun
(92) |
Jul
(88) |
Aug
(80) |
Sep
(288) |
Oct
(515) |
Nov
(1049) |
Dec
(440) |
2007 |
Jan
(179) |
Feb
(406) |
Mar
(294) |
Apr
(80) |
May
(432) |
Jun
(242) |
Jul
(452) |
Aug
(710) |
Sep
(206) |
Oct
(240) |
Nov
(65) |
Dec
(227) |
2008 |
Jan
(80) |
Feb
(90) |
Mar
(98) |
Apr
(136) |
May
(101) |
Jun
(12) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Erich E. <oak...@us...> - 2007-08-22 20:16:47
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31356 Modified Files: Spring.Core.2003.csproj Spring.Core.2005.csproj Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: Spring.Core.2005.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.2005.csproj,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** Spring.Core.2005.csproj 8 Aug 2007 17:46:09 -0000 1.102 --- Spring.Core.2005.csproj 22 Aug 2007 20:16:10 -0000 1.103 *************** *** 40,44 **** <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> ! <NoWarn>1587, 1591, 219, 162, 618</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> --- 40,44 ---- <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> ! <NoWarn>1587, 219, 162, 618</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> *************** *** 565,568 **** --- 565,569 ---- <Compile Include="Objects\Factory\Config\ExpressionHolder.cs" /> <Compile Include="Objects\Factory\Config\IVariableSource.cs" /> + <Compile Include="Objects\Factory\Config\VariableAccessor.cs" /> <Compile Include="Objects\Factory\Config\VariablePlaceholderConfigurer.cs" /> <Compile Include="Objects\Factory\Parsing\ReaderContext.cs" /> *************** *** 977,980 **** --- 978,983 ---- <Compile Include="Util\Generic\CollectionUtils.cs" /> <Compile Include="Util\PatternMatchUtils.cs" /> + <Compile Include="Util\UniqueKey.cs" /> + <Compile Include="Core\TypeConversion\UniqueKeyConverter.cs" /> <Compile Include="Util\XmlUtils.cs" /> <Compile Include="Util\DelegateInfo.cs"> Index: Spring.Core.2003.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.2003.csproj,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Spring.Core.2003.csproj 8 Aug 2007 17:46:09 -0000 1.44 --- Spring.Core.2003.csproj 22 Aug 2007 20:16:10 -0000 1.45 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.10.6030" SchemaVersion = "2.0" ProjectGuid = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" *************** *** 35,39 **** IncrementalBuild = "false" NoStdLib = "false" ! NoWarn = "1591, 219, 162" Optimize = "false" OutputPath = "..\..\..\build\VS.Net\Spring.Core\Debug\" --- 35,39 ---- IncrementalBuild = "false" NoStdLib = "false" ! NoWarn = "219, 162" Optimize = "false" OutputPath = "..\..\..\build\VS.Net\Spring.Core\Debug\" *************** *** 699,702 **** --- 699,707 ---- /> <File + RelPath = "Core\TypeConversion\UniqueKeyConverter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Core\TypeConversion\UriConverter.cs" SubType = "Code" *************** *** 1677,1680 **** --- 1682,1690 ---- /> <File + RelPath = "Objects\Factory\Config\VariableAccessor.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Objects\Factory\Config\VariablePlaceholderConfigurer.cs" SubType = "Code" *************** *** 2274,2277 **** --- 2284,2292 ---- /> <File + RelPath = "Util\UniqueKey.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Util\XmlUtils.cs" SubType = "Code" |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:41
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31490 Modified Files: Spring.Data.NHibernate.2003.csproj Spring.Data.NHibernate.2005.csproj Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: Spring.Data.NHibernate.2003.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate/Spring.Data.NHibernate.2003.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Spring.Data.NHibernate.2003.csproj 9 Aug 2007 06:50:15 -0000 1.4 --- Spring.Data.NHibernate.2003.csproj 22 Aug 2007 20:16:36 -0000 1.5 *************** *** 226,229 **** --- 226,234 ---- /> <File + RelPath = "Data\NHibernate\Support\ConfigSectionSessionScopeSettings.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Data\NHibernate\Support\HibernateDaoSupport.cs" SubType = "Code" *************** *** 240,243 **** --- 245,253 ---- BuildAction = "Compile" /> + <File + RelPath = "Data\NHibernate\Support\SessionScopeSettings.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> Index: Spring.Data.NHibernate.2005.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate/Spring.Data.NHibernate.2005.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Spring.Data.NHibernate.2005.csproj 8 Aug 2007 18:55:13 -0000 1.6 --- Spring.Data.NHibernate.2005.csproj 22 Aug 2007 20:16:36 -0000 1.7 *************** *** 71,77 **** --- 71,79 ---- <Compile Include="Data\NHibernate\SessionHolder.cs" /> <Compile Include="Data\NHibernate\SpringSessionSynchronization.cs" /> + <Compile Include="Data\NHibernate\Support\ConfigSectionSessionScopeSettings.cs" /> <Compile Include="Data\NHibernate\Support\HibernateDaoSupport.cs" /> <Compile Include="Data\NHibernate\Support\OpenSessionInViewModule.cs" /> <Compile Include="Data\NHibernate\Support\SessionScope.cs" /> + <Compile Include="Data\NHibernate\Support\SessionScopeSettings.cs" /> <Compile Include="Data\NHibernate\TemplateFlushMode.cs" /> </ItemGroup> |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:41
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31490/Data/NHibernate/Support Modified Files: SessionScope.cs Added Files: ConfigSectionSessionScopeSettings.cs SessionScopeSettings.cs Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 --- NEW FILE: ConfigSectionSessionScopeSettings.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: SessionScopeSettings.cs --- (This appears to be a binary file; contents omitted.) Index: SessionScope.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data.NHibernate/Data/NHibernate/Support/SessionScope.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SessionScope.cs 8 Aug 2007 18:41:12 -0000 1.1 --- SessionScope.cs 22 Aug 2007 20:16:36 -0000 1.2 *************** *** 19,32 **** #endregion using System; ! using System.Collections.Specialized; using Common.Logging; using NHibernate; - using Spring.Context.Support; using Spring.Threading; using Spring.Transaction.Support; using Spring.Util; ! namespace Spring.Data.NHibernate.Support { /// <summary> /// Implementation of SessionScope that associates a single session within the using scope. --- 19,38 ---- #endregion + #region Imports + using System; ! using System.Diagnostics; ! using System.Reflection; ! using System.Text; using Common.Logging; using NHibernate; using Spring.Threading; using Spring.Transaction.Support; using Spring.Util; ! #endregion ! ! namespace Spring.Data.NHibernate.Support ! { /// <summary> /// Implementation of SessionScope that associates a single session within the using scope. *************** *** 44,76 **** /// ICurrentSessionContext interface. /// </para> /// It is assumed that the session factory object name is called "SessionFactory". In case that you named the object /// in different way you can specify your can specify it in the application settings using the key /// Spring.Data.NHibernate.Support.SessionScope.SessionFactoryObjectName. Values for EntityInterceptorObjectName /// and SingleSessionMode can be specified similarly. /// </remarks> /// <author>Robert M. (.NET)</author> /// <author>Harald Radi (.NET)</author> ! public class SessionScope : IDisposable { #region Fields /// <summary> ! /// The default session factory name to use when retrieving the Hibernate session factory from ! /// the root context. ! /// </summary> ! private static readonly string DEFAULT_SESSION_FACTORY_OBJECT_NAME = "SessionFactory"; ! /// <summary> ! /// the logging instance. ! /// </summary> ! protected readonly ILog log; ! private readonly string PARTICIPATE_KEY; ! private IInterceptor entityInterceptor = null; ! private bool entityInterceptorInitialized = false; ! private string entityInterceptorObjectName = null; ! private ISessionFactory sessionFactory = null; ! private bool sessionFactoryInitialized = false; ! private string sessionFactoryObjectName = DEFAULT_SESSION_FACTORY_OBJECT_NAME; ! private bool singleSession = true; #endregion --- 50,81 ---- /// ICurrentSessionContext interface. /// </para> + /// <para> /// It is assumed that the session factory object name is called "SessionFactory". In case that you named the object /// in different way you can specify your can specify it in the application settings using the key /// Spring.Data.NHibernate.Support.SessionScope.SessionFactoryObjectName. Values for EntityInterceptorObjectName /// and SingleSessionMode can be specified similarly. + /// </para> + /// <para> + /// <b>Note:</b> + /// The session is managed on a per thread basis on the thread that opens the scope instance. This means that you must + /// never pass a reference to a <see cref="SessionScope"/> instance over to another thread! + /// </para> /// </remarks> /// <author>Robert M. (.NET)</author> /// <author>Harald Radi (.NET)</author> ! public class SessionScope : IDisposable ! { #region Fields /// <summary> ! /// The logging instance. ! /// </summary> ! protected readonly ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); ! private readonly SessionScopeSettings settings; ! // Keys into LogicalThreadContext for runtime values. ! private readonly string PARTICIPATE_KEY; ! private readonly string ISOPEN_KEY; #endregion *************** *** 78,87 **** #region Constructor (s) - /// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class in single session mode, /// associating a session with the thread. The session is opened lazily on demand. /// </summary> ! public SessionScope() : this(true) {} --- 83,94 ---- #region Constructor (s) /// <summary> /// Initializes a new instance of the <see cref="SessionScope"/> class in single session mode, /// associating a session with the thread. The session is opened lazily on demand. /// </summary> ! public SessionScope() ! : this(true) ! { ! } *************** *** 89,139 **** /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> ! /// <param name="open">if set to <c>true</c> associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. /// </param> ! public SessionScope(bool open) { ! String fullName = GetType().FullName; ! ! log = LogManager.GetLogger(GetType()); ! PARTICIPATE_KEY = fullName + ".Participate"; ! ! NameValueCollection appSettings = (NameValueCollection) ConfigurationUtils.GetSection("appSettings"); ! ! if (appSettings != null) { ! String s1 = appSettings[fullName + ".SessionFactoryObjectName"]; ! String s3 = appSettings[fullName + ".EntityInterceptorObjectName"]; ! String s2 = appSettings[fullName + ".SingleSession"]; ! ! if (StringUtils.HasLength(s1)) SessionFactoryObjectName = s1; ! if (StringUtils.HasLength(s3)) EntityInterceptorObjectName = s3; ! if (StringUtils.HasLength(s2)) SingleSession = bool.Parse(s2); ! } ! ! if (open) Open(); } ! #endregion ! #region Properties /// <summary> ! /// Set or return the object name of the SessionFactory to fetch from Spring's ! /// root application context. Default is "sessionFactory". /// </summary> ! public string SessionFactoryObjectName { ! set { sessionFactoryObjectName = value; } ! get { return sessionFactoryObjectName; } } /// <summary> ! /// Set or return the object name of the SessionFactory to fetch from Spring's ! /// root application context. Default is "sessionFactory". /// </summary> ! public string EntityInterceptorObjectName { ! set { entityInterceptorObjectName = value; } ! get { return entityInterceptorObjectName; } } ///<summary> /// Set whether to use a single session for each request. Default is "true". --- 96,198 ---- /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> ! /// <param name="open"> ! /// If set to <c>true</c> associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. /// </param> ! public SessionScope(bool open) ! : this("appSettings", open) ! { ! // noop } ! /// <summary> ! /// Initializes a new instance of the <see cref="SessionScope"/> class. ! /// </summary> ! /// <param name="sectionName"> ! /// The name of the configuration section to read configuration settings from. ! /// See <see cref="ConfigSectionSessionScopeSettings"/> for more info. ! /// </param> ! /// <param name="open"> ! /// If set to <c>true</c> associate a session with the thread. If false, another ! /// collaborating class will associate the session with the thread, potentially by calling ! /// the Open method on this class. ! /// </param> ! public SessionScope(string sectionName, bool open) ! : this( new ConfigSectionSessionScopeSettings(new StackFrame(1).GetMethod().DeclaringType, sectionName), open) ! { ! // noop ! } ! /// <summary> ! /// Initializes a new instance of the <see cref="SessionScope"/> class. ! /// </summary> ! /// <param name="sessionFactory"> ! /// The <see cref="ISessionFactory"/> instance to be used for obtaining <see cref="ISession"/> instances. ! /// </param> ! /// <param name="open"> ! /// If set to <c>true</c> associate a session with the thread. If false, another ! /// collaborating class will associate the session with the thread, potentially by calling ! /// the Open method on this class. ! /// </param> ! public SessionScope(ISessionFactory sessionFactory, bool open) ! : this(new SessionScopeSettings(sessionFactory), open) ! { ! // noop ! } /// <summary> ! /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> ! /// <param name="sessionFactory"> ! /// The <see cref="ISessionFactory"/> instance to be used for obtaining <see cref="ISession"/> instances. ! /// </param> ! /// <param name="entityInterceptor"> ! /// Specify the <see cref="IInterceptor"/> to be set on each session provided by this <see cref="SessionScope"/> instance. ! /// </param> ! /// <param name="singleSession"> ! /// Set whether to use a single session for each request. See <see cref="SingleSession"/> property for details. ! /// </param> ! /// <param name="defaultFlushMode"> ! /// Specify the flushmode to be applied on each session provided by this <see cref="SessionScope"/> instance. ! /// </param> ! /// <param name="open"> ! /// If set to <c>true</c> associate a session with the thread. If false, another ! /// collaborating class will associate the session with the thread, potentially by calling ! /// the Open method on this class. ! /// </param> ! public SessionScope(ISessionFactory sessionFactory, IInterceptor entityInterceptor, bool singleSession, FlushMode defaultFlushMode, bool open) ! :this(new SessionScopeSettings(sessionFactory, entityInterceptor, singleSession, defaultFlushMode), open) ! { ! // noop } /// <summary> ! /// Initializes a new instance of the <see cref="SessionScope"/> class. /// </summary> ! /// <param name="settings">An <see cref="SessionScopeSettings"/> instance holding the scope configuration</param> ! /// <param name="open"> ! /// If set to <c>true</c> associate a session with the thread. If false, another ! /// collaborating class will associate the session with the thread, potentially by calling ! /// the Open method on this class. ! /// </param> ! public SessionScope(SessionScopeSettings settings, bool open) ! { ! log = LogManager.GetLogger(this.GetType()); ! this.settings = settings; ! ! PARTICIPATE_KEY = UniqueKey.GetInstanceScopedString(this, "Participate"); ! ISOPEN_KEY = UniqueKey.GetInstanceScopedString(this, "IsOpen"); ! ! if (open) ! { ! Open(); ! } } + #endregion + + #region Properties + ///<summary> /// Set whether to use a single session for each request. Default is "true". *************** *** 143,149 **** /// processed at request completion. /// </summary> ! public bool SingleSession { ! set { singleSession = value; } ! get { return singleSession; } } --- 202,221 ---- /// processed at request completion. /// </summary> ! public bool SingleSession ! { ! get { return settings.SingleSession; } ! } ! ! /// <summary> ! /// Gets or Sets the flushmode to be applied on each newly created session. ! /// </summary> ! /// <remarks> ! /// This property defaults to <see cref="FlushMode.Never"/> to ensure that modifying objects outside the boundaries ! /// of a transaction will not be persisted. It is recommended to not change this value but wrap any modifying operation ! /// within a transaction. ! /// </remarks> ! public FlushMode DefaultFlushMode ! { ! get { return settings.DefaultFlushMode; } } *************** *** 151,167 **** /// Get or set the configured SessionFactory /// </summary> ! public ISessionFactory SessionFactory { ! get { ! if (!sessionFactoryInitialized) { ! sessionFactoryInitialized = true; ! sessionFactory = (ISessionFactory) ContextRegistry.GetContext().GetObject(SessionFactoryObjectName); ! if (sessionFactory == null) throw new ArgumentException("mandatory SessionFactory not found for OpenSessionInViewModule"); ! } ! return sessionFactory; ! } ! set { ! if (value == null) throw new ArgumentNullException("value"); ! sessionFactory = value; ! sessionFactoryInitialized = true; } } --- 223,231 ---- /// Get or set the configured SessionFactory /// </summary> ! public ISessionFactory SessionFactory ! { ! get ! { ! return settings.SessionFactory; } } *************** *** 170,195 **** /// Get or set the configured EntityInterceptor /// </summary> ! public IInterceptor EntityInterceptor { ! get { ! if (!entityInterceptorInitialized) { ! entityInterceptorInitialized = true; ! if (StringUtils.HasLength(EntityInterceptorObjectName)) entityInterceptor = (IInterceptor) ContextRegistry.GetContext().GetObject(EntityInterceptorObjectName); ! } ! return entityInterceptor; } ! set { ! if (value == null) throw new ArgumentNullException("value"); ! entityInterceptor = value; ! entityInterceptorInitialized = true; } } /// <summary> ! /// Gets/Sets a flag, whether this module manages it's own session for the current request or not. /// </summary> /// <value><c>false</c> if session is managed by this module. <c>false</c> otherwise</value> ! private bool Participate { ! get { return (bool) LogicalThreadContext.GetData(PARTICIPATE_KEY); } ! set { LogicalThreadContext.SetData(PARTICIPATE_KEY, value); } } --- 234,296 ---- /// Get or set the configured EntityInterceptor /// </summary> ! public IInterceptor EntityInterceptor ! { ! get ! { ! return settings.EntityInterceptor; } ! } ! ! /// <summary> ! /// Gets a flag, whether this scope is in "open" state on the current logical thread. ! /// </summary> ! public bool IsOpen ! { ! get ! { ! return (null != LogicalThreadContext.GetData(ISOPEN_KEY)); } } /// <summary> ! /// Gets a flag, whether this scope manages it's own session for the current logical thread or not. ! /// </summary> ! public bool IsParticipating ! { ! get ! { ! return (null != LogicalThreadContext.GetData(PARTICIPATE_KEY)); ! } ! } ! ! /// <summary> ! /// Sets a flag, whether this scope is in "open" state on the current logical thread. ! /// </summary> ! private void SetOpen(bool isOpen) ! { ! if (isOpen) ! { ! LogicalThreadContext.SetData(ISOPEN_KEY, ISOPEN_KEY); ! } ! else ! { ! LogicalThreadContext.FreeNamedDataSlot(ISOPEN_KEY); ! } ! } ! ! /// <summary> ! /// Gets/Sets a flag, whether this scope manages it's own session for the current logical thread or not. /// </summary> /// <value><c>false</c> if session is managed by this module. <c>false</c> otherwise</value> ! private void SetParticipating(bool participating) ! { ! if (participating) ! { ! LogicalThreadContext.SetData(PARTICIPATE_KEY, PARTICIPATE_KEY); ! } ! else ! { ! LogicalThreadContext.FreeNamedDataSlot(PARTICIPATE_KEY); ! } } *************** *** 201,205 **** /// Call <code>Close()</code>, /// </summary> ! public virtual void Dispose() { Close(); } --- 302,307 ---- /// Call <code>Close()</code>, /// </summary> ! public virtual void Dispose() ! { Close(); } *************** *** 213,235 **** /// registers with spring's <see cref="TransactionSynchronizationManager"/>. /// </summary> ! public void Open() { ! Participate = false; ! if (SingleSession) { // single session mode ! if (TransactionSynchronizationManager.HasResource(SessionFactory)) { // Do not modify the Session: just set the participate flag. ! if (log.IsDebugEnabled) log.Debug("Participating in existing Hibernate SessionFactory"); ! Participate = true; ! } else { ! log.Debug("Opening single Hibernate Session in SessionScope"); TransactionSynchronizationManager.BindResource(SessionFactory, new LazySessionHolder(this)); } ! } else { // deferred close mode ! if (SessionFactoryUtils.IsDeferredCloseActive(SessionFactory)) { // Do not modify deferred close: just set the participate flag. ! Participate = true; ! } else SessionFactoryUtils.InitDeferredClose(SessionFactory); } } --- 315,359 ---- /// registers with spring's <see cref="TransactionSynchronizationManager"/>. /// </summary> ! public void Open() ! { ! if (IsParticipating || IsOpen) ! { ! throw new InvalidOperationException("This scope is already open"); ! } ! ! bool isDebugEnabled = log.IsDebugEnabled; ! ! if (SingleSession) ! { // single session mode ! if (TransactionSynchronizationManager.HasResource(SessionFactory)) ! { // Do not modify the Session: just set the participate flag. ! if (isDebugEnabled) log.Debug("Participating in existing Hibernate SessionFactory"); ! SetParticipating(true); ! } ! else ! { ! if (isDebugEnabled) log.Debug("Opening single Hibernate Session in SessionScope"); TransactionSynchronizationManager.BindResource(SessionFactory, new LazySessionHolder(this)); } ! } ! else ! { // deferred close mode ! if (SessionFactoryUtils.IsDeferredCloseActive(SessionFactory)) ! { // Do not modify deferred close: just set the participate flag. ! if (isDebugEnabled) log.Debug("Participating in active deferred close mode"); ! SetParticipating(true); ! } ! else ! { ! if (isDebugEnabled) log.Debug("Initializing deferred close mode"); ! SessionFactoryUtils.InitDeferredClose(SessionFactory); ! } } + + SetOpen(true); } *************** *** 238,259 **** /// from spring's <see cref="TransactionSynchronizationManager"/>. /// </summary> ! public void Close() { ! if (!Participate) { ! if (SingleSession) { // single session mode ! log.Debug("Closing single Hibernate Session in SessionScope"); TransactionSynchronizationManager.UnbindResource(SessionFactory); LazySessionHolder.Current.Close(); ! } else { // deferred close mode ! if (log.IsDebugEnabled) log.Debug("Closing all Hibernate Sessions"); SessionFactoryUtils.ProcessDeferredClose(SessionFactory); } ! } else if (log.IsDebugEnabled) log.Debug("Only participated Hibernate Session - doing nothing"); } ! private ISession OpenSession() { ISession session = SessionFactoryUtils.OpenSession(SessionFactory, EntityInterceptor); ! session.FlushMode = FlushMode.Never; return session; } --- 362,416 ---- /// from spring's <see cref="TransactionSynchronizationManager"/>. /// </summary> ! public void Close() ! { ! bool isDebugEnabled = log.IsDebugEnabled; ! if (isDebugEnabled) log.Debug("Trying to close SessionScope"); ! ! if (IsOpen) ! { ! try ! { ! DoClose(isDebugEnabled); ! } ! finally ! { ! SetOpen(false); ! SetParticipating(false); ! } ! } ! else ! { ! if (isDebugEnabled) log.Debug("SessionScope is already closed - doing nothing"); ! } ! } ! ! private void DoClose(bool isLogDebugEnabled) ! { ! if (!IsParticipating) ! { ! if (SingleSession) ! { // single session mode ! if (isLogDebugEnabled) log.Debug("Closing single Hibernate Session in SessionScope"); TransactionSynchronizationManager.UnbindResource(SessionFactory); LazySessionHolder.Current.Close(); ! } ! else ! { // deferred close mode ! if (isLogDebugEnabled) log.Debug("Closing all Hibernate Sessions"); SessionFactoryUtils.ProcessDeferredClose(SessionFactory); } ! } ! else ! { ! if (isLogDebugEnabled) log.Debug("Only participated Hibernate Session - doing nothing"); ! } } ! private ISession DoOpenSession() ! { ISession session = SessionFactoryUtils.OpenSession(SessionFactory, EntityInterceptor); ! session.FlushMode = DefaultFlushMode; return session; } *************** *** 272,276 **** private class LazySessionHolder : SessionHolder { ! private static readonly string ThreadDataSlotKey = typeof(LazySessionHolder).FullName + ".Current"; private readonly ILog log = LogManager.GetLogger(typeof(LazySessionHolder)); --- 429,433 ---- private class LazySessionHolder : SessionHolder { ! private static readonly string ThreadDataSlotKey = UniqueKey.GetTypeScopedString(typeof(LazySessionHolder), "Current"); private readonly ILog log = LogManager.GetLogger(typeof(LazySessionHolder)); *************** *** 293,297 **** public static LazySessionHolder Current { ! get { return (LazySessionHolder)LogicalThreadContext.GetData(ThreadDataSlotKey); } set { LogicalThreadContext.SetData(ThreadDataSlotKey, value); } } --- 450,454 ---- public static LazySessionHolder Current { ! get { return (LazySessionHolder) LogicalThreadContext.GetData(ThreadDataSlotKey); } set { LogicalThreadContext.SetData(ThreadDataSlotKey, value); } } *************** *** 305,309 **** { if (log.IsDebugEnabled) log.Debug("session instance requested - opening new session"); ! session = owner.OpenSession(); AddSession(session); } --- 462,466 ---- { if (log.IsDebugEnabled) log.Debug("session instance requested - opening new session"); ! session = owner.DoOpenSession(); AddSession(session); } |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:31
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31467 Modified Files: ConfigSectionVariableSource.cs Added Files: VariableAccessor.cs Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 --- NEW FILE: VariableAccessor.cs --- (This appears to be a binary file; contents omitted.) Index: ConfigSectionVariableSource.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/ConfigSectionVariableSource.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConfigSectionVariableSource.cs 2 Aug 2007 22:18:32 -0000 1.3 --- ConfigSectionVariableSource.cs 22 Aug 2007 20:16:27 -0000 1.4 *************** *** 40,43 **** --- 40,66 ---- /// <summary> + /// Initializes a new instance of <see cref="ConfigSectionVariableSource"/> + /// </summary> + public ConfigSectionVariableSource() + { + } + + /// <summary> + /// Initializes a new instance of <see cref="ConfigSectionVariableSource"/> from the given <paramref name="sectionName"/> + /// </summary> + public ConfigSectionVariableSource(string sectionName) + { + this.SectionName = sectionName; + } + + /// <summary> + /// Initializes a new instance of <see cref="ConfigSectionVariableSource"/> from the given <paramref name="sectionNames"/> + /// </summary> + public ConfigSectionVariableSource(string[] sectionNames) + { + this.SectionNames = sectionNames; + } + + /// <summary> /// Gets or sets a list of section names variables should be loaded from. /// </summary> |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:30
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Cache In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31043 Modified Files: CacheResultAdvice.cs Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: CacheResultAdvice.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aspects/Cache/CacheResultAdvice.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CacheResultAdvice.cs 1 Apr 2007 15:04:04 -0000 1.3 --- CacheResultAdvice.cs 22 Aug 2007 20:15:58 -0000 1.4 *************** *** 55,58 **** --- 55,61 ---- private static readonly ILog logger = LogManager.GetLogger(typeof (CacheResultAdvice)); + // NullValue + private static readonly object NullValue = new object(); + /// <summary> /// Applies caching around a method invocation. *************** *** 120,126 **** private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, out bool cacheHit) { - object returnValue; if (resultInfo != null) { IDictionary vars = PrepareVariables(invocation.Method, invocation.Arguments); --- 123,131 ---- private object GetReturnValue(IMethodInvocation invocation, CacheResultAttribute resultInfo, out bool cacheHit) { if (resultInfo != null) { + object returnValue = null; + bool isLogDebugEnabled = logger.IsDebugEnabled; + IDictionary vars = PrepareVariables(invocation.Method, invocation.Arguments); *************** *** 132,141 **** returnValue = cache.Get(resultKey); ! cacheHit = returnValue != null; if (!cacheHit) { #region Instrumentation ! if (logger.IsDebugEnabled) { logger.Debug("Object for key [" + resultKey + "] was not found in cache. Proceeding..."); --- 137,146 ---- returnValue = cache.Get(resultKey); ! cacheHit = (returnValue != null); if (!cacheHit) { #region Instrumentation ! if (isLogDebugEnabled) { logger.Debug("Object for key [" + resultKey + "] was not found in cache. Proceeding..."); *************** *** 145,155 **** returnValue = invocation.Proceed(); ! if (returnValue != null) { ! if (EvalCondition(resultInfo.Condition, resultInfo.ConditionExpression, returnValue, vars)) ! { ! cache.Insert(resultKey, returnValue, resultInfo.TimeToLive, ! resultInfo.SlidingExpiration, resultInfo.Priority); ! } } } --- 150,157 ---- returnValue = invocation.Proceed(); ! if (EvalCondition(resultInfo.Condition, resultInfo.ConditionExpression, returnValue, vars)) { ! cache.Insert(resultKey, (returnValue==null)?NullValue:returnValue, resultInfo.TimeToLive, ! resultInfo.SlidingExpiration, resultInfo.Priority); } } *************** *** 158,162 **** #region Instrumentation ! if (logger.IsDebugEnabled) { logger.Debug("Cache hit for [" + resultKey + "]. Aborting invocation..."); --- 160,164 ---- #region Instrumentation ! if (isLogDebugEnabled) { logger.Debug("Cache hit for [" + resultKey + "]. Aborting invocation..."); *************** *** 166,170 **** } ! return returnValue; } --- 168,172 ---- } ! return (returnValue==NullValue)?null:returnValue; } *************** *** 196,200 **** { object itemKey = itemInfo.KeyExpression.GetValue(item); ! cache.Insert(itemKey, item, itemInfo.TimeToLive, itemInfo.SlidingExpiration, itemInfo.Priority); } --- 198,202 ---- { object itemKey = itemInfo.KeyExpression.GetValue(item); ! cache.Insert(itemKey, (item==null?NullValue:item), itemInfo.TimeToLive, itemInfo.SlidingExpiration, itemInfo.Priority); } |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:25
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31439/Util Modified Files: ObjectUtils.cs Added Files: UniqueKey.cs Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: ObjectUtils.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/ObjectUtils.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ObjectUtils.cs 2 Aug 2007 04:15:30 -0000 1.4 --- ObjectUtils.cs 22 Aug 2007 20:16:20 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- using System.Reflection; using System.Runtime.Remoting; + using Spring.Objects; #endregion *************** *** 212,216 **** catch (TargetInvocationException ex) { ! throw ex.InnerException; } } --- 213,219 ---- catch (TargetInvocationException ex) { ! throw new FatalReflectionException( ! string.Format( ! CultureInfo.InvariantCulture, "Failed instantiating type [{0}].", constructor.DeclaringType), ex.InnerException); } } --- NEW FILE: UniqueKey.cs --- (This appears to be a binary file; contents omitted.) |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:25
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Expressions In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31439/Expressions Modified Files: BaseNode.cs Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: BaseNode.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Expressions/BaseNode.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** BaseNode.cs 16 May 2007 15:09:41 -0000 1.21 --- BaseNode.cs 22 Aug 2007 20:16:20 -0000 1.22 *************** *** 38,45 **** --- 38,60 ---- protected internal class EvaluationContext { + /// <summary> + /// Gets/Sets the root context of the current evaluation + /// </summary> public object RootContext; + /// <summary> + /// Gets the type of the <see cref="RootContext"/> + /// </summary> public Type RootContextType { get { return (RootContext == null) ? null : RootContext.GetType(); } } + /// <summary> + /// Gets/Sets the current context of the current evaluation + /// </summary> public object CurrentContext; + /// <summary> + /// Gets/Sets global variables of the current evaluation + /// </summary> public IDictionary Variables; + /// <summary> + /// Gets/Sets local variables of the current evaluation + /// </summary> public IDictionary LocalVariables; |
From: Erich E. <oak...@us...> - 2007-08-22 20:16:20
|
Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31009 Modified Files: .cvsignore Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: .cvsignore =================================================================== RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.DataQuickStart/src/Spring/Spring.DataQuickStart/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 18 Jun 2007 20:04:44 -0000 1.1 --- .cvsignore 22 Aug 2007 20:15:44 -0000 1.2 *************** *** 2,6 **** obj *.csproj.user ! ! ! --- 2,4 ---- obj *.csproj.user ! Spring.DataQuickStart.xml |
From: Erich E. <oak...@us...> - 2007-08-22 20:15:57
|
Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.TxQuickStart/src/Spring/Spring.TxQuickStart In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31028 Modified Files: .cvsignore Log Message: housekeeping fixed SPRNET-697 fixed SPRNET-686 Index: .cvsignore =================================================================== RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.TxQuickStart/src/Spring/Spring.TxQuickStart/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 18 Jun 2007 20:05:12 -0000 1.2 --- .cvsignore 22 Aug 2007 20:15:51 -0000 1.3 *************** *** 2,6 **** obj *.csproj.user ! ! ! --- 2,4 ---- obj *.csproj.user ! Spring.TxQuickStart.xml |
From: Erich E. <oak...@us...> - 2007-08-22 20:09:29
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28194/Support Log Message: Directory /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/Support added to the repository |
From: Mark P. <mar...@us...> - 2007-08-22 08:52:18
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv15261 Modified Files: DefaultListableObjectFactoryTests.cs Log Message: made loadproperties in PropertyResourceConfigurer virtual some other trival code cleanup. Index: DefaultListableObjectFactoryTests.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory/DefaultListableObjectFactoryTests.cs,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** DefaultListableObjectFactoryTests.cs 4 Aug 2007 03:15:18 -0000 1.42 --- DefaultListableObjectFactoryTests.cs 22 Aug 2007 08:52:12 -0000 1.43 *************** *** 24,27 **** --- 24,28 ---- using System.Collections; using System.Globalization; + using System.Reflection; using DotNetMock.Dynamic; using NUnit.Framework; *************** *** 309,316 **** public object PostProcessBeforeInstantiation(Type objectType, string objectName) { return null; } ! public object PostProcessAfterInitialization(object obj, string name) { return obj; --- 310,334 ---- public object PostProcessBeforeInstantiation(Type objectType, string objectName) { + //proceed with default instantiation return null; } ! public bool PostProcessAfterInstantiation(object objectInstance, string objectName) ! { ! //proceed to set properties on the object ! return true; ! } ! ! #region IInstantiationAwareObjectPostProcessor Members ! ! public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, ! string objectName) ! { ! return pvs; ! } ! ! #endregion ! ! public object PostProcessAfterInitialization(object obj, string objectName) { return obj; *************** *** 348,352 **** } ! public object PostProcessAfterInitialization(object obj, string name) { throw new NotImplementedException(); --- 366,385 ---- } ! public bool PostProcessAfterInstantiation(object objectInstance, string objectName) ! { ! return true; ! } ! ! #region IInstantiationAwareObjectPostProcessor Members ! ! public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, ! string objectName) ! { ! return pvs; ! } ! ! #endregion ! ! public object PostProcessAfterInitialization(object obj, string objectName) { throw new NotImplementedException(); |
From: Mark P. <mar...@us...> - 2007-08-22 08:52:08
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv14922/Support Modified Files: MethodOverride.cs Log Message: made loadproperties in PropertyResourceConfigurer virtual some other trival code cleanup. Index: MethodOverride.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/MethodOverride.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MethodOverride.cs 16 Mar 2007 04:01:42 -0000 1.8 --- MethodOverride.cs 22 Aug 2007 08:52:03 -0000 1.9 *************** *** 85,89 **** /// <remarks> /// <p> ! /// If <see lang="true"/> (the defaukt), then argument type matching /// will be performed (because one would not want to override the wrong /// method). --- 85,89 ---- /// <remarks> /// <p> ! /// If <see lang="true"/> (the default), then argument type matching /// will be performed (because one would not want to override the wrong /// method). |
From: Mark P. <mar...@us...> - 2007-08-22 08:52:08
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv14922/Config Modified Files: PropertyResourceConfigurer.cs Log Message: made loadproperties in PropertyResourceConfigurer virtual some other trival code cleanup. Index: PropertyResourceConfigurer.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/PropertyResourceConfigurer.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PropertyResourceConfigurer.cs 8 Aug 2007 17:47:13 -0000 1.17 --- PropertyResourceConfigurer.cs 22 Aug 2007 08:52:03 -0000 1.18 *************** *** 261,265 **** } ! protected void LoadProperties(NameValueCollection properties) { string[] configSections = ConfigSections; --- 261,265 ---- } ! protected virtual void LoadProperties(NameValueCollection properties) { string[] configSections = ConfigSections; |
From: Mark P. <mar...@us...> - 2007-08-22 08:50:27
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.Integration.Tests In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv14334 Modified Files: Spring.Data.Integration.Tests.2005.csproj Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: Spring.Data.Integration.Tests.2005.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.Integration.Tests/Spring.Data.Integration.Tests.2005.csproj,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Spring.Data.Integration.Tests.2005.csproj 21 Aug 2007 19:25:54 -0000 1.19 --- Spring.Data.Integration.Tests.2005.csproj 22 Aug 2007 08:50:23 -0000 1.20 *************** *** 161,165 **** <Compile Include="Data\Northwind\NativeAdoShipperDao.cs" /> <Compile Include="Data\Northwind\Shipper.cs" /> - <Compile Include="Data\OracleAdoTemplateTests.cs" /> <Compile Include="Data\StoredProcedureTests.cs" /> <Compile Include="Data\Support\SimpleExceptionTranslationTests.cs" /> --- 161,164 ---- |
From: Mark P. <mar...@us...> - 2007-08-22 08:50:19
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13974 Modified Files: LifecycleObject.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: LifecycleObject.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory/LifecycleObject.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LifecycleObject.cs 9 Apr 2006 07:24:50 -0000 1.3 --- LifecycleObject.cs 22 Aug 2007 08:50:11 -0000 1.4 *************** *** 174,178 **** } ! public object PostProcessAfterInitialization (object obj, string name) { if (obj is LifecycleObject) --- 174,178 ---- } ! public object PostProcessAfterInitialization (object obj, string objectName) { if (obj is LifecycleObject) |
From: Mark P. <mar...@us...> - 2007-08-22 08:50:19
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory/Xml In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13974/Xml Modified Files: XmlListableObjectFactoryTests.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: XmlListableObjectFactoryTests.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/Factory/Xml/XmlListableObjectFactoryTests.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XmlListableObjectFactoryTests.cs 9 Apr 2006 07:24:51 -0000 1.5 --- XmlListableObjectFactoryTests.cs 22 Aug 2007 08:50:11 -0000 1.6 *************** *** 62,66 **** public virtual object PostProcessAfterInitialization( ! object obj, string name) { return obj; --- 62,66 ---- public virtual object PostProcessAfterInitialization( ! object obj, string objectName) { return obj; |
From: Mark P. <mar...@us...> - 2007-08-22 08:50:03
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Context/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13940 Modified Files: AbstractApplicationContextTests.cs XmlApplicationContextTests.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: XmlApplicationContextTests.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContextTests.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** XmlApplicationContextTests.cs 31 Jul 2007 18:19:41 -0000 1.12 --- XmlApplicationContextTests.cs 22 Aug 2007 08:49:57 -0000 1.13 *************** *** 280,286 **** /// </summary> /// <param name="obj">object to process</param> ! /// <param name="name">name of object</param> /// <returns>processed object</returns> ! public object PostProcessAfterInitialization(object obj, string name) { return obj; --- 280,286 ---- /// </summary> /// <param name="obj">object to process</param> ! /// <param name="objectName">name of object</param> /// <returns>processed object</returns> ! public object PostProcessAfterInitialization(object obj, string objectName) { return obj; Index: AbstractApplicationContextTests.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Context/Support/AbstractApplicationContextTests.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractApplicationContextTests.cs 19 Jul 2007 12:58:52 -0000 1.7 --- AbstractApplicationContextTests.cs 22 Aug 2007 08:49:57 -0000 1.8 *************** *** 262,266 **** } ! public object PostProcessAfterInitialization(object instance, string name) { Assert.AreNotEqual(this, instance); --- 262,266 ---- } ! public object PostProcessAfterInitialization(object instance, string objectName) { Assert.AreNotEqual(this, instance); |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:55
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Data/Spring/Aop/Framework/AutoProxy In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13927 Modified Files: advisorAutoProxyCreator.xml Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: advisorAutoProxyCreator.xml =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Data/Spring/Aop/Framework/AutoProxy/advisorAutoProxyCreator.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** advisorAutoProxyCreator.xml 19 Jul 2007 16:34:28 -0000 1.2 --- advisorAutoProxyCreator.xml 22 Aug 2007 08:49:51 -0000 1.3 *************** *** 17,21 **** The LTCRegExpAdvisor's order value is 10. --> ! <object id="orderedBeforeLTCSet" type="Spring.Aop.Framework.AutoProxy.OrderedLogicalThreadContextCheckAdvisor, Spring.Aop.Tests"> <property name="Order" value="9"/> --- 17,21 ---- The LTCRegExpAdvisor's order value is 10. --> ! <object id="orderedBeforeLTCSet" type="Spring.Aop.Framework.AutoProxy.OrderedLogicalThreadContextCheckAdvisor, Spring.Aop.Tests"> <property name="Order" value="9"/> *************** *** 40,44 **** <property name="Order" value="10"/> </object> ! <object id="CountingAdvice" type="Spring.Aop.Framework.CountingAfterReturningAdvice, Spring.Aop.Tests"/> --- 40,44 ---- <property name="Order" value="10"/> </object> ! <object id="CountingAdvice" type="Spring.Aop.Framework.CountingAfterReturningAdvice, Spring.Aop.Tests"/> *************** *** 52,67 **** <property name="Age" value="4"/> </object> ! <object id="otherTestObject" type="Spring.Objects.TestObject, Spring.Core.Tests"> <property name="Name" value="OtherSimpleTestObject"/> <property name="Age" value="2"/> </object> ! <object id="testObjectFactory" type="Spring.Objects.Factory.DummyFactory"> <property name="otherTestObject" ref="otherTestObject" /> </object> <object id="noSetterPropertiesObject" type="Spring.Aop.Framework.AutoProxy.NoSetterProperties, Spring.Aop.Tests"/> ! </objects> \ No newline at end of file --- 52,70 ---- <property name="Age" value="4"/> </object> ! ! <object id="otherTestObject" type="Spring.Objects.TestObject, Spring.Core.Tests"> <property name="Name" value="OtherSimpleTestObject"/> <property name="Age" value="2"/> </object> ! ! <object id="testObjectFactory" type="Spring.Objects.Factory.DummyFactory"> <property name="otherTestObject" ref="otherTestObject" /> </object> + <object id="noSetterPropertiesObject" type="Spring.Aop.Framework.AutoProxy.NoSetterProperties, Spring.Aop.Tests"/> ! </objects> \ No newline at end of file |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:49
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13911 Modified Files: ReflectionUtils.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: ReflectionUtils.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/ReflectionUtils.cs,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ReflectionUtils.cs 8 Aug 2007 08:25:35 -0000 1.47 --- ReflectionUtils.cs 22 Aug 2007 08:49:46 -0000 1.48 *************** *** 637,653 **** public static bool HasAtLeastOneMethodWithName(Type type, string name) { ! if (type == null || ! StringUtils.IsNullOrEmpty(name)) ! { ! return false; ! } ! MemberInfo[] methods = type.FindMembers( ! MemberTypes.Method, ! ReflectionUtils.AllMembersCaseInsensitiveFlags, ! new MemberFilter(ReflectionUtils.MethodNameFilter), ! name); ! return methods.Length > 0; } private static bool MethodNameFilter(MemberInfo member, object criteria) { --- 637,659 ---- public static bool HasAtLeastOneMethodWithName(Type type, string name) { ! if (type == null || StringUtils.IsNullOrEmpty(name)) ! { ! return false; ! } ! return MethodCountForName(type, name) > 0; } + public static int MethodCountForName(Type type, string name) + { + AssertUtils.ArgumentNotNull(type, "type", "Type must not be null"); + AssertUtils.ArgumentNotNull(name, "name", "Method name must not be null"); + MemberInfo[] methods = type.FindMembers( + MemberTypes.Method, + ReflectionUtils.AllMembersCaseInsensitiveFlags, + new MemberFilter(ReflectionUtils.MethodNameFilter), + name); + return methods.Length; + } + private static bool MethodNameFilter(MemberInfo member, object criteria) { |
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13890/Support Modified Files: AbstractAutowireCapableObjectFactory.cs AbstractObjectDefinition.cs AbstractObjectFactory.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: AbstractObjectDefinition.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectDefinition.cs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** AbstractObjectDefinition.cs 2 Aug 2007 12:09:31 -0000 1.29 --- AbstractObjectDefinition.cs 22 Aug 2007 08:49:39 -0000 1.30 *************** *** 634,639 **** protected void PrepareMethodOverride(MethodOverride methodOverride) { ! if (!ReflectionUtils.HasAtLeastOneMethodWithName(ObjectType, methodOverride.MethodName)) ! { throw new ObjectDefinitionValidationException( string.Format( --- 634,640 ---- protected void PrepareMethodOverride(MethodOverride methodOverride) { ! if (!ReflectionUtils.HasAtLeastOneMethodWithName(ObjectType, methodOverride.MethodName)) ! { ! throw new ObjectDefinitionValidationException( string.Format( *************** *** 642,645 **** --- 643,651 ---- methodOverride.MethodName, ObjectTypeName)); } + //TODO investigate setting overloaded at this point using MethodCountForName... + //Test SunnyDayReplaceMethod_WithArgumentAcceptingReplacerWithNoTypeFragmentsSpecified + // will fail if doing this optimization. + + } Index: AbstractAutowireCapableObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** AbstractAutowireCapableObjectFactory.cs 7 Aug 2007 16:24:26 -0000 1.79 --- AbstractAutowireCapableObjectFactory.cs 22 Aug 2007 08:49:39 -0000 1.80 *************** *** 431,435 **** --- 431,474 ---- protected void PopulateObject(string name, RootObjectDefinition definition, IObjectWrapper wrapper) { + // Give any InstantiationAwareBeanPostProcessors the opportunity to modify the + // state of the bean before properties are set. This can be used, for example, + // to support styles of field injection. + bool continueWithPropertyPopulation = true; + + if (HasInstantiationAwareBeanPostProcessors) + { + foreach (IObjectPostProcessor processor in ObjectPostProcessors) + { + IInstantiationAwareObjectPostProcessor inProc = processor as IInstantiationAwareObjectPostProcessor; + if (inProc != null) + { + if (!inProc.PostProcessAfterInstantiation(wrapper.WrappedInstance, name)) + { + continueWithPropertyPopulation = false; + break; + } + } + } + } + if (!continueWithPropertyPopulation) + { + return; + } + IPropertyValues properties = definition.PropertyValues; + + if (wrapper == null) + { + if (properties.PropertyValues.Length > 0) + { + throw new ObjectCreationException(name, "Cannot apply property values to null instance"); + } + else + { + // skip property population phase for null instance + return; + } + } + if (definition.ResolvedAutowireMode == AutoWiringMode.ByName || definition.ResolvedAutowireMode == AutoWiringMode.ByType) { *************** *** 447,451 **** properties = mpvs; } ! DependencyCheck(name, definition, wrapper, properties); ApplyPropertyValues(name, definition, wrapper, properties); } --- 486,525 ---- properties = mpvs; } ! //DependencyCheck(name, definition, wrapper, properties); ! ! ! bool hasInstAwareOpps = HasInstantiationAwareBeanPostProcessors; ! bool needsDepCheck = (definition.DependencyCheck != DependencyCheckingMode.None); ! ! ! if (hasInstAwareOpps || needsDepCheck) ! { ! PropertyInfo[] filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); ! if (HasInstantiationAwareBeanPostProcessors) ! { ! foreach (IObjectPostProcessor processor in ObjectPostProcessors) ! { ! IInstantiationAwareObjectPostProcessor instantiationAwareObjectPostProcessor = ! processor as IInstantiationAwareObjectPostProcessor; ! if (instantiationAwareObjectPostProcessor != null) ! { ! properties = ! instantiationAwareObjectPostProcessor.PostProcessPropertyValues(properties, filteredPropInfo, wrapper.WrappedInstance, ! name); ! if (properties == null) ! { ! return; ! } ! } ! } ! } ! ! if (needsDepCheck) ! { ! CheckDependencies(name, definition, filteredPropInfo, properties); ! } ! ! } ! ApplyPropertyValues(name, definition, wrapper, properties); } *************** *** 701,711 **** protected virtual object CreateObject(string name, RootObjectDefinition definition, object[] arguments, bool allowEagerCaching) { ! // Make sure object type is actually resolved at this point. ! ResolveObjectType(definition, name); ! ! // return IObjectDefinition instance itself for an abstract object-definition ! if (definition.IsTemplate) { ! return definition; } --- 775,785 ---- protected virtual object CreateObject(string name, RootObjectDefinition definition, object[] arguments, bool allowEagerCaching) { ! // guarantee the initialization of objects that the current one depends on.. ! if (definition.DependsOn != null) { ! foreach (string dependant in definition.DependsOn) ! { ! GetObject(dependant); ! } } *************** *** 719,763 **** #endregion ! object instance = null; ! // Give IInstantiationAwareObjectPostProcessors a chance to return a proxy instead of the target instance.... ! if (definition.HasObjectType) { ! instance = ApplyObjectPostProcessorsBeforeInstantiation(definition.ObjectType, name); ! if (instance != null) ! { ! return instance; ! } } ! // guarantee the initialization of objects that the current one depends on.. ! foreach (string dependant in definition.DependsOn) { ! GetObject(dependant); } IObjectWrapper instanceWrapper = null; bool eagerlyCached = false; try { ! if (StringUtils.HasText(definition.FactoryMethodName)) ! { ! instanceWrapper = InstantiateUsingFactoryMethod(name, definition, arguments); ! } ! //Handle case when arguments are passed in explicitly. ! else if (arguments != null && arguments.Length > 0) ! { ! instanceWrapper = AutowireConstructor(name, definition, arguments); ! } ! else if (definition.ResolvedAutowireMode == AutoWiringMode.Constructor || definition.HasConstructorArgumentValues) ! { ! instanceWrapper = AutowireConstructor(name, definition); ! } ! else { ! instanceWrapper = new ObjectWrapper(InstantiationStrategy.Instantiate(definition, name, this)); ! InitObjectWrapper(instanceWrapper); } instance = instanceWrapper.WrappedInstance; // eagerly cache singletons to be able to resolve circular references // even when triggered by lifecycle interfaces like IObjectFactoryAware. --- 793,838 ---- #endregion ! // Make sure object type is actually resolved at this point. ! ResolveObjectType(definition, name); ! try { ! definition.PrepareMethodOverrides(); ! } ! catch (ObjectDefinitionValidationException ex) ! { ! throw new ObjectDefinitionStoreException(definition.ResourceDescription, name, ! "Validation of method overrides failed. " + ex.Message, ex); } ! // return IObjectDefinition instance itself for an abstract object-definition ! if (definition.IsTemplate) { ! return definition; } + + + object instance = null; + + IObjectWrapper instanceWrapper = null; bool eagerlyCached = false; try { ! // Give IInstantiationAwareObjectPostProcessors a chance to return a proxy instead of the target instance.... ! if (definition.HasObjectType) { ! instance = ApplyObjectPostProcessorsBeforeInstantiation(definition.ObjectType, name); ! if (instance != null) ! { ! return instance; ! } } + + + instanceWrapper = CreateObjectInstance(name, definition, arguments); instance = instanceWrapper.WrappedInstance; + // eagerly cache singletons to be able to resolve circular references // even when triggered by lifecycle interfaces like IObjectFactoryAware. *************** *** 793,796 **** --- 868,895 ---- } + protected IObjectWrapper CreateObjectInstance(string name, RootObjectDefinition definition, object[] arguments) + { + IObjectWrapper instanceWrapper; + if (StringUtils.HasText(definition.FactoryMethodName)) + { + instanceWrapper = InstantiateUsingFactoryMethod(name, definition, arguments); + } + //Handle case when arguments are passed in explicitly. + else if (arguments != null && arguments.Length > 0) + { + instanceWrapper = AutowireConstructor(name, definition, arguments); + } + else if (definition.ResolvedAutowireMode == AutoWiringMode.Constructor || definition.HasConstructorArgumentValues) + { + instanceWrapper = AutowireConstructor(name, definition); + } + else + { + instanceWrapper = new ObjectWrapper(InstantiationStrategy.Instantiate(definition, name, this)); + InitObjectWrapper(instanceWrapper); + } + return instanceWrapper; + } + /// <summary> /// Instantiate an object instance using a named factory method. *************** *** 1307,1315 **** return; } ! ISet ignoreTypes = IgnoredDependencyTypes; ! PropertyInfo[] pds = wrapper.GetPropertyInfos(); ! foreach (PropertyInfo property in pds) { ! if (property.CanWrite && !ignoreTypes.Contains(property.PropertyType) && properties.GetPropertyValue(property.Name) == null) { bool isSimple = ObjectUtils.IsSimpleProperty(property.PropertyType); --- 1406,1438 ---- return; } ! ! PropertyInfo[] filteredPropInfo = FilterPropertyInfoForDependencyCheck(wrapper); ! if (HasInstantiationAwareBeanPostProcessors) { ! foreach (IObjectPostProcessor processor in ObjectPostProcessors) ! { ! IInstantiationAwareObjectPostProcessor inProc = processor as IInstantiationAwareObjectPostProcessor; ! if (inProc != null) ! { ! properties = ! inProc.PostProcessPropertyValues(properties, filteredPropInfo, wrapper.WrappedInstance, name); ! if (properties == null) ! { ! return; ! } ! } ! } ! } ! ! ! CheckDependencies(name, definition, filteredPropInfo, properties); ! } ! ! private static void CheckDependencies(string name, IConfigurableObjectDefinition definition, PropertyInfo[] filteredPropInfo, IPropertyValues properties) ! { ! DependencyCheckingMode dependencyCheck = definition.DependencyCheck; ! foreach (PropertyInfo property in filteredPropInfo) ! { ! if (property.CanWrite && properties.GetPropertyValue(property.Name) == null) { bool isSimple = ObjectUtils.IsSimpleProperty(property.PropertyType); *************** *** 1318,1325 **** if (unsatisfied) { ! throw new UnsatisfiedDependencyException(string.Empty, name, property.Name, null); } } } } --- 1441,1485 ---- if (unsatisfied) { ! throw new UnsatisfiedDependencyException(definition.ResourceDescription, name, property.Name, ! "Set this property value or disable dependency checking for this object."); ! } ! } ! } ! } ! ! /// <summary> ! /// Extract a filtered set of PropertyInfos from the given IObjectWrapper, excluding ! /// ignored dependency types. ! /// </summary> ! /// <param name="wrapper">The object wrapper the object was created with.</param> ! /// <returns>The filtered PropertyInfos</returns> ! private PropertyInfo[] FilterPropertyInfoForDependencyCheck(IObjectWrapper wrapper) ! { ! lock (filteredPropertyDescriptorsCache) ! { ! PropertyInfo[] filtered = (PropertyInfo[]) filteredPropertyDescriptorsCache[wrapper.WrappedType]; ! if (filtered == null) ! { ! ! ArrayList list = new ArrayList(wrapper.GetPropertyInfos()); ! for (int i = list.Count -1 ; i >= 0; i--) ! { ! PropertyInfo pi = (PropertyInfo) list[i]; ! if (IsExcludedFromDependencyCheck(pi)) ! { ! list.RemoveAt(i); ! } } + filtered = (PropertyInfo[]) list.ToArray(typeof(PropertyInfo)); + filteredPropertyDescriptorsCache.Add(wrapper.WrappedType, filtered); } + return filtered; } + + } + + private bool IsExcludedFromDependencyCheck(PropertyInfo pi) + { + return IgnoredDependencyTypes.Contains(pi.PropertyType); } *************** *** 1937,1940 **** --- 2097,2101 ---- } + #endregion *************** *** 2110,2113 **** --- 2271,2284 ---- private IInstantiationStrategy instantiationStrategy = new MethodInjectingInstantiationStrategy(); + /// <summary> + /// Cache of unfinished IFactoryObject instances: IFactoryObject name --> IObjectWrapper */ + /// </summary> + private IDictionary factoryObjectInstanceCache = new Hashtable(); + + /// <summary> + /// Cache of filtered PropertyInfos: object Type -> PropertyInfo array + /// </summary> + private IDictionary filteredPropertyDescriptorsCache = new Hashtable(); + #endregion } Index: AbstractObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** AbstractObjectFactory.cs 7 Aug 2007 16:24:26 -0000 1.68 --- AbstractObjectFactory.cs 22 Aug 2007 08:49:39 -0000 1.69 *************** *** 174,177 **** --- 174,188 ---- } + + protected bool HasInstantiationAwareBeanPostProcessors + { + get { return hasInstantiationAwareBeanPostProcessors; } + } + + protected bool HasDestructionAwareBeanPostProcessors + { + get { return hasDestructionAwareBeanPostProcessors; } + } + #endregion *************** *** 1297,1303 **** --- 1308,1333 ---- #region Fields + /// <summary> + /// Parent object factory, for object inheritance support + /// </summary> private IObjectFactory parentObjectFactory; + private ISet ignoreDependencyTypes = new HybridSet(); + + /// <summary> + /// ObjectPostProcessors to apply in CreateObject + /// </summary> private IList objectPostProcessors = new ArrayList(); + + /// <summary> + /// Indicates whether any IInstantiationAwareBeanPostProcessors have been registered + /// </summary> + private bool hasInstantiationAwareBeanPostProcessors; + + /// <summary> + /// Indicates whether any IDestructionAwareBeanPostProcessors have been registered + /// </summary> + private bool hasDestructionAwareBeanPostProcessors; + private IDictionary aliasMap; private IDictionary singletonCache; *************** *** 1324,1327 **** --- 1354,1358 ---- #region IObjectFactory Members + /// <summary> /// Is this object a singleton? *************** *** 1331,1375 **** { string objectName = TransformedObjectName(name); ! try { ! Type objectClass = null; ! bool singleton = true; ! object objectInstance = this.GetSingleton(objectName); ! if (objectInstance != null && !IsSingletonCurrentlyInCreation(objectName)) { ! objectClass = objectInstance.GetType(); ! singleton = true; } else { ! RootObjectDefinition rootDefinition = GetMergedObjectDefinition(objectName, false); ! if (rootDefinition != null) { ! if (rootDefinition.HasObjectType) { ! objectClass = rootDefinition.ObjectType; } ! singleton = rootDefinition.IsSingleton; } } ! // in the case of an IFactoryObject, return the singleton status of the ! // created object if not a dereference... ! if (objectClass != null && typeof(IFactoryObject).IsAssignableFrom(objectClass) && ! !IsFactoryDereference(name)) ! { ! IFactoryObject factoryObject = GetFactoryObject(name); ! return factoryObject.IsSingleton; ! } ! return singleton; ! } ! catch (NoSuchObjectDefinitionException) ! { ! // Not found -> check parent. ! if (ParentObjectFactory != null) { ! return ParentObjectFactory.IsSingleton(objectName); } ! throw; ! } } --- 1362,1412 ---- { string objectName = TransformedObjectName(name); ! object objectInstance = this.GetSingleton(objectName); ! if (objectInstance != null) { ! IFactoryObject factoryObject = objectInstance as IFactoryObject; ! if (factoryObject != null) { ! return IsFactoryDereference(name) || factoryObject.IsSingleton; } else { ! return !IsFactoryDereference(name); ! } ! } ! else ! { ! // No singleton instance found -> check object definition ! IObjectFactory pof = ParentObjectFactory; ! if (pof != null && !ContainsObjectDefinition(objectName)) ! { ! // No object definition found in this factory -> delegate to parent ! return pof.IsSingleton(OriginalObjectName(name)); ! } ! RootObjectDefinition od = GetMergedObjectDefinition(objectName, false); ! ! // In case of IFactoryObject, return singleton status of created object if not a dereference ! if (od.IsSingleton) ! { ! if (IsObjectTypeMatch(objectName, od, typeof(IFactoryObject))) { ! if (IsFactoryDereference(name)) { ! return true; } ! IFactoryObject factoryObject = ! (IFactoryObject) GetObject(ObjectFactoryUtils.BuildFactoryObjectName(objectName)); ! return factoryObject.IsSingleton; ! } ! else ! { ! return !IsFactoryDereference(name); } } ! else { ! return false; } ! } } *************** *** 1763,1766 **** --- 1800,1812 ---- ObjectPostProcessors.Add(objectPostProcessor); } + if (typeof (IInstantiationAwareObjectPostProcessor).IsInstanceOfType(objectPostProcessor)) + { + hasInstantiationAwareBeanPostProcessors = true; + } + if (typeof (IDestructionAwareObjectPostProcessor).IsInstanceOfType(objectPostProcessor)) + { + hasDestructionAwareBeanPostProcessors = true; + } + } |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:43
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13890/Config Modified Files: IInstantiationAwareObjectPostProcessor.cs IObjectPostProcessor.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: IInstantiationAwareObjectPostProcessor.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/IInstantiationAwareObjectPostProcessor.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IInstantiationAwareObjectPostProcessor.cs 30 Jul 2007 18:00:00 -0000 1.3 --- IInstantiationAwareObjectPostProcessor.cs 22 Aug 2007 08:49:39 -0000 1.4 *************** *** 20,23 **** --- 20,24 ---- using System; + using System.Reflection; using Spring.Objects.Factory.Support; *************** *** 86,89 **** --- 87,125 ---- /// <seealso cref="IConfigurableObjectDefinition.FactoryMethodName"/> object PostProcessBeforeInstantiation(Type objectType, string objectName); + + + /// <summary> + /// Perform operations after the object has been instantiated, via a constructor or factory method, + /// but before Spring property population (from explicit properties or autowiring) occurs. + /// </summary> + /// <param name="objectInstance">The object instance created, but whose properties have not yet been set</param> + /// <param name="objectName">Name of the object.</param> + /// <returns>true if properties should be set on the object; false if property population + /// should be skipped. Normal implementations should return true. Returning false will also + /// prevent any subsequent InstantiationAwareObjectPostProcessor instances from being + /// invoked on this object instance.</returns> + bool PostProcessAfterInstantiation(object objectInstance, string objectName); + + /// <summary> + /// Post-process the given property values before the factory applies them + /// to the given object. + /// </summary> + /// <remarks>Allows for checking whether all dependencies have been + /// satisfied, for example based on a "Required" annotation on bean property setters. + /// <para>Also allows for replacing the property values to apply, typically through + /// creating a new MutablePropertyValues instance based on the original PropertyValues, + /// adding or removing specific values. + /// </para> + /// </remarks> + /// <param name="pvs">The property values that the factory is about to apply (never <code>null</code>).</param> + /// <param name="pis">he relevant property infos for the target object (with ignored + /// dependency types - which the factory handles specifically - already filtered out)</param> + /// <param name="objectInstance">The object instance created, but whose properties have not yet + /// been set.</param> + /// <param name="objectName">Name of the object.</param> + /// <returns>The actual property values to apply to the given object (can be the + /// passed-in PropertyValues instances0 or null to skip property population.</returns> + IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, + string objectName); } } Index: IObjectPostProcessor.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/IObjectPostProcessor.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IObjectPostProcessor.cs 9 Apr 2006 07:18:47 -0000 1.8 --- IObjectPostProcessor.cs 22 Aug 2007 08:49:39 -0000 1.9 *************** *** 86,90 **** /// The new object instance. /// </param> ! /// <param name="name"> /// The name of the object. /// </param> --- 86,90 ---- /// The new object instance. /// </param> ! /// <param name="objectName"> /// The name of the object. /// </param> *************** *** 95,99 **** /// In case of errors. /// </exception> ! object PostProcessAfterInitialization(object instance, string name); } } \ No newline at end of file --- 95,99 ---- /// In case of errors. /// </exception> ! object PostProcessAfterInitialization(object instance, string objectName); } } \ No newline at end of file |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:30
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Context/Support In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13878 Modified Files: AbstractApplicationContext.cs ApplicationContextAwareProcessor.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: ApplicationContextAwareProcessor.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Context/Support/ApplicationContextAwareProcessor.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ApplicationContextAwareProcessor.cs 9 Apr 2006 07:18:38 -0000 1.7 --- ApplicationContextAwareProcessor.cs 22 Aug 2007 08:49:26 -0000 1.8 *************** *** 91,95 **** /// The new object instance. /// </param> ! /// <param name="name"> /// The name of the object. /// </param> --- 91,95 ---- /// The new object instance. /// </param> ! /// <param name="objectName"> /// The name of the object. /// </param> *************** *** 101,105 **** /// </exception> /// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessAfterInitialization"/> ! public object PostProcessAfterInitialization(object obj, string name) { return obj; --- 101,105 ---- /// </exception> /// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessAfterInitialization"/> ! public object PostProcessAfterInitialization(object obj, string objectName) { return obj; Index: AbstractApplicationContext.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** AbstractApplicationContext.cs 8 Aug 2007 17:46:37 -0000 1.72 --- AbstractApplicationContext.cs 22 Aug 2007 08:49:26 -0000 1.73 *************** *** 1727,1731 **** } ! public object PostProcessAfterInitialization(object obj, string name) { if (_objectFactory.ObjectPostProcessorCount < _objectPostProcessorTargetCount) --- 1727,1731 ---- } ! public object PostProcessAfterInitialization(object obj, string objectName) { if (_objectFactory.ObjectPostProcessorCount < _objectPostProcessorTargetCount) *************** *** 1737,1741 **** log.Info(string.Format( "Object '{0}' is not eligible for being processed by all " + ! "IObjectPostProcessors (for example: not eligible for auto-proxying).", name)); } --- 1737,1741 ---- log.Info(string.Format( "Object '{0}' is not eligible for being processed by all " + ! "IObjectPostProcessors (for example: not eligible for auto-proxying).", objectName)); } |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:22
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13865 Modified Files: AbstractPrototypeTargetSourceCreator.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: AbstractPrototypeTargetSourceCreator.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/Target/AbstractPrototypeTargetSourceCreator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractPrototypeTargetSourceCreator.cs 13 Nov 2006 07:04:34 -0000 1.3 --- AbstractPrototypeTargetSourceCreator.cs 22 Aug 2007 08:49:19 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- #region Imports + using System; using Common.Logging; using Spring.Aop.Target; *************** *** 45,49 **** /// Create a special TargetSource for the given object, if any. /// </summary> ! /// <param name="obj">the object to create a TargetSource for</param> /// <param name="name">the name of the object</param> /// <param name="factory">the containing factory</param> --- 46,50 ---- /// Create a special TargetSource for the given object, if any. /// </summary> ! /// <param name="objectType">the type of the object to create a TargetSource for</param> /// <param name="name">the name of the object</param> /// <param name="factory">the containing factory</param> *************** *** 52,58 **** /// interested in the particular object /// </returns> ! public ITargetSource GetTargetSource(object obj, string name, IObjectFactory factory) { ! AbstractPrototypeTargetSource prototypeTargetSource = CreatePrototypeTargetSource(obj, name, factory); if (prototypeTargetSource == null) { --- 53,59 ---- /// interested in the particular object /// </returns> ! public ITargetSource GetTargetSource(Type objectType, string name, IObjectFactory factory) { ! AbstractPrototypeTargetSource prototypeTargetSource = CreatePrototypeTargetSource(objectType, name, factory); if (prototypeTargetSource == null) { *************** *** 96,104 **** /// Creates the prototype target source. /// </summary> ! /// <param name="obj">The obj.</param> /// <param name="name">The name.</param> /// <param name="factory">The factory.</param> /// <returns></returns> ! protected abstract AbstractPrototypeTargetSource CreatePrototypeTargetSource(object obj, string name, IObjectFactory factory); --- 97,105 ---- /// Creates the prototype target source. /// </summary> ! /// <param name="objectType">The type of the object to create a target source for.</param> /// <param name="name">The name.</param> /// <param name="factory">The factory.</param> /// <returns></returns> ! protected abstract AbstractPrototypeTargetSource CreatePrototypeTargetSource(Type objectType, string name, IObjectFactory factory); |
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13590/AutoProxy Modified Files: AbstractAdvisorAutoProxyCreator.cs AbstractAutoProxyCreator.cs ITargetSourceCreator.cs ObjectNameAutoProxyCreator.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: AbstractAdvisorAutoProxyCreator.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAdvisorAutoProxyCreator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractAdvisorAutoProxyCreator.cs 1 Aug 2007 17:51:45 -0000 1.4 --- AbstractAdvisorAutoProxyCreator.cs 22 Aug 2007 08:49:08 -0000 1.5 *************** *** 79,83 **** /// advices (e.g. AOP Alliance interceptors) and advisors to apply. /// </summary> ! /// <param name="obj">the new object instance</param> /// <param name="name">the name of the object</param> /// <param name="customTargetSource">targetSource returned by TargetSource property: --- 79,83 ---- /// advices (e.g. AOP Alliance interceptors) and advisors to apply. /// </summary> ! /// <param name="objType">the new object instance</param> /// <param name="name">the name of the object</param> /// <param name="customTargetSource">targetSource returned by TargetSource property: *************** *** 96,102 **** /// add it to existing implementations of this method.</p> /// </remarks> ! protected override object[] GetAdvicesAndAdvisorsForObject(object obj, string name, ITargetSource customTargetSource) { ! IList advisors = FindEligibleAdvisors(obj.GetType()); if (advisors.Count == 0) { --- 96,102 ---- /// add it to existing implementations of this method.</p> /// </remarks> ! protected override object[] GetAdvicesAndAdvisorsForObject(Type objType, string name, ITargetSource customTargetSource) { ! IList advisors = FindEligibleAdvisors(objType); if (advisors.Count == 0) { Index: AbstractAutoProxyCreator.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/AbstractAutoProxyCreator.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractAutoProxyCreator.cs 3 Aug 2007 14:38:30 -0000 1.10 --- AbstractAutoProxyCreator.cs 22 Aug 2007 08:49:08 -0000 1.11 *************** *** 23,27 **** using System; using System.Collections; ! using AopAlliance.Aop; using AopAlliance.Intercept; --- 23,27 ---- using System; using System.Collections; ! using System.Reflection; using AopAlliance.Aop; using AopAlliance.Intercept; *************** *** 30,34 **** --- 30,36 ---- using Spring.Aop.Support; using Spring.Aop.Target; + using Spring.Collections; using Spring.Core; + using Spring.Objects; using Spring.Objects.Factory; using Spring.Objects.Factory.Config; *************** *** 71,75 **** /// <seealso cref="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator"/> /// <version>$Id$</version> ! public abstract class AbstractAutoProxyCreator : ProxyConfig, IObjectPostProcessor, IObjectFactoryAware, IOrdered { #region Protected Fields --- 73,77 ---- /// <seealso cref="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator"/> /// <version>$Id$</version> ! public abstract class AbstractAutoProxyCreator : ProxyConfig, IInstantiationAwareObjectPostProcessor, IObjectFactoryAware, IOrdered { #region Protected Fields *************** *** 95,99 **** --- 97,108 ---- #region Private Fields + /// <summary> + /// Default value is same as non-ordered + /// </summary> private int order = int.MaxValue; + + /// <summary> + /// Default is global AdvisorAdapterRegistry + /// </summary> private IAdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance; *************** *** 110,113 **** --- 119,133 ---- private IObjectFactory owningObjectFactory; + /// <summary> + /// Set of object type + name strings, referring to all objects that this auto-proxy + /// creator created a custom TargetSource for. Used to detect own pre-built proxies + /// (from "PostProcessBeforeInstantiation") in the "PostProcessAfterInitialization" method. + /// </summary> + private ISet targetSourcedObjects = new SynchronizedSet(new HashedSet()); + + private ISet advisedObjects = new SynchronizedSet(new HashedSet()); + + private ISet nonAdvisedObjects = new SynchronizedSet(new HashedSet()); + #endregion *************** *** 185,191 **** /// identified as one to proxy by the subclass. /// </summary> ! public virtual object PostProcessAfterInitialization(object obj, string name) { ! if (IsInfrastructureType(obj, name) || ShouldSkip(obj, name)) { #region Instrumentation --- 205,221 ---- /// identified as one to proxy by the subclass. /// </summary> ! public virtual object PostProcessAfterInitialization(object obj, string objectName) { ! if (targetSourcedObjects.Contains(objectName)) ! { ! return obj; ! } ! ! object cacheKey = GetCacheKey(obj.GetType(), objectName); ! if (nonAdvisedObjects.Contains(cacheKey)) ! { ! return obj; ! } ! if (IsInfrastructureType(obj.GetType(), objectName) || ShouldSkip(obj.GetType(), objectName)) { #region Instrumentation *************** *** 198,268 **** #endregion return obj; } - ITargetSource targetSource = GetCustomTargetSource(obj, name); ! object[] specificInterceptors = GetAdvicesAndAdvisorsForObject(obj, name, targetSource); // proxy if we have advice or if a TargetSourceCreator wants to do some // fancy stuff such as pooling ! if (specificInterceptors != DO_NOT_PROXY || targetSource != null) ! { ! if (targetSource == null) ! { ! // use default of simple, default target source ! targetSource = new SingletonTargetSource(obj); ! } ! ! // handle prototypes correctly ! IAdvisor[] commonInterceptors = ResolveInterceptorNames(); ! ! ArrayList allInterceptors = new ArrayList(); ! if (specificInterceptors != null) ! { ! allInterceptors.AddRange(specificInterceptors); ! if (commonInterceptors != null) ! { ! if (applyCommonInterceptorsFirst) ! { ! allInterceptors.InsertRange(0, commonInterceptors); ! } ! else ! { ! allInterceptors.AddRange(commonInterceptors); ! } ! } ! } ! if (logger.IsInfoEnabled) ! { ! int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Length : 0; ! int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Length : 0; ! logger.Info(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", name, nrOfCommonInterceptors, nrOfSpecificInterceptors)); ! } ! ! ProxyFactory proxyFactory = new ProxyFactory(); ! // copy our properties (proxyTargetClass) inherited from ProxyConfig ! proxyFactory.CopyFrom(this); ! ! foreach (object o in allInterceptors) ! { ! IAdvisor advisor = advisorAdapterRegistry.Wrap(o); ! if (advisor is IIntroductionAdvisor) ! { ! proxyFactory.AddIntroduction((IIntroductionAdvisor)advisor); ! } ! else ! { ! proxyFactory.AddAdvisor(advisor); ! } ! } ! proxyFactory.TargetSource = targetSource; ! CustomizeProxyFactory(obj, proxyFactory); ! ! return proxyFactory.GetProxy(); ! } ! else { ! return obj; } } --- 228,248 ---- #endregion + nonAdvisedObjects.Add(cacheKey); return obj; } ! //ITargetSource targetSource = GetCustomTargetSource(obj.GetType(), objectName); ! ! object[] specificInterceptors = GetAdvicesAndAdvisorsForObject(obj.GetType(), objectName, null); // proxy if we have advice or if a TargetSourceCreator wants to do some // fancy stuff such as pooling ! if (specificInterceptors != DO_NOT_PROXY) { ! advisedObjects.Add(cacheKey); ! return CreateProxy(obj.GetType(), objectName, specificInterceptors, new SingletonTargetSource(obj)); } + nonAdvisedObjects.Add(cacheKey); + return obj; } *************** *** 335,342 **** /// a circular reference. This implementation returns true. /// </summary> ! /// <param name="obj">the new object instance</param> ! /// <param name="name">the name of the object</param> /// <returns>if remarkable to skip</returns> ! protected virtual bool ShouldSkip(object obj, string name) { return false; --- 315,322 ---- /// a circular reference. This implementation returns true. /// </summary> ! /// <param name="objectType">the type of the object</param> ! /// <param name="objectName">the name of the object</param> /// <returns>if remarkable to skip</returns> ! protected virtual bool ShouldSkip(Type objectType, string objectName) { return false; *************** *** 347,375 **** /// to change the interfaces exposed /// </summary> - /// <param name="obj">object about to be autoproxied.</param> /// <param name="pf"> /// ProxyFactory that will be used to create the proxy immediably after this method returns. /// </param> ! protected virtual void CustomizeProxyFactory(object obj, ProxyFactory pf) { // This implementation does nothing } /// <summary> /// Determines whether the object is an infrastructure type, /// IAdvisor, IAdvice, IAspect, AbstractAutoProxyCreator /// </summary> ! /// <param name="obj">The object.</param> ! /// <param name="name">The name.</param> /// <returns> /// <c>true</c> if [is infrastructure type] [the specified obj]; otherwise, <c>false</c>. /// </returns> ! protected virtual bool IsInfrastructureType(object obj, String name) { ! return ((obj is IAdvisor) ! || (obj is IAdvice) ! || (obj is IAdvisors) ! || (obj is AbstractAutoProxyCreator)); } /// <summary> --- 327,364 ---- /// to change the interfaces exposed /// </summary> /// <param name="pf"> /// ProxyFactory that will be used to create the proxy immediably after this method returns. /// </param> ! protected virtual void CustomizeProxyFactory(ProxyFactory pf) { // This implementation does nothing } + /* + protected virtual bool IsInfrastructureType(object obj, String name) + { + return ((obj is IAdvisor) + || (obj is IAdvice) + || (obj is IAdvisors) + || (obj is AbstractAutoProxyCreator)); + }*/ + /// <summary> /// Determines whether the object is an infrastructure type, /// IAdvisor, IAdvice, IAspect, AbstractAutoProxyCreator /// </summary> ! /// <param name="type">The object type to compare</param> ! /// <param name="name">The name of the object</param> /// <returns> /// <c>true</c> if [is infrastructure type] [the specified obj]; otherwise, <c>false</c>. /// </returns> ! protected virtual bool IsInfrastructureType(Type type, String name) { ! return typeof (IAdvisor).IsAssignableFrom(type) ! || typeof (IAdvice).IsAssignableFrom(type) ! || typeof (IAdvisors).IsAssignableFrom(type) ! || typeof (AbstractAutoProxyCreator).IsAssignableFrom(type); } + /// <summary> *************** *** 380,397 **** /// Subclasses can override this method to use a different mechanism. /// </summary> ! /// <param name="obj">the new object instance</param> /// <param name="name">the name of the object</param> /// <returns>a TargetSource for this object</returns> ! protected ITargetSource GetCustomTargetSource(object obj, string name) { ! if (owningObjectFactory != null && owningObjectFactory.ContainsObject(name) && ! !owningObjectFactory.IsSingleton(name)) { - if (logger.IsInfoEnabled) - logger.Info(string.Format("Checking for custom TargetSource for object with objectName '{0}'", name)); for (int i = 0; i < customTargetSourceCreators.Count; i++) { ITargetSourceCreator tsc = (ITargetSourceCreator) customTargetSourceCreators[i]; ! ITargetSource ts = tsc.GetTargetSource(obj, name, owningObjectFactory); if (ts != null) { --- 369,385 ---- /// Subclasses can override this method to use a different mechanism. /// </summary> ! /// <param name="objectType">the type of the object to create a TargetSource for</param> /// <param name="name">the name of the object</param> /// <returns>a TargetSource for this object</returns> ! protected virtual ITargetSource GetCustomTargetSource(Type objectType, string name) { ! // We can't create fancy target sources for directly registered singletons. ! if (customTargetSourceCreators != null && ! owningObjectFactory != null && owningObjectFactory.ContainsObject(name)) { for (int i = 0; i < customTargetSourceCreators.Count; i++) { ITargetSourceCreator tsc = (ITargetSourceCreator) customTargetSourceCreators[i]; ! ITargetSource ts = tsc.GetTargetSource(objectType, name, owningObjectFactory); if (ts != null) { *************** *** 422,426 **** /// add it to existing implementations of this method.</p> /// </remarks> ! /// <param name="obj">the new object instance</param> /// <param name="name">the name of the object</param> /// <param name="customTargetSource">targetSource returned by TargetSource property: --- 410,414 ---- /// add it to existing implementations of this method.</p> /// </remarks> ! /// <param name="objType">the new object instance</param> /// <param name="name">the name of the object</param> /// <param name="customTargetSource">targetSource returned by TargetSource property: *************** *** 429,434 **** /// or an empty array if no additional interceptors but just the common ones; /// or null if no proxy at all, not even with the common interceptors.</returns> ! protected abstract object[] GetAdvicesAndAdvisorsForObject( ! object obj, string name, ITargetSource customTargetSource); #endregion --- 417,513 ---- /// or an empty array if no additional interceptors but just the common ones; /// or null if no proxy at all, not even with the common interceptors.</returns> ! protected abstract object[] GetAdvicesAndAdvisorsForObject(Type objType, string name, ITargetSource customTargetSource); ! ! /// <summary> ! /// Create an AOP proxy for the given object. ! /// </summary> ! /// <param name="objectType">Type of the object.</param> ! /// <param name="objectName">The name of the object.</param> ! /// <param name="specificInterceptors">The set of interceptors that is specific to this ! /// object (may be empty but not null)</param> ! /// <param name="targetSource">The target source for the proxy, already pre-configured to access the object.</param> ! /// <returns>The AOP Proxy for the object.</returns> ! protected virtual object CreateProxy(Type objectType, string objectName, object[] specificInterceptors, ITargetSource targetSource) ! { ! ProxyFactory proxyFactory = new ProxyFactory(); ! // copy our properties (proxyTargetClass) inherited from ProxyConfig ! proxyFactory.CopyFrom(this); ! ! ! IAdvisor[] advisors = BuildAdvisors(objectName, specificInterceptors); ! ! foreach (IAdvisor advisor in advisors) ! { ! if (advisor is IIntroductionAdvisor) ! { ! proxyFactory.AddIntroduction((IIntroductionAdvisor)advisor); ! } ! else ! { ! proxyFactory.AddAdvisor(advisor); ! } ! } ! proxyFactory.TargetSource = targetSource; ! CustomizeProxyFactory(proxyFactory); ! ! return proxyFactory.GetProxy(); ! } ! ! /// <summary> ! /// Determines the advisors for the given object, including the specific interceptors ! /// as well as the common interceptor, all adapted to the Advisor interface. ! /// </summary> ! /// <param name="objectName">The name of the object.</param> ! /// <param name="specificInterceptors">The set of interceptors that is specific to this ! /// object (may be empty, but not null)</param> ! /// <returns>The list of Advisors for the given object</returns> ! protected virtual IAdvisor[] BuildAdvisors(string objectName, object[] specificInterceptors) ! { ! // handle prototypes correctly ! IAdvisor[] commonInterceptors = ResolveInterceptorNames(); ! ! ArrayList allInterceptors = new ArrayList(); ! if (specificInterceptors != null) ! { ! allInterceptors.AddRange(specificInterceptors); ! if (commonInterceptors != null) ! { ! if (applyCommonInterceptorsFirst) ! { ! allInterceptors.InsertRange(0, commonInterceptors); ! } ! else ! { ! allInterceptors.AddRange(commonInterceptors); ! } ! } ! } ! if (logger.IsInfoEnabled) ! { ! int nrOfCommonInterceptors = commonInterceptors != null ? commonInterceptors.Length : 0; ! int nrOfSpecificInterceptors = specificInterceptors != null ? specificInterceptors.Length : 0; ! logger.Info(string.Format("Creating implicit proxy for object '{0}' with {1} common interceptors and {2} specific interceptors", objectName, nrOfCommonInterceptors, nrOfSpecificInterceptors)); ! } ! ! ! IAdvisor[] advisors = new IAdvisor[allInterceptors.Count]; ! for (int i = 0; i < allInterceptors.Count; i++) ! { ! advisors[i] = advisorAdapterRegistry.Wrap(allInterceptors[i]); ! } ! return advisors; ! } ! ! /// <summary> ! /// Build a cache key for the given object type and object name ! /// </summary> ! /// <param name="objectType">The object type.</param> ! /// <param name="objectName">The object name.</param> ! /// <returns>The cache key for the given type and name</returns> ! protected virtual object GetCacheKey(Type objectType, string objectName) ! { ! return objectType.FullName + "_" + objectName; ! } ! #endregion *************** *** 455,458 **** --- 534,603 ---- #endregion + + #region IInstantiationAwareObjectPostProcessor Members + + /// <summary> + /// Create the proxy if have a custom TargetSource + /// </summary> + /// <param name="objectType">The object type</param> + /// <param name="objectName">The object name</param> + /// <returns>null if not creating a proxy, otherwise return the proxy.</returns> + public object PostProcessBeforeInstantiation(Type objectType, string objectName) + { + object cacheKey = GetCacheKey(objectType, objectName); + if (!targetSourcedObjects.Contains(cacheKey)) + { + if (advisedObjects.Contains(cacheKey) || nonAdvisedObjects.Contains(cacheKey)) + { + return null; + } + if (IsInfrastructureType(objectType, objectName) || ShouldSkip(objectType, objectName)) + { + nonAdvisedObjects.Add(cacheKey); + return null; + } + } + // Create proxy here if we have a custom TargetSource. + // Suppresses unnecessary default instantiation of the target object: + // The TargetSource will handle target instances in a custom fashion. + ITargetSource targetSource = GetCustomTargetSource(objectType, objectName); + if (targetSource != null) + { + targetSourcedObjects.Add(objectName); + object[] specificInterceptors = GetAdvicesAndAdvisorsForObject(objectType, objectName, targetSource); + return CreateProxy(objectType, objectName, specificInterceptors, targetSource); + } + return null; + } + + + /// <summary> + /// Default behavior, return true and continue processing. + /// </summary> + /// <param name="objectInstance">The object instance</param> + /// <param name="objectName">The object name.</param> + /// <returns>true</returns> + public bool PostProcessAfterInstantiation(object objectInstance, string objectName) + { + return true; + } + + /// <summary> + /// Default behavior, return passed in PropertyValues + /// </summary> + /// <param name="pvs">The property values that the factory is about to apply (never <code>null</code>).</param> + /// <param name="pis">he relevant property infos for the target object (with ignored + /// dependency types - which the factory handles specifically - already filtered out)</param> + /// <param name="objectInstance">The object instance created, but whose properties have not yet + /// been set.</param> + /// <param name="objectName">Name of the object.</param> + /// <returns>The passed in PropertyValues</returns> + public IPropertyValues PostProcessPropertyValues(IPropertyValues pvs, PropertyInfo[] pis, object objectInstance, + string objectName) + { + return pvs; + } + + #endregion } } \ No newline at end of file Index: ITargetSourceCreator.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ITargetSourceCreator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ITargetSourceCreator.cs 9 Apr 2006 07:18:36 -0000 1.2 --- ITargetSourceCreator.cs 22 Aug 2007 08:49:08 -0000 1.3 *************** *** 21,24 **** --- 21,25 ---- #region Imports + using System; using Spring.Objects.Factory; *************** *** 43,52 **** /// Create a special TargetSource for the given object, if any. /// </summary> ! /// <param name="obj">the object to create a TargetSource for</param> ! /// <param name="name">the name of the object</param> /// <param name="factory">the containing factory</param> /// <returns>a special TargetSource or null if this TargetSourceCreator isn't /// interested in the particular object</returns> ! ITargetSource GetTargetSource(object obj, string name, IObjectFactory factory); } } \ No newline at end of file --- 44,53 ---- /// Create a special TargetSource for the given object, if any. /// </summary> ! /// <param name="objectType">The type of the object to create a TargetSource for</param> ! /// <param name="objectName">the name of the object</param> /// <param name="factory">the containing factory</param> /// <returns>a special TargetSource or null if this TargetSourceCreator isn't /// interested in the particular object</returns> ! ITargetSource GetTargetSource(Type objectType, string objectName, IObjectFactory factory); } } \ No newline at end of file Index: ObjectNameAutoProxyCreator.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/AutoProxy/ObjectNameAutoProxyCreator.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ObjectNameAutoProxyCreator.cs 28 Feb 2007 20:27:42 -0000 1.5 --- ObjectNameAutoProxyCreator.cs 22 Aug 2007 08:49:09 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- #region Imports + using System; using System.Collections; using Spring.Util; *************** *** 69,73 **** /// Identify as object to proxy if the object name is in the configured list of names. /// </summary> ! protected override object[] GetAdvicesAndAdvisorsForObject(object obj, string name, ITargetSource customTargetSource) { if (objectNames != null) --- 70,74 ---- /// Identify as object to proxy if the object name is in the configured list of names. /// </summary> ! protected override object[] GetAdvicesAndAdvisorsForObject(Type objType, string name, ITargetSource customTargetSource) { if (objectNames != null) |
From: Mark P. <mar...@us...> - 2007-08-22 08:49:21
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/Adapter In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13590/Adapter Modified Files: AdvisorAdapterRegistrationManager.cs Log Message: SPRNET-301 - Add IInstantiationAwareObjectPostProcessor functionality Updated its use in AbstractAutoProxyCreator Updated implementation of IsSingleton in AbstractObjectFactory Index: AdvisorAdapterRegistrationManager.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/Adapter/AdvisorAdapterRegistrationManager.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AdvisorAdapterRegistrationManager.cs 9 Apr 2006 07:18:35 -0000 1.4 --- AdvisorAdapterRegistrationManager.cs 22 Aug 2007 08:49:08 -0000 1.5 *************** *** 89,93 **** /// The new object instance. /// </param> ! /// <param name="name"> /// The name of the object. /// </param> --- 89,93 ---- /// The new object instance. /// </param> ! /// <param name="objectName"> /// The name of the object. /// </param> *************** *** 98,102 **** /// In case of errors. /// </exception> ! public virtual object PostProcessAfterInitialization(object instance, string name) { IAdvisorAdapter adapter = instance as IAdvisorAdapter; --- 98,102 ---- /// In case of errors. /// </exception> ! public virtual object PostProcessAfterInitialization(object instance, string objectName) { IAdvisorAdapter adapter = instance as IAdvisorAdapter; |