From 51b34811b3f52817e0477fdc8c6765ebaebee768 Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Fri, 21 Dec 2012 16:01:18 -0500 Subject: [PATCH] misc initial cosmetic cleanup --- .../AssemblyInfo.cs | 20 + .../HttpModule/ConversationModule.cs | 82 +- .../ConversationWA/IConversationManager.cs | 30 +- .../ConversationWA/IConversationState.cs | 44 +- .../{Imple => Impl}/InnerConversationList.cs | 731 ++++----- .../{Imple => Impl}/WebConversationManager.cs | 728 ++++----- .../WebConversationSpringState.cs | 1335 +++++++++-------- .../Support/SessionPerConversationScope.cs | 47 +- .../Support/SessionPerConversationSettings.cs | 20 + .../Spring.ConversationWA.NH32.2010.csproj | 7 +- .../ConversationWA/Imple/dontdelete.txt | 1 - .../Spring.ConversationWA.NH33.2010.csproj | 12 +- .../Bsn/ConversationEvidenceBsnImpl.cs | 20 + .../Bsn/IConversationEvidenceBsn.cs | 20 + .../Bsn/INoDeferedErrorBsn.cs | 20 + .../Bsn/NoDeferedErrorBsnImpl.cs | 22 +- .../PatialEndConvBeginBasePage.cs | 20 + .../PatialEndConvEndBasePage.cs | 20 + .../SerializeConversationTestModule.cs | 22 +- .../ConversationWA/SimpleTest.cs | 22 +- .../WebConversationStateTest.cs | Bin 68262 -> 68958 bytes .../ConnectionReleaseModeIssue.aspx.cs | 32 +- .../WebConversationStateTest/IoeTests.aspx.cs | 24 +- .../services.xml.config | 66 +- .../Entities/SPCDetailEnt.cs | 20 + .../Entities/SPCMasterEnt.cs | 20 + ...ring.ConversationWA.NH32.Tests.2008.csproj | 2 +- ...ring.ConversationWA.NH32.Tests.2010.csproj | 2 +- .../ConnectionCreationTrackingDbProvider.cs | 49 + .../Data/Common/CountGetConnDbProvider.cs | 29 - .../services.xml.config | 60 +- ...ring.ConversationWA.NH33.Tests.2010.csproj | 4 +- 32 files changed, 1960 insertions(+), 1571 deletions(-) rename src/Spring/Spring.ConversationWA.NH32/ConversationWA/{Imple => Impl}/InnerConversationList.cs (78%) rename src/Spring/Spring.ConversationWA.NH32/ConversationWA/{Imple => Impl}/WebConversationManager.cs (91%) rename src/Spring/Spring.ConversationWA.NH32/ConversationWA/{Imple => Impl}/WebConversationSpringState.cs (84%) delete mode 100644 src/Spring/Spring.ConversationWA.NH33/ConversationWA/Imple/dontdelete.txt create mode 100644 test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/ConnectionCreationTrackingDbProvider.cs delete mode 100644 test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/CountGetConnDbProvider.cs diff --git a/src/Spring/Spring.ConversationWA.NH32/AssemblyInfo.cs b/src/Spring/Spring.ConversationWA.NH32/AssemblyInfo.cs index d82e84c0..11ea80a7 100644 --- a/src/Spring/Spring.ConversationWA.NH32/AssemblyInfo.cs +++ b/src/Spring/Spring.ConversationWA.NH32/AssemblyInfo.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Reflection; diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/HttpModule/ConversationModule.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/HttpModule/ConversationModule.cs index 4804eeb6..9ecd5799 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/HttpModule/ConversationModule.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/HttpModule/ConversationModule.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; @@ -11,21 +31,17 @@ using Spring.Context; namespace Spring.ConversationWA.HttpModule { /// - /// HttpModule for end Conversation with Timeout exceeded. + /// HttpModule for ending Conversations with Timeout exceeded. /// /// Hailton de Castro public class ConversationModule : IHttpModule, IApplicationContextAware { private static readonly ILog LOG = LogManager.GetLogger(typeof(ConversationModule)); - /// - /// Default constructor. - /// - public ConversationModule(){ } - private IList conversationManagerName; + /// - /// Name for the IConversationManager on the spring context. + /// The Names of the s in the /// public IList ConversationManagerNameList { @@ -41,13 +57,14 @@ namespace Spring.ConversationWA.HttpModule /// public void Init(HttpApplication context) { - context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute); - context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute); - context.EndRequest += new EventHandler(context_EndRequest); + context.PreRequestHandlerExecute += context_PreRequestHandlerExecute; + context.PostRequestHandlerExecute += context_PostRequestHandlerExecute; + context.EndRequest += context_EndRequest; } + /// - /// NOOP. + /// Disposes of the resources (other than memory) used by the module that implements . /// public void Dispose() { @@ -63,9 +80,10 @@ namespace Spring.ConversationWA.HttpModule if (HttpContext.Current.Session != null) { - if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: HttpContext.Current.Session is NOT null"); + if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: Processing HttpContext.Current.Session"); foreach (String convMngName in this.ConversationManagerNameList) { + if (LOG.IsDebugEnabled) LOG.Debug(string.Format("context_PreRequestHandlerExecute: Processing ConversationManager: {0}", convMngName)); IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName); convMng.EndOnTimeOut(); convMng.FreeEnded(); @@ -73,21 +91,26 @@ namespace Spring.ConversationWA.HttpModule } else { - if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: HttpContext.Current.Session IS null"); + if (LOG.IsDebugEnabled) LOG.Debug("context_PreRequestHandlerExecute: no HttpContext.Current.Session found."); } } } + /// - /// Necessary for Redirect or Abort for some reason. + /// Handles the Unload event of the page control. /// - /// - /// + /// The source of the event. + /// The instance containing the event data. + /// + /// Necessary for Redirect or Abort for any reason. + /// void page_Unload(object sender, EventArgs e) { if (LOG.IsDebugEnabled) LOG.Debug("page_Unload HttpContext.Current.Session is null: " + (HttpContext.Current.Session == null)); foreach (String convMngName in this.ConversationManagerNameList) { + if (LOG.IsDebugEnabled) LOG.Debug(string.Format("page_Unload: Processing ConversationManager: {0}", convMngName)); IConversationManager convMng = (IConversationManager)this.applicationContext.GetObject(convMngName); convMng.EndOnTimeOut(); convMng.FreeEnded(); @@ -112,9 +135,34 @@ namespace Spring.ConversationWA.HttpModule #region IApplicationContextAware Members private IApplicationContext applicationContext; + /// - /// Used to obtain the instances of "IConversationManager". + /// Sets the that this + /// object runs in. /// + /// + /// + ///

+ /// Used to obtain the instances of + ///

+ ///

+ /// Invoked after population of normal object properties but before an + /// init callback such as + /// 's + /// + /// or a custom init-method. Invoked after the setting of any + /// 's + /// + /// property. + ///

+ ///
+ /// + /// In the case of application context initialization errors. + /// + /// + /// If thrown by any application context methods. + /// + /// public IApplicationContext ApplicationContext { set { this.applicationContext = value; } diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationManager.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationManager.cs index b48ba512..f43c6e17 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationManager.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationManager.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; @@ -24,21 +44,21 @@ namespace Spring.ConversationWA void EndOnTimeOut(); /// - /// Close IDbConnection's for that + /// Close IDbConnections for that /// use 'session-per-conversation'. It calls /// in all conversations. /// void PauseConversations(); /// - /// Release the ended conversatons And remove it. - /// If the conversation support 'session-per-conversation' close the session. + /// Release the ended conversations And removes them. + /// If the conversation supports 'session-per-conversation', also close the session. /// void FreeEnded(); /// /// Add conversation. If is null - /// it is setted with 'this'. + /// it resolves to 'this'. /// /// /// @@ -74,7 +94,7 @@ namespace Spring.ConversationWA /// /// Ends the "paused conversations" in call to . /// Important: Unexpected behavior may occur if there are nested conversations, - /// as in 'StartResumeConversation' only the own conversation and their parents + /// as in only the current conversation and its parents /// are started, the 'conversations children' remain paused, so these will be ended. /// Defaul value: false. /// diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationState.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationState.cs index 6e0259c0..89db3c59 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationState.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/IConversationState.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Data; using System.Configuration; @@ -17,7 +37,7 @@ namespace Spring.ConversationWA /// /// Port to conversation. If the object is not found in the current /// conversation, will be tried on the parent if the parent is - /// different not null. + /// not null. /// /// /// If is different from spring name for this instance. @@ -31,9 +51,9 @@ namespace Spring.ConversationWA String Id { get; set; } /// - /// Starts or resumes the conversation and the . + /// Starts or resumes the conversation and the . /// If is not null, so - /// .GetCurrentSession() is called to + /// is called to /// Raise SessionHolder for make the reconnection. /// /// Make return false. @@ -47,7 +67,7 @@ namespace Spring.ConversationWA /// /// If is not null and /// different from - /// .GetCurrentSession() + /// /// /// /// @@ -59,7 +79,7 @@ namespace Spring.ConversationWA bool IsNew { get; } /// - /// Ends the conversation. End each the 'inner conversation' in + /// Ends the conversation. End each of the 'inner conversations' in /// . Returns false if the /// conversation and all of /// has already been ended. @@ -84,14 +104,14 @@ namespace Spring.ConversationWA bool Ended { get; } /// - /// Inner conversation. After added if the - /// is null it will be setted with 'this'. + /// Inner conversation. After added if the + /// is null it will resolve to 'this'. /// /// at /// , /// , /// - /// if Circular Dependence is detected. + /// if Circular Dependency is detected. IList InnerConversations { get; } /// @@ -103,23 +123,23 @@ namespace Spring.ConversationWA /// /// If this Conversation is not new. /// - /// If Circular Dependence is detected. + /// If Circular Dependency is detected. /// /// The Parent conversation is not new. /// /// /// - IConversationState ParenteConversation { get; set;} + IConversationState ParentConversation { get; set;} /// /// TimeOut for the conversation in milliseconds. - /// If 0 means it will be ignored. + /// If 0 TimeOut will be ignored. /// Int32 TimeOut { get; set; } /// /// Last acces for a value into this Conversation or Inner Conversation. - /// It is reseted for DateTime.Now each time + /// Reset to DateTime.Now each time /// is called. /// DateTime LastAccess { get; set; } diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/InnerConversationList.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/InnerConversationList.cs similarity index 78% rename from src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/InnerConversationList.cs rename to src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/InnerConversationList.cs index cbad86ef..065be83d 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/InnerConversationList.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/InnerConversationList.cs @@ -1,355 +1,376 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Collections; -using Common.Logging; -using Iesi.Collections.Generic; - -namespace Spring.ConversationWA.Imple -{ - /// - /// List that make validation for Circular Dependence for - /// - /// Hailton de Castro - [Serializable] - public class InnerConversationList: IList, IList - { - private static readonly ILog LOG = LogManager.GetLogger(typeof(InnerConversationList)); - - private IConversationState conversationOwner; - /// - /// Contructor. - /// - /// The IConversation that owns this InnerConversationList. - public InnerConversationList(IConversationState conversationOwner) - { - if (conversationOwner == null) - { - String exMsgStr = "'conversationOwner' can not be null"; - - LOG.Error(exMsgStr); - throw new InvalidOperationException(exMsgStr); - } - if (LOG.IsDebugEnabled) LOG.Error(String.Format("Creating InnerConversationList for '{0}'", conversationOwner.Id)); - this.conversationOwner = conversationOwner; - } - - private IList innerList = new List(); - - /// - /// Common Helper to be run before insert. - /// - /// - private void addPreAddHelper(IConversationState itemAdded) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("addPreAddHelper: added={0} into {1}", itemAdded, this.conversationOwner)); - this.validateCircularDependence(itemAdded); - if (itemAdded.ParenteConversation != null && itemAdded.ParenteConversation != this.conversationOwner) - { - throw new InvalidOperationException( - String.Format(WebConversationSpringState.MSG_CONVERSATION_ALREADY_HAS_PARENT, itemAdded.ParenteConversation.Id, this.conversationOwner.Id)); - } - } - - /// - /// Common Helper to be run after insert. - /// - private void addPostAddHelper(IConversationState itemAdded) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("addPreAddHelper: added={0} into {1}", itemAdded, this.conversationOwner)); - if (itemAdded.ParenteConversation == null) - { - itemAdded.ParenteConversation = this.conversationOwner; - } - } - - private void validateCircularDependence(IConversationState itemAdded) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Validating Circular Dependence: added={0} into {1}", itemAdded, this.conversationOwner)); - - ICollection visitedColl = new HashedSet(); - visitedColl.Add(conversationOwner); - - IConversationState parentAncestor = this.conversationOwner; - String path = this.conversationOwner.Id; - //string conectorPath = ""; - - this.validateCircularDependenceRecursive(itemAdded, visitedColl, path + "->" + itemAdded.Id); - } - - private void validateCircularDependenceRecursive(IConversationState currentConv, ICollection visitedColl, String path) - { - foreach (IConversationState convItem in currentConv.InnerConversations) - { - if (visitedColl.Contains(convItem)) - { - String exMsgStr = - "ConversationState Circular Dependence detected: " + - path + "->" + convItem.Id; - - LOG.Error(exMsgStr); - throw new InvalidOperationException(exMsgStr); - } - - visitedColl.Add(convItem); - - this.validateCircularDependenceRecursive(convItem, visitedColl, path + "->" + convItem.Id); - } - } - - #region IList Members - /// - /// - /// - /// - /// - public int IndexOf(IConversationState item) - { - return this.innerList.IndexOf(item); - } - - /// - /// - /// - /// - /// - public void Insert(int index, IConversationState item) - { - this.addPreAddHelper(item); - this.innerList.Insert(index, item); - this.addPostAddHelper(item); - } - - /// - /// - /// - /// - public void RemoveAt(int index) - { - this.innerList.RemoveAt(index); - } - - /// - /// - /// - /// - /// - public IConversationState this[int index] - { - get - { - return this.innerList[index]; - } - set - { - this.addPreAddHelper(value); - this.innerList[index] = value; - this.addPostAddHelper(value); - } - } - - #endregion - - #region ICollection Members - /// - /// - /// - /// - public void Add(IConversationState item) - { - this.addPreAddHelper(item); - this.innerList.Add(item); - this.addPostAddHelper(item); - } - - /// - /// - /// - public void Clear() - { - this.innerList.Clear(); - } - - /// - /// - /// - /// - /// - public bool Contains(IConversationState item) - { - return this.innerList.Contains(item); - } - - /// - /// - /// - /// - /// - public void CopyTo(IConversationState[] array, int arrayIndex) - { - this.innerList.CopyTo(array, arrayIndex); - } - - /// - /// - /// - public int Count - { - get { return this.innerList.Count; } - } - - /// - /// - /// - public bool IsReadOnly - { - get { return this.innerList.IsReadOnly; } - } - - /// - /// - /// - /// - /// - public bool Remove(IConversationState item) - { - return this.innerList.Remove(item); - } - - #endregion - - #region IEnumerable Members - /// - /// - /// - /// - public IEnumerator GetEnumerator() - { - return this.innerList.GetEnumerator(); - } - - #endregion - - #region IEnumerable Members - - /// - /// - /// - /// - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.innerList.GetEnumerator(); - } - - #endregion - - #region IList Members - /// - /// - /// - /// - /// - public int Add(object value) - { - ((IList)this).Add((IConversationState)value); - return this.innerList.Count - 1; - } - - /// - /// - /// - /// - /// - public bool Contains(object value) - { - return ((IList)this).Contains((IConversationState)value); - } - - /// - /// - /// - /// - /// - public int IndexOf(object value) - { - return ((IList)this).IndexOf((IConversationState)value); - } - - /// - /// - /// - /// - /// - public void Insert(int index, object value) - { - ((IList)this).Insert(index, (IConversationState)value); - } - - /// - /// - /// - public bool IsFixedSize - { - get { return false; } - } - - /// - /// - /// - /// - public void Remove(object value) - { - ((IList)this).Add((IConversationState)value); - } - - /// - /// - /// - /// - /// - object IList.this[int index] - { - get - { - return ((IList)this)[index]; - } - set - { - ((IList)this)[index] = (IConversationState)value; - } - } - - #endregion - - #region ICollection Members - /// - /// - /// - /// - /// - public void CopyTo(Array array, int index) - { - IConversationState[] convArr = new IConversationState[array.Length]; - ((IList)this).CopyTo(convArr, index); - convArr.CopyTo(array, index); - } - - /// - /// - /// - public bool IsSynchronized - { - get { return false; } - } - - /// - /// - /// - public object SyncRoot - { - get { return this; } - } - - #endregion - } -} +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Collections; +using Common.Logging; +using Iesi.Collections.Generic; + +namespace Spring.ConversationWA.Impl +{ + /// + /// List that make validation for Circular Dependency for + /// + /// Hailton de Castro + [Serializable] + public class InnerConversationList: IList, IList + { + private static readonly ILog LOG = LogManager.GetLogger(typeof(InnerConversationList)); + + private IConversationState conversationOwner; + + private IList innerList = new List(); + + /// + /// Contructor. + /// + /// The that owns this . + public InnerConversationList(IConversationState conversationOwner) + { + if (conversationOwner == null) + { + String message = "'conversationOwner' can not be null"; + + LOG.Error(message); + throw new InvalidOperationException(message); + } + if (LOG.IsDebugEnabled) LOG.Error(String.Format("Creating InnerConversationList for '{0}'", conversationOwner.Id)); + this.conversationOwner = conversationOwner; + } + + /// + /// Common Helper to be run before insert. + /// + /// + private void PreAddProcessor(IConversationState itemAdded) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("PreAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); + this.ValidateCircularDependency(itemAdded); + if (itemAdded.ParentConversation != null && itemAdded.ParentConversation != this.conversationOwner) + { + throw new InvalidOperationException( + String.Format(WebConversationSpringState.MSG_CONVERSATION_ALREADY_HAS_PARENT, itemAdded.ParentConversation.Id, this.conversationOwner.Id)); + } + } + + /// + /// Common Helper to be run after insert. + /// + private void PostAddProcessor(IConversationState itemAdded) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("PostAddProcessor: added={0} into {1}", itemAdded, this.conversationOwner)); + if (itemAdded.ParentConversation == null) + { + itemAdded.ParentConversation = this.conversationOwner; + } + } + + private void ValidateCircularDependency(IConversationState itemAdded) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Validating Circular Dependency: added={0} into {1}", itemAdded, this.conversationOwner)); + + ICollection visitedColl = new HashedSet(); + visitedColl.Add(conversationOwner); + + IConversationState parentAncestor = this.conversationOwner; + String path = this.conversationOwner.Id; + //string conectorPath = ""; + + this.ValidateCircularDependencyRecursive(itemAdded, visitedColl, path + "->" + itemAdded.Id); + } + + private void ValidateCircularDependencyRecursive(IConversationState currentConv, ICollection visitedColl, String path) + { + foreach (IConversationState convItem in currentConv.InnerConversations) + { + if (visitedColl.Contains(convItem)) + { + String exMsgStr = + "ConversationState Circular Dependency detected: " + + path + "->" + convItem.Id; + + LOG.Error(exMsgStr); + throw new InvalidOperationException(exMsgStr); + } + + visitedColl.Add(convItem); + + this.ValidateCircularDependencyRecursive(convItem, visitedColl, path + "->" + convItem.Id); + } + } + + #region IList Members + + /// + /// + /// + /// + /// + public int IndexOf(IConversationState item) + { + return this.innerList.IndexOf(item); + } + + /// + /// + /// + /// + /// + public void Insert(int index, IConversationState item) + { + this.PreAddProcessor(item); + this.innerList.Insert(index, item); + this.PostAddProcessor(item); + } + + /// + /// + /// + /// + public void RemoveAt(int index) + { + this.innerList.RemoveAt(index); + } + + /// + /// + /// + /// + /// + public IConversationState this[int index] + { + get + { + return this.innerList[index]; + } + set + { + this.PreAddProcessor(value); + this.innerList[index] = value; + this.PostAddProcessor(value); + } + } + + #endregion + + #region ICollection Members + /// + /// + /// + /// + public void Add(IConversationState item) + { + this.PreAddProcessor(item); + this.innerList.Add(item); + this.PostAddProcessor(item); + } + + /// + /// + /// + public void Clear() + { + this.innerList.Clear(); + } + + /// + /// + /// + /// + /// + public bool Contains(IConversationState item) + { + return this.innerList.Contains(item); + } + + /// + /// + /// + /// + /// + public void CopyTo(IConversationState[] array, int arrayIndex) + { + this.innerList.CopyTo(array, arrayIndex); + } + + /// + /// + /// + public int Count + { + get { return this.innerList.Count; } + } + + /// + /// + /// + public bool IsReadOnly + { + get { return this.innerList.IsReadOnly; } + } + + /// + /// + /// + /// + /// + public bool Remove(IConversationState item) + { + return this.innerList.Remove(item); + } + + #endregion + + #region IEnumerable Members + /// + /// + /// + /// + public IEnumerator GetEnumerator() + { + return this.innerList.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + /// + /// + /// + /// + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.innerList.GetEnumerator(); + } + + #endregion + + #region IList Members + /// + /// + /// + /// + /// + public int Add(object value) + { + ((IList)this).Add((IConversationState)value); + return this.innerList.Count - 1; + } + + /// + /// + /// + /// + /// + public bool Contains(object value) + { + return ((IList)this).Contains((IConversationState)value); + } + + /// + /// + /// + /// + /// + public int IndexOf(object value) + { + return ((IList)this).IndexOf((IConversationState)value); + } + + /// + /// + /// + /// + /// + public void Insert(int index, object value) + { + ((IList)this).Insert(index, (IConversationState)value); + } + + /// + /// + /// + public bool IsFixedSize + { + get { return false; } + } + + /// + /// + /// + /// + public void Remove(object value) + { + ((IList)this).Add((IConversationState)value); + } + + /// + /// + /// + /// + /// + object IList.this[int index] + { + get + { + return ((IList)this)[index]; + } + set + { + ((IList)this)[index] = (IConversationState)value; + } + } + + #endregion + + #region ICollection Members + /// + /// + /// + /// + /// + public void CopyTo(Array array, int index) + { + IConversationState[] convArr = new IConversationState[array.Length]; + ((IList)this).CopyTo(convArr, index); + convArr.CopyTo(array, index); + } + + /// + /// + /// + public bool IsSynchronized + { + get { return false; } + } + + /// + /// + /// + public object SyncRoot + { + get { return this; } + } + + #endregion + } +} diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationManager.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationManager.cs similarity index 91% rename from src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationManager.cs rename to src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationManager.cs index 7e8c6581..8d9ef260 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationManager.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationManager.cs @@ -1,354 +1,374 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Web; -using Common.Logging; -using Spring.Data.NHibernate.Support; -using NHibernate; -using Spring.Context; -using Spring.Context.Support; - -namespace Spring.ConversationWA.Imple -{ - /// - /// This was made to stay under session scope. - /// - /// Hailton de Castro - [Serializable] - public class WebConversationManager : SessionPerConversationScope, IConversationManager, IApplicationContextAware - { - private static readonly ILog LOG = LogManager.GetLogger(typeof(WebConversationManager)); - - private static readonly String CONVERSATION_COOKIE_ID = "WebConversationManager.activeConversationId"; - - /// - /// Semaphore to synchronize writes to the dictionary. - /// - [NonSerialized] - private Mutex mutexEditDic = new Mutex(); - private Mutex MutexEditDic - { - get - { - if (this.mutexEditDic == null) - this.mutexEditDic = new Mutex(); - return this.mutexEditDic; - } - } - - private IDictionary conversations = new Dictionary(); - private IConversationState activeConversation = null; - - #region IConversationManager Members - - /// - /// - /// - /// - /// - public IConversationState GetConversationById(string id) - { - if (this.conversations.ContainsKey(id)) - { - return this.conversations[id]; - } - else - { - return null; - } - } - - /// - /// - /// - public void EndOnTimeOut() - { - try - { - if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); - this.MutexEditDic.WaitOne(5000); - foreach (String keyItem in this.conversations.Keys) - { - IConversationState conversationItem = this.conversations[keyItem]; - if (conversationItem.TimeOut > 0) - { - if (DateTime.Now.Subtract(conversationItem.LastAccess).TotalMilliseconds > conversationItem.TimeOut) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Timeout for conversation '{0}'", conversationItem.Id)); - conversationItem.EndConversation(); - } - } - } - } - finally - { - this.MutexEditDic.ReleaseMutex(); - } - } - - /// - /// - /// - public void PauseConversations() - { - foreach (IConversationState convItem in this.conversations.Values) - { - convItem.PauseConversation(); - } - this.Close(this.SessionFactory, this.conversations.Values); - } - - /// - /// - /// - public void FreeEnded() - { - try - { - if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); - this.MutexEditDic.WaitOne(5000); - List removeList = new List(); - foreach (String keyItem in this.conversations.Keys) - { - IConversationState conversationItem = this.conversations[keyItem]; - if (conversationItem.Ended) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Release conversation '{0}'", conversationItem.Id)); - removeList.Add(conversationItem); - } - } - - if (removeList.Count > 0) - { - this.Close(this.SessionFactory, removeList); - } - - foreach (IConversationState conversationItem in removeList) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Remove conversation '{0}'", conversationItem.Id)); - conversationItem.EndConversation(); - this.RemoveConversation(conversationItem); - } - } - finally - { - this.MutexEditDic.ReleaseMutex(); - } - } - - /// - /// - /// - /// - public void AddConversation(IConversationState conversation) - { - try - { - this.MutexEditDic.WaitOne(5000); - this.conversations.Add(conversation.Id, conversation); - } - finally - { - this.MutexEditDic.ReleaseMutex(); - } - - if (conversation.ConversationManager != null && conversation.ConversationManager != this) - { - throw new InvalidOperationException(String.Format("Conversation already has another manager. conversation='{0}'", conversation.Id)); - } - - if (conversation.ConversationManager == null) - { - conversation.ConversationManager = this; - } - } - - /// - /// - /// - /// - public void SetActiveConversation(IConversationState conversation) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}')", conversation.Id)); - - //Close connection for the last conversation, if it is open. - if (this.activeConversation != null && this.activeConversation != conversation) - { - this.Close(this.SessionFactory, this.conversations.Values); - } - this.Open(conversation, this.conversations.Values); - - this.activeConversation = conversation; - - //Ending the paused conversations. - if (this.EndPaused) - { - foreach (IConversationState convItem in this.conversations.Values) - { - if (convItem.IsPaused) - { - convItem.EndConversation(); - } - } - } - } - - /// - /// - /// - [Obsolete("Not used, the active conversation is defined by call 'IConversationManager.SetActiveConversation' on 'IConversationState.StartResumeConversation'")] - public void LoadActiveConversation() - { - //reset this.activeConversation - this.activeConversation = null; - - if (LOG.IsDebugEnabled) LOG.Debug("LoadActiveConversation"); - - HttpCookie activeConveCookie = HttpContext.Current.Request.Cookies[CONVERSATION_COOKIE_ID]; - if (activeConveCookie != null && !String.IsNullOrEmpty(activeConveCookie.Value)) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: cooking found for current active conversation: [{0}]", activeConveCookie.ToString())); - if (this.conversations.ContainsKey(activeConveCookie.Value)) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: active conversation found for id: '{0}'", activeConveCookie.Value)); - IConversationState conversation = this.conversations[activeConveCookie.Value]; - if (conversation != null) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation found: '{0}'", conversation.Id)); - //find root conversation. - IConversationState rootConversation = conversation; - while (rootConversation.ParenteConversation != null) - { - rootConversation = rootConversation.ParenteConversation; - } - rootConversation.StartResumeConversation(); - this.SetActiveConversation(rootConversation); - } - } - else - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation NOT found for id on the cookie: '{0}'", activeConveCookie.Value)); - HttpContext.Current.Response.Cookies.Remove(CONVERSATION_COOKIE_ID); - } - } - } - - /// - /// - /// - public IConversationState ActiveConversation - { - get - { - return this.activeConversation; - } - } - - private String sessionFactoryName; - /// - /// "SessionFactory" name in the current context. - /// This approach is required to support serialization. - /// - public String SessionFactoryName - { - get { return sessionFactoryName; } - set { sessionFactoryName = value; } - } - - [NonSerialized] - private ISessionFactory sessionFactory; - /// - /// - /// - public ISessionFactory SessionFactory - { - get - { - if (this.sessionFactory == null && this.sessionFactoryName != null) - { - this.sessionFactory = this.ApplicationContext.GetObject(this.sessionFactoryName); - } - return sessionFactory; - } - } - - private bool endPaused = false; - - /// - /// - /// - public bool EndPaused - { - get { return endPaused; } - set { endPaused = value; } - } - #endregion - - #region SessionPerConversationScope Members - /// - /// Ends all conversations and Closes all their Session. - /// - public override void Dispose() - { - if (LOG.IsDebugEnabled) LOG.Debug("Dispose. End all Conversations"); - foreach (String conversationId in this.conversations.Keys) - { - this.conversations[conversationId].EndConversation(); - } - - this.Close(this.SessionFactory, this.conversations.Values); - - this.conversations.Clear(); - this.sessionFactory = null; - } - #endregion - - /// - /// Remove conversation. - /// - /// - private void RemoveConversation(IConversationState conversation) - { - try - { - this.MutexEditDic.WaitOne(5000); - if (!this.conversations.Remove(conversation.Id)) - { - throw new InvalidOperationException(String.Format("Conversation '{0}' not exists on this manager", conversation.Id)); - } - } - finally - { - this.MutexEditDic.ReleaseMutex(); - } - } - - #region IApplicationContextAware Members - private String applicationContextName; - [NonSerialized] - private IApplicationContext applicationContext = null; - /// - /// Returns the current context. Supports serialization and deserialization. - /// - public IApplicationContext ApplicationContext - { - set - { - this.applicationContext = value; - this.applicationContextName = this.applicationContext.Name; - } - get - { - if (this.applicationContext == null) - { - this.applicationContext = ContextRegistry.GetContext(this.applicationContextName); - } - return this.applicationContext; - } - } - - #endregion - - } -} +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Web; +using Common.Logging; +using Spring.Data.NHibernate.Support; +using NHibernate; +using Spring.Context; +using Spring.Context.Support; + +namespace Spring.ConversationWA.Impl +{ + /// + /// This was made to stay under session scope. + /// + /// Hailton de Castro + [Serializable] + public class WebConversationManager : SessionPerConversationScope, IConversationManager, IApplicationContextAware + { + private static readonly ILog LOG = LogManager.GetLogger(typeof(WebConversationManager)); + + private static readonly String CONVERSATION_COOKIE_ID = "WebConversationManager.activeConversationId"; + + /// + /// Semaphore to synchronize writes to the dictionary. + /// + [NonSerialized] + private Mutex mutexEditDic = new Mutex(); + private Mutex MutexEditDic + { + get + { + if (this.mutexEditDic == null) + this.mutexEditDic = new Mutex(); + return this.mutexEditDic; + } + } + + private readonly IDictionary conversations = new Dictionary(); + private IConversationState activeConversation = null; + + #region IConversationManager Members + + /// + /// + /// + /// + /// + public IConversationState GetConversationById(string id) + { + if (this.conversations.ContainsKey(id)) + { + return this.conversations[id]; + } + else + { + return null; + } + } + + /// + /// + /// + public void EndOnTimeOut() + { + try + { + if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); + this.MutexEditDic.WaitOne(5000); + foreach (String keyItem in this.conversations.Keys) + { + IConversationState conversationItem = this.conversations[keyItem]; + if (conversationItem.TimeOut > 0) + { + if (DateTime.Now.Subtract(conversationItem.LastAccess).TotalMilliseconds > conversationItem.TimeOut) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Timeout for conversation '{0}'", conversationItem.Id)); + conversationItem.EndConversation(); + } + } + } + } + finally + { + this.MutexEditDic.ReleaseMutex(); + } + } + + /// + /// + /// + public void PauseConversations() + { + foreach (IConversationState convItem in this.conversations.Values) + { + convItem.PauseConversation(); + } + this.Close(this.SessionFactory, this.conversations.Values); + } + + /// + /// + /// + public void FreeEnded() + { + try + { + if (LOG.IsDebugEnabled) LOG.Debug("EndOnTimeOut"); + this.MutexEditDic.WaitOne(5000); + List removeList = new List(); + foreach (String keyItem in this.conversations.Keys) + { + IConversationState conversationItem = this.conversations[keyItem]; + if (conversationItem.Ended) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Release conversation '{0}'", conversationItem.Id)); + removeList.Add(conversationItem); + } + } + + if (removeList.Count > 0) + { + this.Close(this.SessionFactory, removeList); + } + + foreach (IConversationState conversationItem in removeList) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("FreeEnded: Remove conversation '{0}'", conversationItem.Id)); + conversationItem.EndConversation(); + this.RemoveConversation(conversationItem); + } + } + finally + { + this.MutexEditDic.ReleaseMutex(); + } + } + + /// + /// + /// + /// + public void AddConversation(IConversationState conversation) + { + try + { + this.MutexEditDic.WaitOne(5000); + this.conversations.Add(conversation.Id, conversation); + } + finally + { + this.MutexEditDic.ReleaseMutex(); + } + + if (conversation.ConversationManager != null && conversation.ConversationManager != this) + { + throw new InvalidOperationException(String.Format("Conversation already has another manager. conversation='{0}'", conversation.Id)); + } + + if (conversation.ConversationManager == null) + { + conversation.ConversationManager = this; + } + } + + /// + /// + /// + /// + public void SetActiveConversation(IConversationState conversation) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}')", conversation.Id)); + + //Close connection for the last conversation, if it is open. + if (this.activeConversation != null && this.activeConversation != conversation) + { + this.Close(this.SessionFactory, this.conversations.Values); + } + this.Open(conversation, this.conversations.Values); + + this.activeConversation = conversation; + + //Ending the paused conversations. + if (this.EndPaused) + { + foreach (IConversationState convItem in this.conversations.Values) + { + if (convItem.IsPaused) + { + convItem.EndConversation(); + } + } + } + } + + /// + /// + /// + [Obsolete("Not used, the active conversation is defined by call 'IConversationManager.SetActiveConversation' on 'IConversationState.StartResumeConversation'")] + public void LoadActiveConversation() + { + //reset this.activeConversation + this.activeConversation = null; + + if (LOG.IsDebugEnabled) LOG.Debug("LoadActiveConversation"); + + HttpCookie activeConveCookie = HttpContext.Current.Request.Cookies[CONVERSATION_COOKIE_ID]; + if (activeConveCookie != null && !String.IsNullOrEmpty(activeConveCookie.Value)) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: cooking found for current active conversation: [{0}]", activeConveCookie.ToString())); + if (this.conversations.ContainsKey(activeConveCookie.Value)) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: active conversation found for id: '{0}'", activeConveCookie.Value)); + IConversationState conversation = this.conversations[activeConveCookie.Value]; + if (conversation != null) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation found: '{0}'", conversation.Id)); + //find root conversation. + IConversationState rootConversation = conversation; + while (rootConversation.ParentConversation != null) + { + rootConversation = rootConversation.ParentConversation; + } + rootConversation.StartResumeConversation(); + this.SetActiveConversation(rootConversation); + } + } + else + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation NOT found for id on the cookie: '{0}'", activeConveCookie.Value)); + HttpContext.Current.Response.Cookies.Remove(CONVERSATION_COOKIE_ID); + } + } + } + + /// + /// + /// + public IConversationState ActiveConversation + { + get + { + return this.activeConversation; + } + } + + private String sessionFactoryName; + /// + /// "SessionFactory" name in the current context. + /// This approach is required to support serialization. + /// + public String SessionFactoryName + { + get { return sessionFactoryName; } + set { sessionFactoryName = value; } + } + + [NonSerialized] + private ISessionFactory sessionFactory; + /// + /// + /// + public ISessionFactory SessionFactory + { + get + { + if (this.sessionFactory == null && this.sessionFactoryName != null) + { + this.sessionFactory = this.ApplicationContext.GetObject(this.sessionFactoryName); + } + return sessionFactory; + } + } + + private bool endPaused = false; + + /// + /// + /// + public bool EndPaused + { + get { return endPaused; } + set { endPaused = value; } + } + #endregion + + #region SessionPerConversationScope Members + /// + /// Ends all conversations and Closes all their Session. + /// + public override void Dispose() + { + if (LOG.IsDebugEnabled) LOG.Debug("Dispose. End all Conversations"); + foreach (String conversationId in this.conversations.Keys) + { + if (LOG.IsDebugEnabled) LOG.Debug(string.Format("Ending Conversation for Conversation Id: {0}", conversationId)); + this.conversations[conversationId].EndConversation(); + } + + this.Close(this.SessionFactory, this.conversations.Values); + + this.conversations.Clear(); + this.sessionFactory = null; + } + #endregion + + /// + /// Remove conversation. + /// + /// + private void RemoveConversation(IConversationState conversation) + { + try + { + this.MutexEditDic.WaitOne(5000); + if (!this.conversations.Remove(conversation.Id)) + { + throw new InvalidOperationException(String.Format("Conversation '{0}' does not exist on this manager.", conversation.Id)); + } + } + finally + { + this.MutexEditDic.ReleaseMutex(); + } + } + + #region IApplicationContextAware Members + private String applicationContextName; + [NonSerialized] + private IApplicationContext applicationContext = null; + /// + /// Returns the current context. Supports serialization and deserialization. + /// + public IApplicationContext ApplicationContext + { + set + { + this.applicationContext = value; + this.applicationContextName = this.applicationContext.Name; + } + get + { + if (this.applicationContext == null) + { + this.applicationContext = ContextRegistry.GetContext(this.applicationContextName); + } + return this.applicationContext; + } + } + + #endregion + + } +} diff --git a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationSpringState.cs b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationSpringState.cs similarity index 84% rename from src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationSpringState.cs rename to src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationSpringState.cs index ee586579..3267bb69 100644 --- a/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Imple/WebConversationSpringState.cs +++ b/src/Spring/Spring.ConversationWA.NH32/ConversationWA/Impl/WebConversationSpringState.cs @@ -1,666 +1,669 @@ -using System; -using System.Data; -using System.Configuration; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; -using Spring.Objects.Factory; -using Common.Logging; -using System.Collections.Generic; -using System.Collections; -using Spring.Data.Common; -using NHibernate; -using Spring.Data.NHibernate.Support; -using Spring.Data.NHibernate; -using Spring.Context; -using Spring.Context.Support; - -namespace Spring.ConversationWA.Imple -{ - /// - /// Implementation of conversation in the infrastructure of Spring. - /// It avoid Circular Dependence. - /// - /// Hailton de Castro - [Serializable] - public class WebConversationSpringState : IConversationState, IObjectNameAware, IApplicationContextAware - { - private static readonly ILog LOG = LogManager.GetLogger(typeof(WebConversationSpringState)); - - /// - /// Default message for "CONVERSATION ALREADY HAS A PARENT" error. - /// - public static readonly String MSG_CONVERSATION_ALREADY_HAS_PARENT = - "This conversation already has a different parent." + - " Current: '{0}'. Tried: '{1}'"; - - private IDictionary state = new Dictionary(); - - #region IConversationState Members - - private String id; - /// - /// - /// - public string Id - { - get - { - return this.id; - } - set - { - this.id = value; - } - } - - /// - /// - /// - /// - public void EndConversation() - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("End of Conversation '{0}'", this.id)); - - IDictionary springSessionScope = (IDictionary)HttpContext.Current.Session["spring.objects"]; - if (springSessionScope == null) - { - throw new InvalidOperationException("The 'spring session scope' are not located in the key 'spring.objects' of HttpSessionState"); - } - - if (springSessionScope.Contains(this.Id)) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was Found on 'spring session scope'!", this.id)); - springSessionScope.Remove(this.id); - } - else - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was NOT Found on 'spring session scope!", this.id)); - } - - List innerConversationsListTemp = new List(this.InnerConversations); - foreach (IConversationState innerConversationItem in innerConversationsListTemp) - { - innerConversationItem.EndConversation(); - } - - if (this.parenteConversation != null) - { - this.parenteConversation.InnerConversations.Remove(this); - } - - this.ended = true; - } - - private bool ended = false; - /// - /// - /// - public bool Ended - { - get { return ended; } - } - - private int timeOut = 180000; - /// - /// Default 180000. - /// - public int TimeOut - { - get { return timeOut; } - set { timeOut = value; } - } - - private IList innerConversations; - /// - /// - /// - public IList InnerConversations - { - get - { - if (this.innerConversations == null) - { - this.innerConversations = new InnerConversationList(this); - } - return this.innerConversations; - } - } - - private IConversationState parenteConversation; - /// - /// - /// - public IConversationState ParenteConversation - { - get - { - return this.parenteConversation; - } - set - { - if (this.parenteConversation != null && this.parenteConversation != value) - { - throw new InvalidOperationException( - String.Format(MSG_CONVERSATION_ALREADY_HAS_PARENT, this.parenteConversation.Id, value.Id)); - } - if (!this.IsNew) - { - throw new InvalidOperationException( - String.Format("This Conversation is not new." + - " Conversation.Id: '{0}'. Parent Tried: '{1}'", this.Id, value.Id)); - } - //Perhaps the father need not be new, only the child needs to be. - //if (!value.IsNew) - //{ - // throw new InvalidOperationException( - // String.Format("The Parent conversation is not new." + - // " Conversation.Id: '{0}'. Parent Tried: '{1}'", this.Id, value.Id)); - //} - - this.parenteConversation = value; - if (!this.parenteConversation.InnerConversations.Contains(this)) - { - this.parenteConversation.InnerConversations.Add(this); - } - } - } - - private DateTime lastAccess = DateTime.Now; - /// - /// . - /// - public DateTime LastAccess - { - get { return lastAccess; } - set { lastAccess = value; } - } - - private IConversationManager conversationManager; - /// - /// - /// - public IConversationManager ConversationManager - { - get - { - return conversationManager; - } - set - { - conversationManager = value; - if (this.conversationManager.GetConversationById(this.Id) == null) - { - this.conversationManager.AddConversation(this); - } - } - } - - /// - /// - /// - public void StartResumeConversation() - { - this.isNew = false; - this.isPaused = false; - this.lastAccess = DateTime.Now; - - if (this.Ended) - { - throw new InvalidOperationException( - String.Format( - "StartResumeConversation: this conversation is ended." + - " Conversation.Id '{0}'", this.Id)); - } - if (this.ConversationManager != null) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("StartResumeConversation('{0}'): ConversationManager is not null.", this.Id)); - //if this is the root conversation. - if (this.ParenteConversation == null) - { - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}'): ConversationManager is not null.", this.Id)); - //if this is the root conversation. - this.ConversationManager.SetActiveConversation(this); - - //makes SessionHolder to reopen this session - if (this.RootSessionPerConversation != null) - { - ISession session = this.SessionFactory.GetCurrentSession(); - if (this.RootSessionPerConversation != session) - { - //How it is implemented it will never happen, because of the sequence of previous calls: - // ConversationManager.SetActiveConversation -> SessionPerConversationScope.Open - // 'new InvalidOperationException("Participating in existing Hibernate SessionFactory IS NOT ALOWED.")' happen first. - throw new InvalidOperationException( - String.Format( - "StartResumeConversation: this.SessionFactory.GetCurrentSession()" + - " have a different instance than 'RootSessionPerConversation'" + - " from conversation '{0}'", this.Id)); - } - } - } - else - { - this.ParenteConversation.StartResumeConversation(); - } - } - } - - private ISession rootSessionPerConversation; - /// - /// - /// - public ISession RootSessionPerConversation - { - get - { - if (this.ParenteConversation != null) - { - return this.ParenteConversation.RootSessionPerConversation; - } - else - { - return rootSessionPerConversation; - } - } - set - { - if (this.ParenteConversation != null) - { - this.ParenteConversation.RootSessionPerConversation = value; - } - else - { - rootSessionPerConversation = value; - } - } - } - - private String sessionFactoryName; - /// - /// "SessionFactory" name in the current context. - /// This approach is required to support serialization. - /// - public String SessionFactoryName - { - get { return sessionFactoryName; } - set { sessionFactoryName = value; } - } - - [NonSerialized] - private ISessionFactory sessionFactory; - /// - /// - /// - public ISessionFactory SessionFactory - { - get - { - if (this.sessionFactory == null && this.sessionFactoryName != null) - { - this.sessionFactory = this.ApplicationContext.GetObject(this.sessionFactoryName); - } - return sessionFactory; - } - } - - private String dbProviderName; - /// - /// "DbProvider" name in the current context. - /// This approach is required to support serialization. - /// - public String DbProviderName - { - get { return dbProviderName; } - set { dbProviderName = value; } - } - - [NonSerialized] - private IDbProvider dbProvider; - /// - /// - /// - public IDbProvider DbProvider - { - get - { - if (this.dbProvider == null && this.dbProviderName != null) - { - this.dbProvider = this.ApplicationContext.GetObject(this.dbProviderName); - } - return dbProvider; - } - } - - private bool isNew = true; - /// - /// - /// - public bool IsNew - { - get { return this.isNew; } - } - - private bool isPaused = true; - /// - /// - /// - public bool IsPaused - { - get { return isPaused; } - } - - /// - /// - /// - public void PauseConversation() - { - this.isPaused = true; - foreach (IConversationState innerConv in this.InnerConversations) - { - innerConv.PauseConversation(); - } - } - #endregion - - #region IObjectNameAware Members - /// - /// . It is used to valddate - /// - public string ObjectName - { - set - { - if (this.id != value) - { - throw new InvalidOperationException(String.Format("Id is different from spring name for this instance.. Currents='{0}', springName='{1}'", this.id, value)); - } - if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Begin of Conversation '{0}'", this.id)); - } - } - - #endregion - - #region IDictionary Members - /// - /// - /// - /// - /// - public void Add(string key, object value) - { - this.state.Add(key, value); - } - - /// - /// - /// - /// - /// - public bool ContainsKey(string key) - { - if (this.state.ContainsKey(key)) - { - return this.state.ContainsKey(key); - } - else if (this.parenteConversation != null) - { - return this.parenteConversation.ContainsKey(key); - } - else - { - return false; - } - } - - /// - /// - /// - public ICollection Keys - { - get - { - return this.state.Keys; - } - } - - /// - /// - /// - /// - /// - public bool Remove(string key) - { - return this.state.Remove(key); - } - - /// - /// - /// - /// - /// - /// - public bool TryGetValue(string key, out object value) - { - if (this.state.TryGetValue(key, out value)) - { - return true; - } - else if (this.parenteConversation != null && this.parenteConversation.TryGetValue(key, out value)) - { - return true; - } - else - { - return false; - } - } - - /// - /// - /// - public ICollection Values - { - get - { - return this.state.Values; - } - } - - /// - /// - /// - /// - /// - public object this[string key] - { - get - { - if (this.state.ContainsKey(key)) - { - return this.state[key]; - } - else if (this.parenteConversation != null) - { - return this.parenteConversation[key]; - } - else - { - return null; - } - } - set - { - this.state[key] = value; - } - } - - #endregion - - #region ICollection> Members - /// - /// - /// - /// - public void Add(KeyValuePair item) - { - this.state.Add(item); - } - - /// - /// - /// - public void Clear() - { - this.state.Clear(); - } - - /// - /// - /// - /// - /// - public bool Contains(KeyValuePair item) - { - if (this.state.Contains(item)) - { - return this.state.Contains(item); - } - else if (this.parenteConversation != null) - { - return this.parenteConversation.Contains(item); - } - else - { - return false; - } - } - - /// - /// - /// - /// - /// - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - this.state.CopyTo(array, arrayIndex); - } - - /// - /// - /// - public int Count - { - get - { - return this.state.Count; - } - } - - /// - /// - /// - public bool IsReadOnly - { - get - { - return this.state.IsReadOnly; - } - } - - /// - /// - /// - /// - /// - public bool Remove(KeyValuePair item) - { - return this.state.Remove(item); - } - - #endregion - - #region IEnumerable> Members - /// - /// - /// - /// - public IEnumerator> GetEnumerator() - { - return this.state.GetEnumerator(); - } - - #endregion - - #region IEnumerable Members - /// - /// - /// - /// - IEnumerator IEnumerable.GetEnumerator() - { - return this.state.GetEnumerator(); - } - - #endregion - - /// - /// A String representation from conversation. - /// - /// - public override string ToString() - { - String innerConsversationsStr = ""; - - String conector = ""; - foreach (IConversationState convItem in this.InnerConversations) - { - innerConsversationsStr += conector + convItem.ToString(); - } - - return String.Format("{{Id='{0}'; this.ParenteConversation.Id={1}; InnerConversations=[{2}]}}", - this.id, - this.ParenteConversation != null ? this.ParenteConversation.Id : "", - innerConsversationsStr - ); - } - - /// - /// HashCode. - /// - /// - public override int GetHashCode() - { - return base.GetHashCode(); - } - - #region IApplicationContextAware Members - private String applicationContextName; - [NonSerialized] - private IApplicationContext applicationContext = null; - /// - /// Returns the current context. Supports serialization and deserialization. - /// - public IApplicationContext ApplicationContext - { - set - { - this.applicationContext = value; - this.applicationContextName = this.applicationContext.Name; - } - get - { - if (this.applicationContext == null) - { - this.applicationContext = ContextRegistry.GetContext(this.applicationContextName); - } - return this.applicationContext; - } - } - - #endregion - } -} +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Web; +using Spring.Objects.Factory; +using Common.Logging; +using System.Collections.Generic; +using System.Collections; +using Spring.Data.Common; +using NHibernate; +using Spring.Context; +using Spring.Context.Support; + +namespace Spring.ConversationWA.Impl +{ + /// + /// Implementation of conversation in the infrastructure of Spring. + /// It avoid Circular Dependencies. + /// + /// Hailton de Castro + [Serializable] + public class WebConversationSpringState : IConversationState, IObjectNameAware, IApplicationContextAware + { + private const string SPRING_SESSSION_SCOPE_KEY = "spring.objects"; + private static readonly ILog LOG = LogManager.GetLogger(typeof(WebConversationSpringState)); + + /// + /// Default message for "CONVERSATION ALREADY HAS A PARENT" error. + /// + public static readonly String MSG_CONVERSATION_ALREADY_HAS_PARENT = + "This conversation already has a different parent." + + " Current: '{0}'. Tried: '{1}'"; + + private IDictionary state = new Dictionary(); + + #region IConversationState Members + + private String id; + /// + /// + /// + public string Id + { + get + { + return this.id; + } + set + { + this.id = value; + } + } + + /// + /// + /// + /// + public void EndConversation() + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("End of Conversation '{0}'", this.id)); + + IDictionary springSessionScope = (IDictionary)HttpContext.Current.Session[SPRING_SESSSION_SCOPE_KEY]; + if (springSessionScope == null) + { + throw new InvalidOperationException(string.Format("The 'spring session scope' is not located in the key {0} of HttpSessionState.", SPRING_SESSSION_SCOPE_KEY)); + } + + if (springSessionScope.Contains(this.Id)) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was Found on 'spring session scope'!", this.id)); + springSessionScope.Remove(this.id); + } + else + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("EndConversation: Id='{0}' Was NOT Found on 'spring session scope!", this.id)); + } + + List innerConversationsListTemp = new List(this.InnerConversations); + foreach (IConversationState innerConversationItem in innerConversationsListTemp) + { + innerConversationItem.EndConversation(); + } + + if (this.parentConversation != null) + { + this.parentConversation.InnerConversations.Remove(this); + } + + this.ended = true; + } + + private bool ended = false; + /// + /// + /// + public bool Ended + { + get { return ended; } + } + + private int timeOut = 180000; + /// + /// Default 180000. + /// + public int TimeOut + { + get { return timeOut; } + set { timeOut = value; } + } + + private IList innerConversations; + /// + /// + /// + public IList InnerConversations + { + get + { + if (this.innerConversations == null) + { + this.innerConversations = new InnerConversationList(this); + } + return this.innerConversations; + } + } + + private IConversationState parentConversation; + /// + /// + /// + public IConversationState ParentConversation + { + get + { + return this.parentConversation; + } + set + { + if (this.parentConversation != null && this.parentConversation != value) + { + throw new InvalidOperationException( + String.Format(MSG_CONVERSATION_ALREADY_HAS_PARENT, this.parentConversation.Id, value.Id)); + } + if (!this.IsNew) + { + throw new InvalidOperationException( + String.Format("This Conversation is not new." + + " Conversation.Id: '{0}'. Parent Tried: '{1}'", this.Id, value.Id)); + } + //Perhaps the father need not be new, only the child needs to be. + //if (!value.IsNew) + //{ + // throw new InvalidOperationException( + // String.Format("The Parent conversation is not new." + + // " Conversation.Id: '{0}'. Parent Tried: '{1}'", this.Id, value.Id)); + //} + + this.parentConversation = value; + if (!this.parentConversation.InnerConversations.Contains(this)) + { + this.parentConversation.InnerConversations.Add(this); + } + } + } + + private DateTime lastAccess = DateTime.Now; + /// + /// . + /// + public DateTime LastAccess + { + get { return lastAccess; } + set { lastAccess = value; } + } + + private IConversationManager conversationManager; + /// + /// + /// + public IConversationManager ConversationManager + { + get + { + return conversationManager; + } + set + { + conversationManager = value; + if (this.conversationManager.GetConversationById(this.Id) == null) + { + this.conversationManager.AddConversation(this); + } + } + } + + /// + /// + /// + public void StartResumeConversation() + { + this.isNew = false; + this.isPaused = false; + this.lastAccess = DateTime.Now; + + if (this.Ended) + { + throw new InvalidOperationException( + String.Format( + "StartResumeConversation: this conversation is ended." + + " Conversation.Id '{0}'", this.Id)); + } + if (this.ConversationManager != null) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("StartResumeConversation('{0}'): ConversationManager is not null.", this.Id)); + //if this is the root conversation. + if (this.ParentConversation == null) + { + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("SetActiveConversation('{0}'): ConversationManager is not null.", this.Id)); + //if this is the root conversation. + this.ConversationManager.SetActiveConversation(this); + + //makes SessionHolder to reopen this session + if (this.RootSessionPerConversation != null) + { + ISession session = this.SessionFactory.GetCurrentSession(); + if (this.RootSessionPerConversation != session) + { + //How it is implemented it will never happen, because of the sequence of previous calls: + // ConversationManager.SetActiveConversation -> SessionPerConversationScope.Open + // 'new InvalidOperationException("Participating in existing Hibernate SessionFactory IS NOT ALOWED.")' happen first. + throw new InvalidOperationException( + String.Format( + "StartResumeConversation: this.SessionFactory.GetCurrentSession()" + + " have a different instance than 'RootSessionPerConversation'" + + " from conversation '{0}'", this.Id)); + } + } + } + else + { + this.ParentConversation.StartResumeConversation(); + } + } + } + + private ISession rootSessionPerConversation; + /// + /// + /// + public ISession RootSessionPerConversation + { + get + { + if (this.ParentConversation != null) + { + return this.ParentConversation.RootSessionPerConversation; + } + else + { + return rootSessionPerConversation; + } + } + set + { + if (this.ParentConversation != null) + { + this.ParentConversation.RootSessionPerConversation = value; + } + else + { + rootSessionPerConversation = value; + } + } + } + + private String sessionFactoryName; + /// + /// "SessionFactory" name in the current context. + /// This approach is required to support serialization. + /// + public String SessionFactoryName + { + get { return sessionFactoryName; } + set { sessionFactoryName = value; } + } + + [NonSerialized] + private ISessionFactory sessionFactory; + /// + /// + /// + public ISessionFactory SessionFactory + { + get + { + if (this.sessionFactory == null && this.sessionFactoryName != null) + { + this.sessionFactory = this.ApplicationContext.GetObject(this.sessionFactoryName); + } + return sessionFactory; + } + } + + private String dbProviderName; + /// + /// "DbProvider" name in the current context. + /// This approach is required to support serialization. + /// + public String DbProviderName + { + get { return dbProviderName; } + set { dbProviderName = value; } + } + + [NonSerialized] + private IDbProvider dbProvider; + /// + /// + /// + public IDbProvider DbProvider + { + get + { + if (this.dbProvider == null && this.dbProviderName != null) + { + this.dbProvider = this.ApplicationContext.GetObject(this.dbProviderName); + } + return dbProvider; + } + } + + private bool isNew = true; + /// + /// + /// + public bool IsNew + { + get { return this.isNew; } + } + + private bool isPaused = true; + /// + /// + /// + public bool IsPaused + { + get { return isPaused; } + } + + /// + /// + /// + public void PauseConversation() + { + this.isPaused = true; + foreach (IConversationState conversation in this.InnerConversations) + { + conversation.PauseConversation(); + } + } + #endregion + + #region IObjectNameAware Members + /// + /// . It is used to valddate + /// + public string ObjectName + { + set + { + if (this.id != value) + { + throw new InvalidOperationException(String.Format("Id is different from spring name for this instance.. Currents='{0}', springName='{1}'", this.id, value)); + } + if (LOG.IsDebugEnabled) LOG.Debug(String.Format("Begin of Conversation '{0}'", this.id)); + } + } + + #endregion + + #region IDictionary Members + /// + /// + /// + /// + /// + public void Add(string key, object value) + { + this.state.Add(key, value); + } + + /// + /// + /// + /// + /// + public bool ContainsKey(string key) + { + if (this.state.ContainsKey(key)) + { + return this.state.ContainsKey(key); + } + else if (this.parentConversation != null) + { + return this.parentConversation.ContainsKey(key); + } + else + { + return false; + } + } + + /// + /// + /// + public ICollection Keys + { + get + { + return this.state.Keys; + } + } + + /// + /// + /// + /// + /// + public bool Remove(string key) + { + return this.state.Remove(key); + } + + /// + /// + /// + /// + /// + /// + public bool TryGetValue(string key, out object value) + { + if (this.state.TryGetValue(key, out value)) + { + return true; + } + else if (this.parentConversation != null && this.parentConversation.TryGetValue(key, out value)) + { + return true; + } + else + { + return false; + } + } + + /// + /// + /// + public ICollection Values + { + get + { + return this.state.Values; + } + } + + /// + /// + /// + /// + /// + public object this[string key] + { + get + { + if (this.state.ContainsKey(key)) + { + return this.state[key]; + } + else if (this.parentConversation != null) + { + return this.parentConversation[key]; + } + else + { + return null; + } + } + set + { + this.state[key] = value; + } + } + + #endregion + + #region ICollection> Members + /// + /// + /// + /// + public void Add(KeyValuePair item) + { + this.state.Add(item); + } + + /// + /// + /// + public void Clear() + { + this.state.Clear(); + } + + /// + /// + /// + /// + /// + public bool Contains(KeyValuePair item) + { + if (this.state.Contains(item)) + { + return this.state.Contains(item); + } + else if (this.parentConversation != null) + { + return this.parentConversation.Contains(item); + } + else + { + return false; + } + } + + /// + /// + /// + /// + /// + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + this.state.CopyTo(array, arrayIndex); + } + + /// + /// + /// + public int Count + { + get + { + return this.state.Count; + } + } + + /// + /// + /// + public bool IsReadOnly + { + get + { + return this.state.IsReadOnly; + } + } + + /// + /// + /// + /// + /// + public bool Remove(KeyValuePair item) + { + return this.state.Remove(item); + } + + #endregion + + #region IEnumerable> Members + /// + /// + /// + /// + public IEnumerator> GetEnumerator() + { + return this.state.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + /// + /// + /// + /// + IEnumerator IEnumerable.GetEnumerator() + { + return this.state.GetEnumerator(); + } + + #endregion + + /// + /// A String representation from conversation. + /// + /// + public override string ToString() + { + String innerConsversationsStr = ""; + + String conector = ""; + foreach (IConversationState convItem in this.InnerConversations) + { + innerConsversationsStr += conector + convItem; + } + + return String.Format("{{Id='{0}'; this.ParentConversation.Id={1}; InnerConversations=[{2}]}}", + this.id, + this.ParentConversation != null ? this.ParentConversation.Id : "", + innerConsversationsStr + ); + } + + #region IApplicationContextAware Members + private String applicationContextName; + [NonSerialized] + private IApplicationContext applicationContext = null; + /// + /// Returns the current context. Supports serialization and deserialization. + /// + public IApplicationContext ApplicationContext + { + set + { + this.applicationContext = value; + this.applicationContextName = this.applicationContext.Name; + } + get + { + if (this.applicationContext == null) + { + this.applicationContext = ContextRegistry.GetContext(this.applicationContextName); + } + return this.applicationContext; + } + } + + #endregion + } +} diff --git a/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationScope.cs b/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationScope.cs index 969c23a5..fc4fb0b3 100644 --- a/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationScope.cs +++ b/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationScope.cs @@ -1,14 +1,14 @@ -#region Licence +#region License /* - * Copyright © 2002-2007 the original author or authors. - * + * Copyright © 2002-2011 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,7 @@ namespace Spring.Data.NHibernate.Support { /// ///Based on - /// for dupport to 'session-per-conversation' pattern. + /// for support of 'session-per-conversation' pattern. /// ///Hailton de Castro [Serializable] @@ -50,7 +50,7 @@ namespace Spring.Data.NHibernate.Support /// /// The logging instance. /// - protected readonly ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); + protected readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly SessionPerConversationScopeSettings settings; @@ -115,7 +115,7 @@ namespace Spring.Data.NHibernate.Support } /// - /// Get or set the configured EntityInterceptor + /// Get the configured EntityInterceptor /// public IInterceptor EntityInterceptor { @@ -177,7 +177,6 @@ namespace Spring.Data.NHibernate.Support public virtual void Dispose() { //no OP - log.Warn("I'm not doing anything"); } #endregion @@ -187,16 +186,16 @@ namespace Spring.Data.NHibernate.Support /// /// Open a new session or reconect the /// in . - /// Participates in an existing session registed with spring's + /// Participating in an existing session registed with /// is not alowed. /// /// /// /// /// - /// If there is another conversation with a ISession with opened - /// IDbConnection. - /// If trie to participating in existing Hibernate SessionFactory + /// If there is another conversation with a with opened + /// . + /// If attempting to participate in an existing NHibernate /// managed by . /// /// @@ -226,12 +225,12 @@ namespace Spring.Data.NHibernate.Support if (TransactionSynchronizationManager.HasResource(activeConversation.SessionFactory)) { // Do not modify the Session: just set the participate flag. - if (isDebugEnabled) log.Debug("Participating in existing Hibernate SessionFactory IS NOT ALOWED."); - throw new InvalidOperationException("Participating in existing Hibernate SessionFactory IS NOT ALOWED."); + if (isDebugEnabled) log.Debug("Participating in existing NHibernate SessionFactory IS NOT ALLOWED."); + throw new InvalidOperationException("Participating in existing NHibernate SessionFactory IS NOT ALLOWED."); } else { - if (isDebugEnabled) log.Debug("Opening single Hibernate Session in SessionPerConversationScope"); + if (isDebugEnabled) log.Debug("Opening single NHibernate Session in SessionPerConversationScope"); TransactionSynchronizationManager.BindResource(activeConversation.SessionFactory, new LazySessionPerConversationHolder(this, activeConversation, allManagedConversation)); SetOpen(true); @@ -247,17 +246,17 @@ namespace Spring.Data.NHibernate.Support /// /// Close the current view's session and unregisters - /// from spring's . + /// from . /// - /// The session factory that IConversationState on use + /// The session factory that on use /// A list of conversations which the session can be closed or disconnected /// /// /// If start/resume a conversation from a - /// IConversationManager when exists a diferent IConversationManager - /// with open ISession registered on TransactionSynchronizationManager + /// when exists a different + /// with open registered on /// - /// If the holder on TransactionSynchronizationManager, is not a LazySessionPerConversationHolder. + /// If the holder on , is not a . /// /// public void Close(ISessionFactory sessionFactory, ICollection allManagedConversation) @@ -370,11 +369,11 @@ namespace Spring.Data.NHibernate.Support /// /// This sessionHolder creates a session for the active conversation only if it is - /// needed (. + /// needed (). /// /// - /// Although a NHibernateSession deferes creation of db-connections until they are really - /// needed, instantiation a session is imho still more expensive than this LazySessionHolder. (EE) + /// Although a NHibernateSession defers creation of db-connections until they are really + /// needed, instantiation a session is still more expensive than using LazySessionHolder. /// private class LazySessionPerConversationHolder : SessionHolder { diff --git a/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationSettings.cs b/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationSettings.cs index 85a2c6f0..0170aee1 100644 --- a/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationSettings.cs +++ b/src/Spring/Spring.ConversationWA.NH32/Data/NHibernate/Support/SessionPerConversationSettings.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/src/Spring/Spring.ConversationWA.NH32/Spring.ConversationWA.NH32.2010.csproj b/src/Spring/Spring.ConversationWA.NH32/Spring.ConversationWA.NH32.2010.csproj index 767d94eb..de80e395 100644 --- a/src/Spring/Spring.ConversationWA.NH32/Spring.ConversationWA.NH32.2010.csproj +++ b/src/Spring/Spring.ConversationWA.NH32/Spring.ConversationWA.NH32.2010.csproj @@ -61,9 +61,9 @@ - - - + + + @@ -72,7 +72,6 @@ nant.xsd - diff --git a/src/Spring/Spring.ConversationWA.NH33/ConversationWA/Imple/dontdelete.txt b/src/Spring/Spring.ConversationWA.NH33/ConversationWA/Imple/dontdelete.txt deleted file mode 100644 index 55d0ec6d..00000000 --- a/src/Spring/Spring.ConversationWA.NH33/ConversationWA/Imple/dontdelete.txt +++ /dev/null @@ -1 +0,0 @@ -sources are linked here from Spring.ConversationWA.NH32 \ No newline at end of file diff --git a/src/Spring/Spring.ConversationWA.NH33/Spring.ConversationWA.NH33.2010.csproj b/src/Spring/Spring.ConversationWA.NH33/Spring.ConversationWA.NH33.2010.csproj index 9c2392eb..35cd6d3d 100644 --- a/src/Spring/Spring.ConversationWA.NH33/Spring.ConversationWA.NH33.2010.csproj +++ b/src/Spring/Spring.ConversationWA.NH33/Spring.ConversationWA.NH33.2010.csproj @@ -66,14 +66,14 @@ Conversation\IConversationState.cs - - Conversation\Imple\InnerConversationList.cs + + Conversation\Impl\InnerConversationList.cs - - Conversation\Imple\WebConversationManager.cs + + Conversation\Impl\WebConversationManager.cs - - Conversation\Imple\WebConversationSpringState.cs + + Conversation\Impl\WebConversationSpringState.cs Data\NHibernate\Support\SessionPerConversationScope.cs diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/ConversationEvidenceBsnImpl.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/ConversationEvidenceBsnImpl.cs index f76d04d1..c5ce9eac 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/ConversationEvidenceBsnImpl.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/ConversationEvidenceBsnImpl.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Data; using System.Configuration; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/IConversationEvidenceBsn.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/IConversationEvidenceBsn.cs index 2420e957..003533dd 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/IConversationEvidenceBsn.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/IConversationEvidenceBsn.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/INoDeferedErrorBsn.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/INoDeferedErrorBsn.cs index 75a1b13d..55dc6c58 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/INoDeferedErrorBsn.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/INoDeferedErrorBsn.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/NoDeferedErrorBsnImpl.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/NoDeferedErrorBsnImpl.cs index 130b83c5..c440a266 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/NoDeferedErrorBsnImpl.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Bsn/NoDeferedErrorBsnImpl.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; @@ -55,7 +75,7 @@ namespace Spring.Bsn SPCMasterEnt masterEnt3 = sessionNoConv.Get(3); Assert.AreEqual(1, masterEnt3.SPCDetailEntList.Count, "masterEnt3.SPCDetailEntList.Count"); - Assert.AreEqual(1, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(1, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); } #endregion diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvBeginBasePage.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvBeginBasePage.cs index a9f7d305..3e99e9b0 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvBeginBasePage.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvBeginBasePage.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvEndBasePage.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvEndBasePage.cs index c283e494..439a9378 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvEndBasePage.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/PatialEndConvEndBasePage.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SerializeConversationTestModule.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SerializeConversationTestModule.cs index 104ba954..e212c362 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SerializeConversationTestModule.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SerializeConversationTestModule.cs @@ -1,4 +1,24 @@ -using System; +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SimpleTest.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SimpleTest.cs index 73f57f00..53fb65f7 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SimpleTest.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/SimpleTest.cs @@ -1,4 +1,24 @@ -using System; +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/WebConversationStateTest.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/ConversationWA/WebConversationStateTest.cs index d08547f7d1aa6e0965fa301dc26f1190c295e800..07246fcacfb7d40ed0388f48ecc88e4c1a574954 100644 GIT binary patch delta 1730 zcmZuxUuc_E6hGgnO*c}Mtqn5jxMWVY(xq7`cIZo5x6#hhLYum+Y+-4WX3?6|B()u) zpGeV{QR$9$B07EY&zo>zzKkKGPtuhUgvuWJFy@<#J`DVWZ2r#qk}pjdmwfl!bARXG z@0^?OK5yFkvdMk&_#hQ1O&Q8ko^oVp7}7K}IV$4YN_+IzO`W^jpKXN#h?i7)j-wV&;&9U%8E*$jOaTcHVemT^xB|4sYSwi zyiG%%s*pSjc>%ZHTqTi;Sb26OXibHe1#)GAOM1+Zj73rDDZxCcMzw@eKox-%iz%d1 zsyKYw@YOd;!pRgo#e=K0cn?oHZzxRtpvHivama=S^em??pCv{7c-T%=)DVI5$@BN`K&&ZX=tQ>Idp9vdq$mQVDv7e0`xM| z8KA_ffHZ{M>N6Ia#WuBrD|uCdlJ_937PbW^jT>tG+o;dBR#&$=lxaAKuo7VBzb5o6 z$ro1k|7k~@C5OLo%*s}Xqs|_?zU%yMF1NqL*IV1{N5RjY<=&0~{;ltPwb{=o#uH&a|x$kTXZ^Sy)Y$LX| zkINSh@J2jzZOw5eZERw!oqu{Wp(l<_G}+u+;UI5+@G{?h?>WBtehY8AZFcYCFU?RU zxNULSZn=ZaeB$FvI3#TFlZQ`d@&rem%@L z`$DQ%|K{%i-~WD64`2N-)5>GFVtnz2(Sq;Yh_`d$PQ>2cY;icT-eJGJb89y=dwF@Y x*RE|21o_1Wy}T5BWJmre@8kRb3`&K(^;fSA{d+2KE&7bpBSiju+i@PW{15mAey;!k delta 1062 zcmcaNi)GnV7N-CICI_%fOpalFGg*M0Z?Y7d47VPGCqphn0YeT$>g0v2!jtpZL^j8; z6)(1); - Assert.AreEqual(1, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(1, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); SessionScopeSettings sessionScopeSettings = new SessionScopeSettings(this.sessionFactory); sessionScopeSettings.SingleSession = true; @@ -110,20 +110,20 @@ public partial class ConnectionReleaseModeIssue : System.Web.UI.Page, IApplicati ISession sessionB = this.SessionFactory.GetCurrentSession(); masterEnt = sessionB.Get(1); - Assert.AreEqual(2, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(2, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); Assert.AreSame(sessionA, sessionB, "sessionA, sessionB"); } SPCMasterEnt masterEnt2 = sessionA.Get(2); - Assert.AreEqual(3, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(3, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); Assert.AreEqual(1, masterEnt2.SPCDetailEntList.Count, "masterEnt2.SPCDetailEntList.Count"); - Assert.AreEqual(4, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(4, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); SPCMasterEnt masterEnt3 = sessionA.Get(3); - Assert.AreEqual(5, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(5, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); Assert.AreEqual(1, masterEnt3.SPCDetailEntList.Count, "masterEnt3.SPCDetailEntList.Count"); - Assert.AreEqual(6, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(6, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); //Renew the conversation. @@ -152,7 +152,7 @@ public partial class ConnectionReleaseModeIssue : System.Web.UI.Page, IApplicati ConnectionReleaseMode connReleaseModeOriginal = settings.ConnectionReleaseMode; this.setConnectionReleaseModeByReflection(settings, ConnectionReleaseMode.AfterTransaction); - CountGetConnDbProvider.Count = 0; + ConnectionCreationTrackingDbProvider.Count = 0; this.ConnectionReleaseModeIssueBsn.Test(); this.setConnectionReleaseModeByReflection(settings, connReleaseModeOriginal); @@ -172,19 +172,19 @@ public partial class ConnectionReleaseModeIssue : System.Web.UI.Page, IApplicati //with no conversation SessionScopeSettings sessionScopeSettings = new SessionScopeSettings(this.sessionFactory); - CountGetConnDbProvider.Count = 0; + ConnectionCreationTrackingDbProvider.Count = 0; using (new SessionScope(sessionScopeSettings, true)) { ISession sessionNoConv = this.SessionFactory.GetCurrentSession(); SPCMasterEnt masterEnt2 = sessionNoConv.Get(2); - Assert.AreEqual(1, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(1, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); Assert.AreEqual(1, masterEnt2.SPCDetailEntList.Count, "masterEnt2.SPCDetailEntList.Count"); - Assert.AreEqual(2, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(2, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); SPCMasterEnt masterEnt3 = sessionNoConv.Get(3); - Assert.AreEqual(3, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(3, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); Assert.AreEqual(1, masterEnt3.SPCDetailEntList.Count, "masterEnt3.SPCDetailEntList.Count"); - Assert.AreEqual(4, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(4, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); } this.setConnectionReleaseModeByReflection(settings, connReleaseModeOriginal); @@ -206,11 +206,11 @@ public partial class ConnectionReleaseModeIssue : System.Web.UI.Page, IApplicati this.setConnectionReleaseModeByReflection(settings, ConnectionReleaseMode.OnClose); //with conversation and "connection.release_mode" "on_close"(AfterTransaction) - CountGetConnDbProvider.Count = 0; + ConnectionCreationTrackingDbProvider.Count = 0; this.Conversation.StartResumeConversation(); ISession sessionA = this.SessionFactory.GetCurrentSession(); SPCDetailEnt detailEnt = sessionA.Get(1); - Assert.AreEqual(1, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(1, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); SessionScopeSettings sessionScopeSettings = new SessionScopeSettings(this.sessionFactory); sessionScopeSettings.SingleSession = true; @@ -226,7 +226,7 @@ public partial class ConnectionReleaseModeIssue : System.Web.UI.Page, IApplicati Assert.AreEqual(3, masterEnt.SPCDetailEntList.Count, "masterEnt.SPCDetailEntList.Count"); - Assert.AreEqual(1, CountGetConnDbProvider.Count, "CountGetConnDbProvider.Count"); + Assert.AreEqual(1, ConnectionCreationTrackingDbProvider.Count, "ConnectionCreationTrackingDbProvider.Count"); //Renew the conversation. this.Conversation.EndConversation(); diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/IoeTests.aspx.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/IoeTests.aspx.cs index 82221b7a..166ee485 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/IoeTests.aspx.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/IoeTests.aspx.cs @@ -9,7 +9,7 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Spring.ConversationWA; -using Spring.ConversationWA.Imple; +using Spring.ConversationWA.Impl; using System.Text.RegularExpressions; using NHibernate; using Spring.Data.NHibernate.Support; @@ -176,9 +176,9 @@ public partial class IoeTests : System.Web.UI.Page { otherConversationState = new WebConversationSpringState(); otherConversationState.Id = "otherConversationState"; - //try second by 'ParenteConversation = ' - this.ConversationAA.ParenteConversation = otherConversationState; - throw new Exception("NOT OK: No raise for 'this.ConversationAA.ParenteConversation = otherConversationState'"); + //try second by 'ParentConversation = ' + this.ConversationAA.ParentConversation = otherConversationState; + throw new Exception("NOT OK: No raise for 'this.ConversationAA.ParentConversation = otherConversationState'"); } catch (InvalidOperationException ioe) { @@ -216,8 +216,8 @@ public partial class IoeTests : System.Web.UI.Page { otherConversationState = new WebConversationSpringState(); otherConversationState.Id = "otherConversationState"; - //try second by 'ParenteConversation = ' - otherConversationState.ParenteConversation = this.ConversationA; + //try second by 'ParentConversation = ' + otherConversationState.ParentConversation = this.ConversationA; this.Session["testResult"] = "OK"; } finally @@ -264,9 +264,9 @@ public partial class IoeTests : System.Web.UI.Page otherConversationState.Id = "otherConversationState"; // make not new otherConversationState.StartResumeConversation(); - //try second by 'ParenteConversation = ' - otherConversationState.ParenteConversation = this.ConversationA; - throw new Exception("NOT OK: No raise for 'this.ConversationAA.ParenteConversation = otherConversationState'"); + //try second by 'ParentConversation = ' + otherConversationState.ParentConversation = this.ConversationA; + throw new Exception("NOT OK: No raise for 'this.ConversationAA.ParentConversation = otherConversationState'"); } catch (InvalidOperationException ioe) { @@ -305,8 +305,8 @@ public partial class IoeTests : System.Web.UI.Page otherConversationState = new WebConversationSpringState(); otherConversationState.Id = "otherConversationState"; // leave new - //try second by 'ParenteConversation = ' - otherConversationState.ParenteConversation = this.ConversationA; + //try second by 'ParentConversation = ' + otherConversationState.ParentConversation = this.ConversationA; this.Session["testResult"] = "OK"; } finally @@ -366,7 +366,7 @@ public partial class IoeTests : System.Web.UI.Page private void participatingHibernateNotAlowed() { - Regex msgErrorRx = new Regex(".*Participating.*Hibernate.*NOT.*ALOWED.*"); + Regex msgErrorRx = new Regex(".*Participating.*Hibernate.*NOT.*ALLOWED.*"); try { //No raise diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config b/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config index f9452f87..8074dc43 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config @@ -12,12 +12,12 @@ - + - + @@ -25,7 +25,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -62,10 +62,10 @@ - + - + @@ -74,20 +74,20 @@ - + - + - + - + @@ -97,9 +97,9 @@ - + - + @@ -110,7 +110,7 @@ - + @@ -147,7 +147,7 @@ - + @@ -160,14 +160,14 @@ - + - + @@ -180,7 +180,7 @@ - + @@ -197,18 +197,18 @@ - + - + - + @@ -217,15 +217,15 @@ - + - + - + @@ -238,14 +238,14 @@ - + - + @@ -261,21 +261,21 @@ - + - + - + @@ -287,7 +287,7 @@ - + @@ -303,7 +303,7 @@ - + @@ -313,7 +313,7 @@ - + @@ -344,7 +344,7 @@ - + diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCDetailEnt.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCDetailEnt.cs index 3070a489..11a68687 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCDetailEnt.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCDetailEnt.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCMasterEnt.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCMasterEnt.cs index 76411178..5a04a63b 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCMasterEnt.cs +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Entities/SPCMasterEnt.cs @@ -1,3 +1,23 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + using System; using System.Collections.Generic; using System.Text; diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2008.csproj b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2008.csproj index 3a8a419d..a75c19f6 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2008.csproj +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2008.csproj @@ -87,7 +87,7 @@ - + diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2010.csproj b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2010.csproj index 99f894ca..9ee1dc58 100644 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2010.csproj +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring.ConversationWA.NH32.Tests.2010.csproj @@ -101,7 +101,7 @@ - + diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/ConnectionCreationTrackingDbProvider.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/ConnectionCreationTrackingDbProvider.cs new file mode 100644 index 00000000..78d9a610 --- /dev/null +++ b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/ConnectionCreationTrackingDbProvider.cs @@ -0,0 +1,49 @@ +#region License + +/* + * Copyright © 2002-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Text; +using Spring.Data.Common; +using System.Data; + +namespace Spring.Spring.Data.Common +{ + /// + /// Count the number of calls to "CreateConnection()". + /// + public class ConnectionCreationTrackingDbProvider : DelegatingDbProvider + { + /// + /// Count of calls to + /// + public static Int32 Count = 0; + + /// + /// Count. + /// + /// + public override IDbConnection CreateConnection() + { + Count++; + return this.TargetDbProvider.CreateConnection(); + } + } +} diff --git a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/CountGetConnDbProvider.cs b/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/CountGetConnDbProvider.cs deleted file mode 100644 index 66f4a0bc..00000000 --- a/test/Spring/Spring.ConversationWA.NH32.Tests/Spring/Data/Common/CountGetConnDbProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Spring.Data.Common; -using System.Data; - -namespace Spring.Spring.Data.Common -{ - /// - /// Count the number of calls to "CreateConnection()". - /// - public class CountGetConnDbProvider : DelegatingDbProvider - { - /// - /// Count of calls to - /// - public static Int32 Count = 0; - - /// - /// Count. - /// - /// - public override IDbConnection CreateConnection() - { - Count++; - return this.TargetDbProvider.CreateConnection(); - } - } -} diff --git a/test/Spring/Spring.ConversationWA.NH33.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config b/test/Spring/Spring.ConversationWA.NH33.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config index dbff9f29..28ebd70d 100644 --- a/test/Spring/Spring.ConversationWA.NH33.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config +++ b/test/Spring/Spring.ConversationWA.NH33.Tests/Data/Spring/ConversationWA/WebConversationStateTest/services.xml.config @@ -12,12 +12,12 @@ - + - + @@ -25,7 +25,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -62,10 +62,10 @@ - + - + @@ -74,20 +74,20 @@ - + - + - + - + @@ -97,7 +97,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -147,7 +147,7 @@ - + @@ -160,14 +160,14 @@ - + - + @@ -180,7 +180,7 @@ - + @@ -197,14 +197,14 @@ - + - + @@ -217,15 +217,15 @@ - + - + - + @@ -238,14 +238,14 @@ - + - + @@ -261,21 +261,21 @@ - + - + - + @@ -287,7 +287,7 @@ - + @@ -303,7 +303,7 @@ - + @@ -313,7 +313,7 @@ - + diff --git a/test/Spring/Spring.ConversationWA.NH33.Tests/Spring.ConversationWA.NH33.Tests.2010.csproj b/test/Spring/Spring.ConversationWA.NH33.Tests/Spring.ConversationWA.NH33.Tests.2010.csproj index ed2bb98c..861310fa 100644 --- a/test/Spring/Spring.ConversationWA.NH33.Tests/Spring.ConversationWA.NH33.Tests.2010.csproj +++ b/test/Spring/Spring.ConversationWA.NH33.Tests/Spring.ConversationWA.NH33.Tests.2010.csproj @@ -116,8 +116,8 @@ Entities\SPCMasterEnt.cs - - Spring\Data\Common\CountGetConnDbProvider.cs + + Spring\Data\Common\ConnectionCreationTrackingDbProvider.cs