///
/// Shared state is very useful if you have data that needs to be shared by all instances
- /// of the same page (or other ).
+ /// of e.g. the same webform (or other IHttpHandlers).
///
///
- /// For example, class implements this interface, which allows
+ /// For example, Spring.Web.UI.Page class implements this interface, which allows
/// each page derived from it to cache localizalization resources and parsed data binding
/// expressions only once and then reuse the cached values, regardless of how many instances
/// of the page are created.
@@ -47,12 +47,8 @@ namespace Spring.Web.Support
{
///
/// Gets or sets the that should be used
- /// to store shared state for the .
+ /// to store shared state for this instance.
///
- ///
- /// The that should be used
- /// to store shared state for the .
- ///
IDictionary SharedState { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/ISharedStateFactory.cs b/src/Spring/Spring.Core/Objects/ISharedStateFactory.cs
new file mode 100644
index 00000000..23a5921d
--- /dev/null
+++ b/src/Spring/Spring.Core/Objects/ISharedStateFactory.cs
@@ -0,0 +1,55 @@
+#region License
+
+/*
+ * Copyright © 2002-2008 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
+
+#region Imports
+
+using System.Collections;
+
+#endregion
+
+namespace Spring.Objects
+{
+ ///
+ /// Abstracts the state sharing strategy used
+ /// by
+ ///
+ /// Erich Eichinger
+ public interface ISharedStateFactory
+ {
+ ///
+ /// Indicate, whether the given instance can be served by this factory
+ ///
+ /// the instance to serve state
+ /// the name of the instance
+ ///
+ /// a boolean value indicating, whether state can
+ /// be served for the given instance or not.
+ ///
+ bool CanProvideState(object instance, string name);
+
+ ///
+ /// Returns the shared state for the given instance.
+ ///
+ /// the instance to obtain shared state for.
+ /// the name of this instance
+ /// a dictionary containing shared state for or null.
+ IDictionary GetSharedStateFor( object instance, string name );
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/Support/AbstractSharedStateFactory.cs b/src/Spring/Spring.Core/Objects/Support/AbstractSharedStateFactory.cs
new file mode 100644
index 00000000..41e5d684
--- /dev/null
+++ b/src/Spring/Spring.Core/Objects/Support/AbstractSharedStateFactory.cs
@@ -0,0 +1,145 @@
+#region License
+
+/*
+ * Copyright © 2002-2008 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
+
+#region Imports
+
+using System;
+using System.Collections;
+using Spring.Collections;
+using Spring.Core;
+using Spring.Util;
+
+#endregion
+
+namespace Spring.Objects.Support
+{
+ ///
+ /// Convenience base class for implementations.
+ ///
+ public abstract class AbstractSharedStateFactory : ISharedStateFactory, IOrdered
+ {
+ private bool _caseSensitiveState;
+ private int _order = Int32.MaxValue;
+ private readonly IDictionary _sharedStateCache = new Hashtable();
+
+ ///
+ /// Create shared state dictionaries case-sensitive or case-insensitive?
+ ///
+ public bool CaseSensitiveState
+ {
+ get { return _caseSensitiveState; }
+ set { _caseSensitiveState = value; }
+ }
+
+ ///
+ /// Gets a dictionary acc. to the type of .
+ /// If no dictionary is found, create it according to
+ ///
+ /// the instance to obtain shared state for
+ /// the name of the instance.
+ ///
+ /// A dictionary containing the 's state,
+ /// or null if no state can be served by this provider.
+ ///
+ public IDictionary GetSharedStateFor( object instance, string name )
+ {
+ AssertUtils.ArgumentNotNull(instance, "instance");
+
+ if (!CanProvideState(instance, name))
+ {
+ return null;
+ }
+
+ object key = GetKey(instance, name);
+ if (key == null)
+ {
+ return null;
+ }
+
+ IDictionary sharedState = (IDictionary) _sharedStateCache[key];
+ if (sharedState == null)
+ {
+ lock(_sharedStateCache)
+ {
+ sharedState = (IDictionary) _sharedStateCache[key];
+ if (sharedState == null)
+ {
+ sharedState = CreateSharedStateDictionary(key);
+ _sharedStateCache[key] = sharedState;
+ }
+ }
+ }
+ return sharedState;
+ }
+
+ ///
+ /// A number indicating the priority of this ( for more).
+ ///
+ public virtual int Order
+ {
+ get { return _order; }
+ set { _order = value; }
+ }
+
+ ///
+ /// Creates a dictionary to hold the shared state identified by .
+ ///
+ /// a key to create the dictionary for.
+ /// a dictionary according to and .
+ protected virtual IDictionary CreateSharedStateDictionary(object key)
+ {
+ return _caseSensitiveState ? new Hashtable() : new CaseInsensitiveHashtable();
+ }
+
+ ///
+ /// Indicate, whether the given instance will be served by this provider
+ ///
+ /// the instance to serve state
+ /// the name of the instance
+ ///
+ /// a boolean value indicating, whether state shall
+ /// be resolved for the given instance or not.
+ ///
+ public virtual bool CanProvideState(object instance, string name)
+ {
+ return true;
+ }
+
+ ///
+ /// Create the key used for obtaining the state dictionary for .
+ ///
+ /// the instance to create the key for
+ /// the name of the instance.
+ ///
+ /// the key identifying the state dictionary to be used for
+ /// or null, if this state manager doesn't serve the given instance.
+ ///
+ ///
+ ///
+ /// Implementations may choose to return null from this method to indicate,
+ /// that they won't serve state for the given instance.
+ ///
+ ///
+ /// Note:Keys returned by this method are always treated case-sensitive!
+ ///
+ ///
+ protected abstract object GetKey(object instance, string name);
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Objects/Support/ByTypeSharedStateFactory.cs b/src/Spring/Spring.Core/Objects/Support/ByTypeSharedStateFactory.cs
new file mode 100644
index 00000000..7199fd3e
--- /dev/null
+++ b/src/Spring/Spring.Core/Objects/Support/ByTypeSharedStateFactory.cs
@@ -0,0 +1,104 @@
+#region License
+
+/*
+ * Copyright © 2002-2008 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
+
+#region Imports
+
+using System;
+
+#endregion
+
+namespace Spring.Objects.Support
+{
+ ///
+ /// Serves shared state on a by-type basis.
+ ///
+ public class ByTypeSharedStateFactory : AbstractSharedStateFactory
+ {
+ private Type[] typeFilter;
+
+ ///
+ /// Limit object types to be served by this state manager.
+ ///
+ ///
+ /// Only objects assignable to one of the types in this list
+ /// will be served state by this manager.
+ ///
+ public Type[] TypeFilter
+ {
+ set { typeFilter = value; }
+ }
+
+ ///
+ /// Creates a new instance matching all types by default.
+ ///
+ public ByTypeSharedStateFactory()
+ {}
+
+ ///
+ /// Creates a new instance matching only specified list of types.
+ ///
+ /// the list of types to serve.
+ public ByTypeSharedStateFactory(Type[] typeFilter)
+ {
+ this.typeFilter = typeFilter;
+ }
+
+ ///
+ /// Indicate, whether the given instance will be served by this provider
+ ///
+ /// the instance to serve state
+ /// the name of the instance
+ ///
+ /// a boolean value indicating, whether state shall
+ /// be resolved for the given instance or not.
+ ///
+ public override bool CanProvideState( object instance, string name )
+ {
+ if (instance == null)
+ return false;
+
+ if (typeFilter == null)
+ return true;
+
+ Type instanceType = instance.GetType();
+ foreach (Type type in typeFilter)
+ {
+ if (type.IsAssignableFrom( instanceType ))
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Returns the for the given .
+ ///
+ /// the instance to obtain the key for.
+ /// the name of the instance (ignored by this provider)
+ /// instance.GetType() if it matches the list. Null otherwise.
+ ///
+ /// This method will only be called if returned true previously.
+ ///
+ protected override object GetKey( object instance, string name )
+ {
+ Type key = instance.GetType();
+ return key;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Spring.Core.2005.csproj b/src/Spring/Spring.Core/Spring.Core.2005.csproj
index 892dbde2..ea4ae66b 100644
--- a/src/Spring/Spring.Core/Spring.Core.2005.csproj
+++ b/src/Spring/Spring.Core/Spring.Core.2005.csproj
@@ -554,6 +554,7 @@
+
@@ -587,6 +588,8 @@
+
+
@@ -888,6 +891,7 @@
Code
+
Code
@@ -897,6 +901,7 @@
Code
+
Code
diff --git a/src/Spring/Spring.Core/Spring.Core.2008.csproj b/src/Spring/Spring.Core/Spring.Core.2008.csproj
index 605983ae..28d30ee9 100644
--- a/src/Spring/Spring.Core/Spring.Core.2008.csproj
+++ b/src/Spring/Spring.Core/Spring.Core.2008.csproj
@@ -570,6 +570,7 @@
+
@@ -603,6 +604,8 @@
+
+
@@ -904,6 +907,7 @@
Code
+
Code
@@ -913,6 +917,7 @@
Code
+
Code
diff --git a/src/Spring/Spring.Core/Util/ArrayUtils.cs b/src/Spring/Spring.Core/Util/ArrayUtils.cs
index b5c2291e..52dbaae6 100644
--- a/src/Spring/Spring.Core/Util/ArrayUtils.cs
+++ b/src/Spring/Spring.Core/Util/ArrayUtils.cs
@@ -34,6 +34,22 @@ namespace Spring.Util
/// Aleksandar Seovic
public sealed class ArrayUtils
{
+ ///
+ /// Checks if the given array or collection has elements and none of the elements is null.
+ ///
+ /// the collection to be checked.
+ /// true if the collection has a length and contains only non-null elements.
+ public static bool HasElements(ICollection collection)
+ {
+ if (!HasLength(collection)) return false;
+ IEnumerator it = collection.GetEnumerator();
+ while(it.MoveNext())
+ {
+ if (it.Current == null ) return false;
+ }
+ return true;
+ }
+
///
/// Checks if the given array or collection is null or has no elements.
///
diff --git a/src/Spring/Spring.Core/Util/AssertUtils.cs b/src/Spring/Spring.Core/Util/AssertUtils.cs
index c5394745..6b252d51 100644
--- a/src/Spring/Spring.Core/Util/AssertUtils.cs
+++ b/src/Spring/Spring.Core/Util/AssertUtils.cs
@@ -168,6 +168,29 @@ namespace Spring.Util
}
}
+ ///
+ /// Checks the value of the supplied and throws
+ /// an if it is , contains no elements or only null elements.
+ ///
+ /// The array or collection to check.
+ /// The argument name.
+ ///
+ /// If the supplied is ,
+ /// contains no elements or only null elements.
+ ///
+ public static void ArgumentHasElements(ICollection argument, string name)
+ {
+ if (!ArrayUtils.HasElements(argument))
+ {
+ throw new ArgumentException(
+ name,
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "Argument '{0}' must not be null or resolve to an empty collection and must contain non-null elements", name));
+ }
+ }
+
+
///
/// Checks whether the specified can be cast
/// into the .
diff --git a/src/Spring/Spring.Web.Extensions/Web/Script/Services/ScriptHandlerFactory.cs b/src/Spring/Spring.Web.Extensions/Web/Script/Services/ScriptHandlerFactory.cs
index eefc76d8..4173b511 100644
--- a/src/Spring/Spring.Web.Extensions/Web/Script/Services/ScriptHandlerFactory.cs
+++ b/src/Spring/Spring.Web.Extensions/Web/Script/Services/ScriptHandlerFactory.cs
@@ -26,7 +26,6 @@ using System.Web;
using System.Web.Script.Services;
using Spring.Context;
-using Spring.Context.Support;
using Spring.Util;
using Spring.Web.Services;
using Spring.Web.Support;
diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
index b6932600..c9256a15 100644
--- a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
+++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
@@ -29,8 +29,11 @@ using System.Web;
using System.Web.Hosting;
using Common.Logging;
using Spring.Collections;
+using Spring.Objects;
+using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Objects.Factory.Xml;
+using Spring.Objects.Support;
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs b/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs
index 43eae8c3..1a1a515c 100644
--- a/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs
+++ b/src/Spring/Spring.Web/Context/Support/WebSupportModule.cs
@@ -26,15 +26,17 @@ using System.Reflection;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
-
+using System.Web.UI;
using Common.Logging;
using Spring.Core.IO;
using Spring.Core.TypeConversion;
using Spring.Core.TypeResolution;
using Spring.Expressions;
+using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Threading;
using Spring.Util;
+using Spring.Web.Support;
#endregion
@@ -46,6 +48,28 @@ namespace Spring.Context.Support
/// Erich Eichinger
public class WebSupportModule : IHttpModule
{
+ ///
+ /// Identifies the Objectdefinition used for the current IHttpHandler instance in TLS
+ ///
+ private static readonly string CURRENTHANDLER_OBJECTDEFINITION = "__spring.web" + new Guid().ToString();
+
+ ///
+ /// Holds the handler configuration information.
+ ///
+ private class HandlerConfigurationMetaData
+ {
+ public readonly IConfigurableApplicationContext ApplicationContext;
+ public readonly string ObjectDefinitionName;
+ public readonly bool IsContainerManaged;
+
+ public HandlerConfigurationMetaData(IConfigurableApplicationContext applicationContext, string objectDefinitionName, bool isContainerManaged)
+ {
+ ApplicationContext = applicationContext;
+ ObjectDefinitionName = objectDefinitionName;
+ IsContainerManaged = isContainerManaged;
+ }
+ }
+
private static readonly ILog s_log;
private static bool s_isInitialized = false;
@@ -64,28 +88,28 @@ namespace Spring.Context.Support
///
static WebSupportModule()
{
- s_log = LogManager.GetLogger(typeof(WebSupportModule));
+ s_log = LogManager.GetLogger( typeof( WebSupportModule ) );
// register additional resource handler
- ResourceHandlerRegistry.RegisterResourceHandler(WebUtils.DEFAULT_RESOURCE_PROTOCOL, typeof(WebResource));
+ ResourceHandlerRegistry.RegisterResourceHandler( WebUtils.DEFAULT_RESOURCE_PROTOCOL, typeof( WebResource ) );
// replace default IResource converter
- TypeConverterRegistry.RegisterConverter(typeof(IResource),
+ TypeConverterRegistry.RegisterConverter( typeof( IResource ),
new ResourceConverter(
- new ConfigurableResourceLoader(WebUtils.DEFAULT_RESOURCE_PROTOCOL)));
+ new ConfigurableResourceLoader( WebUtils.DEFAULT_RESOURCE_PROTOCOL ) ) );
// default to hybrid thread storage implementation
- LogicalThreadContext.SetStorage(new HybridContextStorage());
+ LogicalThreadContext.SetStorage( new HybridContextStorage() );
- s_log.Debug("Set default resource protocol to 'web' and installed HttpContext-aware HybridContextStorage");
+ s_log.Debug( "Set default resource protocol to 'web' and installed HttpContext-aware HybridContextStorage" );
}
///
/// Registers this module for all events required by the Spring.Web framework
///
- public virtual void Init(HttpApplication app)
+ public virtual void Init( HttpApplication app )
{
- lock (typeof(WebSupportModule))
+ lock (typeof( WebSupportModule ))
{
- s_log.Debug("Initializing Application instance");
+ s_log.Debug( "Initializing Application instance" );
if (!s_isInitialized)
{
HttpModuleCollection modules = app.Modules;
@@ -94,7 +118,7 @@ namespace Spring.Context.Support
if (modules[moduleKey] is SessionStateModule)
{
#if !NET_1_1
- HookSessionEvent((SessionStateModule) modules[moduleKey]);
+ HookSessionEvent( (SessionStateModule)modules[moduleKey] );
#else
HookSessionEvent11();
#endif
@@ -108,16 +132,85 @@ namespace Spring.Context.Support
VirtualEnvironment.SetInitialized();
}
- app.EndRequest += new EventHandler(VirtualEnvironment.RaiseEndRequest);
+ app.PreRequestHandlerExecute += new EventHandler( OnPreRequestHandlerExecute );
+ app.EndRequest += new EventHandler( VirtualEnvironment.RaiseEndRequest );
// ensure context is instantiated
IConfigurableApplicationContext appContext = WebApplicationContext.GetRootContext() as IConfigurableApplicationContext;
// configure this app + it's module instances
if (appContext == null)
{
- throw new InvalidOperationException("Implementations of IApplicationContext must also implement IConfigurableApplicationContext");
+ throw new InvalidOperationException( "Implementations of IApplicationContext must also implement IConfigurableApplicationContext" );
+ }
+ HttpApplicationConfigurer.Configure( appContext, app );
+ }
+
+ ///
+ /// Configures the current IHttpHandler as specified by .
+ ///
+ private void OnPreRequestHandlerExecute( object sender, EventArgs e )
+ {
+ HandlerConfigurationMetaData hCfg = (HandlerConfigurationMetaData)LogicalThreadContext.GetData( CURRENTHANDLER_OBJECTDEFINITION );
+ if (hCfg != null)
+ {
+ HttpApplication app = (HttpApplication)sender;
+ //app.Context.Handler =
+ ConfigureHandler( app.Context.Handler, hCfg.ApplicationContext, hCfg.ObjectDefinitionName, hCfg.IsContainerManaged );
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static void SetCurrentHandlerConfiguration( IConfigurableApplicationContext applicationContext, string name, bool isContainerManaged )
+ {
+ LogicalThreadContext.SetData( CURRENTHANDLER_OBJECTDEFINITION, new HandlerConfigurationMetaData(applicationContext, name, isContainerManaged) );
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public IHttpHandler ConfigureHandler( IHttpHandler handler, IConfigurableApplicationContext applicationContext, string name, bool isContainerManaged)
+ {
+ ApplyDependencyInjectionInfrastructure(handler, applicationContext);
+
+ if (isContainerManaged)
+ {
+ handler = (IHttpHandler)applicationContext.ObjectFactory.ConfigureObject( handler, name );
+ }
+ else
+ {
+ // at a minimum we'll apply ObjectPostProcessors
+ handler = (IHttpHandler)applicationContext.ObjectFactory.ApplyObjectPostProcessorsBeforeInitialization(handler, name);
+ handler = (IHttpHandler)applicationContext.ObjectFactory.ApplyObjectPostProcessorsAfterInitialization(handler, name);
+ }
+
+ return handler;
+ }
+
+ ///
+ /// Apply dependency injection stuff on the handler.
+ ///
+ /// the handler to be intercepted
+ /// the context responsible for configuring this handler
+ private static void ApplyDependencyInjectionInfrastructure(IHttpHandler handler, IApplicationContext applicationContext)
+ {
+ if (handler is Control)
+ {
+ ControlInterceptor.EnsureControlIntercepted(applicationContext, (Control)handler);
+ }
+ else
+ {
+ if (handler is ISupportsWebDependencyInjection)
+ {
+ ((ISupportsWebDependencyInjection)handler).DefaultApplicationContext = applicationContext;
+ }
}
- HttpApplicationConfigurer.Configure(appContext, app);
}
///
@@ -130,15 +223,15 @@ namespace Spring.Context.Support
#region Session Handling Stuff
- private static void OnCacheItemRemoved(string key, object value, CacheItemRemovedReason reason)
+ private static void OnCacheItemRemoved( string key, object value, CacheItemRemovedReason reason )
{
- s_log.Debug("end session " + key + " because of " + reason);
+ s_log.Debug( "end session " + key + " because of " + reason );
try
{
- HttpSessionState ss = CreateSessionState(key, value);
+ HttpSessionState ss = CreateSessionState( key, value );
- VirtualEnvironment.RaiseEndSession(ss, reason);
+ VirtualEnvironment.RaiseEndSession( ss, reason );
}
catch (Exception ex)
{
@@ -146,51 +239,51 @@ namespace Spring.Context.Support
// are we on a current request?
if (HttpContext.Current != null)
{
- s_log.Error(msg, ex);
+ s_log.Error( msg, ex );
}
else
{
// this is an async session timout - log as fatal since this is the thread's exit point!
- s_log.Fatal(msg, ex);
+ s_log.Fatal( msg, ex );
}
}
finally
{
if (s_originalCallback != null)
{
- s_originalCallback(key, value, reason);
- }
+ s_originalCallback( key, value, reason );
+ }
}
}
#if !NET_1_1
- private static void HookSessionEvent(SessionStateModule sessionStateModule)
+ private static void HookSessionEvent( SessionStateModule sessionStateModule )
{
// Hook only into InProcState - all others ignore SessionEnd anyway
- object store = ExpressionEvaluator.GetValue(sessionStateModule, "_store");
+ object store = ExpressionEvaluator.GetValue( sessionStateModule, "_store" );
if ((store != null) && store.GetType().Name == "InProcSessionStateStore")
{
- s_log.Debug("attaching to InProcSessionStateStore");
- s_originalCallback = (CacheItemRemovedCallback) ExpressionEvaluator.GetValue(store, "_callback");
- ExpressionEvaluator.SetValue(store, "_callback", new CacheItemRemovedCallback(OnCacheItemRemoved));
+ s_log.Debug( "attaching to InProcSessionStateStore" );
+ s_originalCallback = (CacheItemRemovedCallback)ExpressionEvaluator.GetValue( store, "_callback" );
+ ExpressionEvaluator.SetValue( store, "_callback", new CacheItemRemovedCallback( OnCacheItemRemoved ) );
- CACHEKEYPREFIXLENGTH = (int) ExpressionEvaluator.GetValue(store, "CACHEKEYPREFIXLENGTH");
+ CACHEKEYPREFIXLENGTH = (int)ExpressionEvaluator.GetValue( store, "CACHEKEYPREFIXLENGTH" );
}
}
- private static HttpSessionState CreateSessionState(string key, object state)
+ private static HttpSessionState CreateSessionState( string key, object state )
{
- string id = key.Substring(CACHEKEYPREFIXLENGTH);
+ string id = key.Substring( CACHEKEYPREFIXLENGTH );
ISessionStateItemCollection sessionItems =
- (ISessionStateItemCollection) ExpressionEvaluator.GetValue(state, "_sessionItems");
+ (ISessionStateItemCollection)ExpressionEvaluator.GetValue( state, "_sessionItems" );
HttpStaticObjectsCollection staticObjects =
- (HttpStaticObjectsCollection) ExpressionEvaluator.GetValue(state, "_staticObjects");
- int timeout = (int) ExpressionEvaluator.GetValue(state, "_timeout");
- TypeRegistry.RegisterType("SessionStateModule", typeof(SessionStateModule));
+ (HttpStaticObjectsCollection)ExpressionEvaluator.GetValue( state, "_staticObjects" );
+ int timeout = (int)ExpressionEvaluator.GetValue( state, "_timeout" );
+ TypeRegistry.RegisterType( "SessionStateModule", typeof( SessionStateModule ) );
HttpCookieMode cookieMode =
- (HttpCookieMode) ExpressionEvaluator.GetValue(null, "SessionStateModule.s_configCookieless");
+ (HttpCookieMode)ExpressionEvaluator.GetValue( null, "SessionStateModule.s_configCookieless" );
SessionStateMode stateMode =
- (SessionStateMode) ExpressionEvaluator.GetValue(null, "SessionStateModule.s_configMode");
+ (SessionStateMode)ExpressionEvaluator.GetValue( null, "SessionStateModule.s_configMode" );
HttpSessionStateContainer container = new HttpSessionStateContainer(
id
, sessionItems
@@ -202,11 +295,11 @@ namespace Spring.Context.Support
, true
);
- return (HttpSessionState) Activator.CreateInstance(
- typeof(HttpSessionState)
+ return (HttpSessionState)Activator.CreateInstance(
+ typeof( HttpSessionState )
, BindingFlags.Instance | BindingFlags.NonPublic
, null
- , new object[] {container}
+ , new object[] { container }
, CultureInfo.InvariantCulture
);
}
diff --git a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs
index f9c58e7e..3e8a49b1 100644
--- a/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs
+++ b/src/Spring/Spring.Web/Objects/Factory/Support/WebObjectFactory.cs
@@ -327,7 +327,7 @@ namespace Spring.Objects.Factory.Support
scopedSingletonCache.Add(objectName, TemporarySingletonPlaceHolder);
try
{
- instance = CreateObject(objectName, objectDefinition, arguments, true);
+ instance = InstantiateObject(objectName, objectDefinition, arguments, true, false);
AssertUtils.ArgumentNotNull(instance, "instance");
scopedSingletonCache[objectName] = instance;
}
diff --git a/src/Spring/Spring.Web/Spring.Web.2005.csproj b/src/Spring/Spring.Web/Spring.Web.2005.csproj
index 64008c51..6fd4af08 100644
--- a/src/Spring/Spring.Web/Spring.Web.2005.csproj
+++ b/src/Spring/Spring.Web/Spring.Web.2005.csproj
@@ -159,9 +159,6 @@
Code
-
-
-
@@ -184,7 +181,6 @@
Code
-
Code
@@ -192,10 +188,8 @@
-
- ASPXCodeBehind
Code
diff --git a/src/Spring/Spring.Web/Spring.Web.2008.csproj b/src/Spring/Spring.Web/Spring.Web.2008.csproj
index 5ee91d65..5a58e020 100644
--- a/src/Spring/Spring.Web/Spring.Web.2008.csproj
+++ b/src/Spring/Spring.Web/Spring.Web.2008.csproj
@@ -160,9 +160,6 @@
Code
-
-
-
@@ -185,7 +182,6 @@
Code
-
Code
@@ -193,10 +189,8 @@
-
- ASPXCodeBehind
Code
diff --git a/src/Spring/Spring.Web/Web/Process/IProcess.cs b/src/Spring/Spring.Web/Web/Process/IProcess.cs
deleted file mode 100644
index 9c9617c5..00000000
--- a/src/Spring/Spring.Web/Web/Process/IProcess.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-
-namespace Spring.Web.Process
-{
- ///
- /// An interface that different process implementations need to support.
- ///
- public interface IProcess
- {
- ///
- /// Unique ID of this process instance.
- ///
- string Id { get; }
-
- ///
- /// Controller for the component.
- ///
- ///
- /// Process controller will be shared by all the views
- /// that belong to this process.
- ///
- object Controller { get; set; }
-
- ///
- /// Gets the name of the current view.
- ///
- string CurrentView { get; }
-
- ///
- /// Gets the the flag that indicates if selected view
- /// has changed during the current request.
- ///
- bool ViewChanged { get; }
-
- ///
- /// Starts the process.
- ///
- /// Referrer URL.
- void Start(string referrerUrl);
-
- ///
- /// Resolves view for the specified view name.
- ///
- /// Name of the view to go to.
- void SetView(string viewName);
-
- ///
- /// Ends the process.
- ///
- void End();
- }
-}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/Process/ProcessManager.cs b/src/Spring/Spring.Web/Web/Process/ProcessManager.cs
deleted file mode 100644
index 89c66723..00000000
--- a/src/Spring/Spring.Web/Web/Process/ProcessManager.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-#region License
-
-/*
- * Copyright 2002-2004 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.Collections;
-
-namespace Spring.Web.Process
-{
- ///
- /// Singleton that keeps track of all active process instances.
- ///
- /// Aleksandar Seovic
- public class ProcessManager
- {
- private static readonly ProcessManager instance = new ProcessManager();
-
- private IDictionary processInstances = new Hashtable();
-
- ///
- /// Creates singleton instance.
- ///
- private ProcessManager()
- {}
-
- ///
- /// Registers process instance.
- ///
- /// Process instance to register.
- public static void RegisterProcess(IProcess process)
- {
- instance.processInstances.Add(process.Id, process);
- }
-
- ///
- /// Returns process with the specified ID.
- ///
- /// Process ID to use for lookup.
- /// Process with the specified ID, or null if process with that ID is not registered.
- public static IProcess GetProcess(string id)
- {
- return (IProcess) instance.processInstances[id];
- }
-
- ///
- /// Unregisters process with the specified ID.
- ///
- /// ID of the process to unregister.
- public static void UnregisterProcess(string id)
- {
- instance.processInstances.Remove(id);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/Services/WebServiceHandlerFactory.cs b/src/Spring/Spring.Web/Web/Services/WebServiceHandlerFactory.cs
index e17d8db9..65572a52 100644
--- a/src/Spring/Spring.Web/Web/Services/WebServiceHandlerFactory.cs
+++ b/src/Spring/Spring.Web/Web/Services/WebServiceHandlerFactory.cs
@@ -29,6 +29,7 @@ using System.Web.Services;
using Spring.Context;
using Spring.Context.Support;
+using Spring.Objects.Factory.Config;
using Spring.Util;
using Spring.Web.Support;
diff --git a/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs b/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs
index 9ece991e..58e310ff 100644
--- a/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs
+++ b/src/Spring/Spring.Web/Web/Support/AbstractHandlerFactory.cs
@@ -48,6 +48,43 @@ namespace Spring.Web.Support
/// Aleksandar Seovic
public abstract class AbstractHandlerFactory : IHttpHandlerFactory
{
+ #region NamedObjectDefinition Utility
+ ///
+ /// Holds a named
+ ///
+ /// Erich Eichinger
+ protected internal class NamedObjectDefinition
+ {
+ private readonly string _name;
+ private readonly IObjectDefinition _objectDefinition;
+
+ ///
+ /// Creates a new name/objectdefinition pair.
+ ///
+ public NamedObjectDefinition(string name, IObjectDefinition objectDefinition)
+ {
+ _name = name;
+ _objectDefinition = objectDefinition;
+ }
+
+ ///
+ /// Get the name of the attached object definition
+ ///
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ ///
+ /// Get the .
+ ///
+ public IObjectDefinition ObjectDefinition
+ {
+ get { return _objectDefinition; }
+ }
+ }
+ #endregion
+
///
/// Holds all handlers having == true.
///
@@ -255,39 +292,5 @@ namespace Spring.Web.Support
return (pageDefinition == null) ? (NamedObjectDefinition)null : new NamedObjectDefinition( objectDefinitionName, pageDefinition );
}
-
- ///
- /// DO NOT USE - this is subject to change!
- ///
- protected internal class NamedObjectDefinition
- {
- private readonly string _name;
- private readonly IObjectDefinition _objectDefinition;
-
- ///
- /// DO NOT USE
- ///
- public NamedObjectDefinition( string name, IObjectDefinition objectDefinition )
- {
- _name = name;
- _objectDefinition = objectDefinition;
- }
-
- ///
- /// DO NOT USE
- ///
- public string Name
- {
- get { return _name; }
- }
-
- ///
- /// DO NOT USE
- ///
- public IObjectDefinition ObjectDefinition
- {
- get { return _objectDefinition; }
- }
- }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/Support/AbstractProcessHandler.cs b/src/Spring/Spring.Web/Web/Support/AbstractProcessHandler.cs
deleted file mode 100644
index 37fe10f4..00000000
--- a/src/Spring/Spring.Web/Web/Support/AbstractProcessHandler.cs
+++ /dev/null
@@ -1,312 +0,0 @@
-#region License
-
-/*
- * Copyright 2002-2007 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
-
-#region Imports
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web;
-using System.Web.SessionState;
-using Spring.Collections;
-using Spring.Context;
-using Spring.Util;
-using Spring.Web.Process;
-using Spring.Web.Support;
-
-#endregion
-
-namespace Spring.Web.Support
-{
- ///
- /// An abstract base class that defines common behavior for different process implementations.
- ///
- /// Aleksandar Seovic
- public abstract class AbstractProcessHandler : IProcess, ISharedStateAware, IApplicationContextAware, IHttpHandler, IRequiresSessionState
- {
- ///
- /// Parameter name that is used for process ID.
- ///
- protected internal const string ProcessIdParamName = "pid";
-
- #region Fields
-
- private string id = Guid.NewGuid().ToString("N");
- private IProcess parent;
- private object controller;
- private string defaultView;
- private string currentView;
- private IDictionary views = new CaseInsensitiveHashtable(); //CollectionsUtil.CreateCaseInsensitiveHashtable();
- private IDictionary sharedState;
- private IApplicationContext applicationContext;
- private string processUrl;
- private bool viewChanged;
-
- #endregion
-
- #region Constructors
-
- ///
- /// Creates instance of the process and registers it with the .
- ///
- public AbstractProcessHandler()
- {
- ProcessManager.RegisterProcess(this);
- }
-
- #endregion
-
- #region Properties
-
- ///
- /// Unique ID of this component instance.
- ///
- public string Id
- {
- get { return this.id; }
- }
-
- ///
- /// Gets or sets the parent process.
- ///
- internal IProcess Parent
- {
- get { return this.parent; }
- set { this.parent = value; }
- }
-
- ///
- /// Returns a thread-safe dictionary that contains state that is shared by
- /// all views of this component.
- ///
- public IDictionary SharedState
- {
- get { return this.sharedState; }
- set { this.sharedState = value; }
- }
-
- ///
- /// Controller for the component.
- ///
- ///
- /// Process controller will be shared by all the views
- /// that belong to this component.
- ///
- public object Controller
- {
- get { return this.controller; }
- set { this.controller = value; }
- }
-
- ///
- /// Default view for the component.
- ///
- public string DefaultView
- {
- get { return this.defaultView; }
- set { this.defaultView = value; }
- }
-
- ///
- /// Gets the name of the current view.
- ///
- public string CurrentView
- {
- get
- {
- if (this.currentView == null)
- {
- this.CurrentView = this.defaultView;
- }
- return this.currentView;
- }
- set
- {
- string oldView = this.currentView;
- if (this.views.Contains(value))
- {
- this.currentView = (string) this.views[value];
- }
- else
- {
- this.currentView = value;
- }
- this.viewChanged = (oldView != this.currentView);
- }
- }
-
- ///
- /// Gets the the flag that indicates if selected view
- /// has changed during the current request.
- ///
- public bool ViewChanged
- {
- get { return this.viewChanged; }
- }
-
- ///
- /// Gets a map of process views.
- ///
- public IDictionary Views
- {
- get { return this.views; }
- }
-
- ///
- /// Gets the process URL.
- ///
- protected string ProcessUrl
- {
- get { return this.processUrl; }
- }
-
- #endregion
-
- #region Public methods
-
- ///
- /// Starts the process.
- ///
- /// Process URL.
- public void Start(string url)
- {
- this.processUrl = url;
- this.NavigateToStartView();
- }
-
- ///
- /// Resolves and sets the view for the specified view name.
- ///
- /// Name of the view to go to.
- public virtual void SetView(string viewName)
- {
- this.CurrentView = viewName;
- this.NavigateToCurrentView();
- }
-
- ///
- /// Ends the process by unregistering it from the .
- ///
- public virtual void End()
- {
- ProcessManager.UnregisterProcess(this.id);
- if (this.parent != null)
- {
- this.parent.SetView(this.parent.CurrentView);
- }
- }
-
- #endregion
-
- #region Abstract methods
-
- ///
- /// Method that needs to be implemented by specific process implementations
- /// in order to navigate to the first view in the process.
- ///
- protected abstract void NavigateToStartView();
-
- ///
- /// Method that needs to be implemented by specific process implementations
- /// in order to navigate to the current view.
- ///
- protected abstract void NavigateToCurrentView();
-
- #endregion
-
- #region IHttpHandler implementation
-
- ///
- /// Processes the request by delegating to appropriate view, which could be
- /// another process.
- ///
- ///
- void IHttpHandler.ProcessRequest(HttpContext context)
- {
- IHttpHandler handler = (IHttpHandler) this.applicationContext.GetObject(WebUtils.GetPageName(this.CurrentView));
- this.viewChanged = false;
-
- if (handler is AbstractProcessHandler)
- {
- ((AbstractProcessHandler) handler).Parent = this;
- // TODO: start child process
- }
-
- if (handler is IProcessAware)
- {
- ((IProcessAware) handler).Process = this;
- }
- if (handler is ISharedStateAware)
- {
- ((ISharedStateAware) handler).SharedState = this.sharedState;
- }
-
- context.Handler = handler;
- handler.ProcessRequest(context);
- }
-
- ///
- /// Returns true because this wrapper handler can be reused.
- /// Actual page is instantiated at the beginning of the ProcessRequest method.
- ///
- bool IHttpHandler.IsReusable
- {
- get { return false; }
- }
-
- #endregion
-
- #region IApplicationContextAware implementation
-
- ///
- /// Sets the that this
- /// object runs in.
- ///
- ///
- ///
- ///
- /// Normally this call will be used to initialize the object.
- ///
- ///
- /// 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; }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs b/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs
index 705b6d67..d78c190f 100644
--- a/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs
+++ b/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs
@@ -32,10 +32,9 @@ using Common.Logging;
using Spring.Collections;
using Spring.Context;
using Spring.Context.Support;
-using Spring.Objects.Factory.Config;
+using Spring.Objects;
using Spring.Objects.Factory.Support;
using Spring.Util;
-using Spring.Web.Process;
#endregion
@@ -78,9 +77,9 @@ namespace Spring.Web.Support
/// Requested page URL
/// Translated server path for the page
/// Instance of the IHttpHandler object that should be used to process request.
- public override IHttpHandler GetHandler( HttpContext context, string requestType, string url, string physicalPath )
+ public override IHttpHandler GetHandler(HttpContext context, string requestType, string url, string physicalPath)
{
- new SecurityPermission( SecurityPermissionFlag.UnmanagedCode ).Assert();
+ new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
return base.GetHandler(context, requestType, url, physicalPath);
}
@@ -93,321 +92,31 @@ namespace Spring.Web.Support
/// The requested .
/// The physical path of the requested resource.
/// A handler instance for the current request.
- protected override IHttpHandler CreateHandlerInstance( HttpContext context, string requestType, string url, string physicalPath )
+ protected override IHttpHandler CreateHandlerInstance(HttpContext context, string requestType, string url, string physicalPath)
{
- IHttpHandler pageHandlerWrapper;
- IConfigurableApplicationContext appContext = GetCheckedApplicationContext( url );
+ IHttpHandler handler;
+ IConfigurableApplicationContext appContext = GetCheckedApplicationContext(url);
if (appContext == null)
{
- throw new InvalidOperationException(
- "Implementations of IApplicationContext must also implement IConfigurableApplicationContext" );
+ throw new InvalidOperationException("PageHandlerFactory requires an IConfigurableApplicationContext");
}
- string appRelativeVirtualPath = WebUtils.GetAppRelativePath( url );
- NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition( appRelativeVirtualPath, appContext.ObjectFactory );
+ string appRelativeVirtualPath = WebUtils.GetAppRelativePath(url);
+ NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory);
if (namedPageDefinition != null)
{
- Type pageType = namedPageDefinition.ObjectDefinition.ObjectType;
- if (typeof( IRequiresSessionState ).IsAssignableFrom( pageType ))
- {
- pageHandlerWrapper = new SessionAwarePageHandlerWrapper( appContext, namedPageDefinition.Name, url, null );
- }
- else
- {
- pageHandlerWrapper = new PageHandlerWrapper( appContext, namedPageDefinition.Name, url, null );
- }
+ handler = (IHttpHandler)appContext.CreateObject(namedPageDefinition.Name, typeof(IHttpHandler), null);
+ WebSupportModule.SetCurrentHandlerConfiguration(appContext, namedPageDefinition.Name, true);
}
else
{
- Type pageType = WebObjectUtils.GetCompiledPageType( url );
- if (typeof( IRequiresSessionState ).IsAssignableFrom( pageType ))
- {
- pageHandlerWrapper = new SessionAwarePageHandlerWrapper( appContext, appRelativeVirtualPath, url, physicalPath );
- }
- else
- {
- pageHandlerWrapper = new PageHandlerWrapper( appContext, appRelativeVirtualPath, url, physicalPath );
- }
- }
- return pageHandlerWrapper;
- }
- }
-
- ///
- /// Wrapper for handlers that do not require .
- ///
- ///
- /// NOTE: This class has to extend System.Web.UI.Page instead of simply
- /// implementing IHttpHandler in order for Server.Transfer to work properly.
- /// This in turn requires explicit IHttpHandler implementation in order to
- /// override non-virtual methods from the base Page class.
- ///
- internal class PageHandlerWrapper : Page, IHttpHandler
- {
-#if NET_2_0 && !MONO_2_0
- private static readonly FieldInfo fiHttpContext_CurrentHandler =
- typeof( HttpContext ).GetField( "_currentHandler", BindingFlags.NonPublic | BindingFlags.Instance );
-#endif
-#if MONO_2_0
- private static readonly FieldInfo fiHttpContext_CurrentHandler =
- typeof(HttpContext).GetField("handler", BindingFlags.NonPublic | BindingFlags.Instance);
-#endif
-#if NET_2_0 || !MONO_2_0
- private static readonly MethodInfo miPage_SetPreviousPage =
- typeof( System.Web.UI.Page ).GetMethod( "SetPreviousPage", BindingFlags.NonPublic | BindingFlags.Instance );
-#endif
-
- private readonly IApplicationContext appContext;
- private readonly string pageId;
- private readonly string url;
- private readonly string path;
-
- // cache handler if IsReusable == true
- // since we don't use sync, make it volatile
- private volatile IHttpHandler cachedHandler;
-
- // holds shared state for handlerType
- private Type handlerType;
- private IDictionary handlerState;
-
- private readonly object syncRoot = new object();
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Application context instance to retrieve page from.
- /// Name of the page object to execute.
- /// Requested page URL.
- /// Translated server path for the page.
- public PageHandlerWrapper( IApplicationContext appContext, string pageName, string url, string path )
- {
- this.appContext = appContext;
- this.pageId = pageName;
- this.url = url;
- this.path = path;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Application context instance to retrieve page from.
- /// Name of the page object to execute.
- public PageHandlerWrapper( IApplicationContext appContext, string pageName )
- : this( appContext, pageName, null, null )
- {
- }
-
- #region Properties
-
- ///
- /// Use for sync access to this PageHandler instance.
- ///
- public object SyncRoot
- {
- get { return syncRoot; }
- }
-
- ///
- /// Gets that contains handler state.
- ///
- ///
- /// This will be assigned to the SharedState
- /// property of instances that implement
- /// interface.
- ///
- public IDictionary HandlerState
- {
- get { return handlerState; }
- }
-
- #endregion
-
- void IHttpHandler.ProcessRequest( HttpContext context )
- {
- IHttpHandler handler = cachedHandler;
-
- if (handler == null)
- {
- if (path != null)
- {
- handler = CreatePageInstance();
- }
- else
- {
- handler = GetOrCreateProcessHandler( context );
- }
-
- // note, that we don't care about sync here. The last call wins (it's the most current handler instance anyway)
- if (handler.IsReusable)
- cachedHandler = handler;
+ handler = WebObjectUtils.CreatePageInstance(url);
+ WebSupportModule.SetCurrentHandlerConfiguration(appContext, url, false);
}
- // replace handler proxy on context with "real" handler
- if (this == context.Handler)
- {
- context.Handler = handler;
- }
-
-#if NET_2_0
- // this may happen under load, if GetHandler()
- // and ProcessRequest() are executed under different threads
- // fix this...
- if (this == context.CurrentHandler)
- {
- fiHttpContext_CurrentHandler.SetValue( context, handler );
- }
-
- if (handler is System.Web.UI.Page)
- {
- System.Web.UI.Page page = (Page)handler;
-
- // TODO: to fix this would require a change to the Mono source as there is no mechanisim (public or private) for explicitly setting the
- // PreviousPage at the moment
-#if !MONO_2_0
- // During Server.Transfer/Execute() the PreviousPage property gets set
- if (this.PreviousPage != null)
- {
- miPage_SetPreviousPage.Invoke( page, new object[] { this.PreviousPage } );
- }
-#endif
- }
-#endif
-
- ApplySharedState( handler );
- ApplyDependencyInjection( handler );
-
- handler.ProcessRequest( context );
- }
-
- ///
- /// Returns true because this wrapper handler can be reused.
- /// Actual page is instantiated at the beginning of the ProcessRequest method.
- ///
- bool IHttpHandler.IsReusable
- {
- get { return true; }
- }
-
- ///
- /// Creates a page instance corresponding to this handler's url.
- ///
- private IHttpHandler CreatePageInstance()
- {
- IHttpHandler handler;
- handler = WebObjectUtils.CreatePageInstance( url );
- if (handler is IApplicationContextAware)
- {
- ((IApplicationContextAware)handler).ApplicationContext = appContext;
- }
return handler;
}
-
- ///
- /// Gets or - if not found - creates a process handler instance.
- ///
- private IHttpHandler GetOrCreateProcessHandler( HttpContext context )
- {
- IHttpHandler handler = null;
- string processId = context.Request[AbstractProcessHandler.ProcessIdParamName];
- if (processId != null)
- {
- handler = (IHttpHandler)ProcessManager.GetProcess( processId );
- }
-
- if (handler == null)
- {
- handler = (IHttpHandler)this.appContext.GetObject( this.pageId );
- if (handler is IProcess)
- {
- ((IProcess)handler).Start( url );
- }
- }
- return handler;
- }
-
- ///
- /// Apply dependency injection stuff on the handler.
- ///
- ///
- private void ApplyDependencyInjection( IHttpHandler handler )
- {
- if (handler is Control)
- {
- ControlInterceptor.EnsureControlIntercepted( appContext, (Control)handler );
- }
- else
- {
- if (handler is ISupportsWebDependencyInjection)
- {
- ((ISupportsWebDependencyInjection)handler).DefaultApplicationContext = appContext;
- }
- }
- }
-
- ///
- /// Applies to the given handler if applicable.
- ///
- private void ApplySharedState( IHttpHandler handler )
- {
- if (handler is ISharedStateAware)
- {
- CheckIfPageWasRecompiled( handler );
- ((ISharedStateAware)handler).SharedState = this.handlerState;
- }
- }
-
- ///
- /// Checks, if page has been recompiled. Creates/discards handlerState if necessary.
- ///
- ///
- private void CheckIfPageWasRecompiled( IHttpHandler handler )
- {
- if (handlerType != handler.GetType())
- {
- lock (SyncRoot)
- {
- if (handlerType != handler.GetType())
- {
- // discard old handlerState and cache new pagetype
- handlerState = new SynchronizedHashtable();
- handlerType = handler.GetType();
- }
- }
- }
- }
- }
-
- ///
- /// Wrapper for handlers that require .
- ///
- ///
- /// Delays page object instantiation until ProcessRequest is called
- /// in order to be able to access session state.
- ///
- internal class SessionAwarePageHandlerWrapper : PageHandlerWrapper, IRequiresSessionState
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// Application context instance to retrieve page from.
- /// Name of the page object to execute.
- /// Requested page URL.
- /// Translated server path for the page.
- public SessionAwarePageHandlerWrapper( IApplicationContext appContext, string pageName, string url, string path )
- : base( appContext, pageName, url, path )
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Application context instance to retrieve page from.
- /// Name of the page object to execute.
- public SessionAwarePageHandlerWrapper( IApplicationContext appContext, string pageName )
- : base( appContext, pageName )
- {
- }
}
}
diff --git a/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs b/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
index 46f18162..fb119699 100644
--- a/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
+++ b/src/Spring/Spring.Web/Web/Support/SharedStateResourceCache.cs
@@ -22,6 +22,7 @@
using System.Collections;
using Spring.Globalization;
+using Spring.Objects;
using Spring.Util;
#endregion
diff --git a/src/Spring/Spring.Web/Web/UI/Page.cs b/src/Spring/Spring.Web/Web/UI/Page.cs
index 1d7909c1..e540fc6b 100644
--- a/src/Spring/Spring.Web/Web/UI/Page.cs
+++ b/src/Spring/Spring.Web/Web/UI/Page.cs
@@ -37,14 +37,14 @@ using Spring.Core;
using Spring.DataBinding;
using Spring.Globalization;
using Spring.Globalization.Resolvers;
+using Spring.Objects;
using Spring.Util;
using Spring.Validation;
-using Spring.Web.Process;
using Spring.Web.Support;
#if NET_2_0
using System.Web.Compilation;
#endif
-using IValidator=Spring.Validation.IValidator;
+using IValidator = Spring.Validation.IValidator;
#endregion
@@ -70,9 +70,9 @@ namespace Spring.Web.UI
///
///
///