resolved SPRNET-997, SPRNET-962

This commit is contained in:
eeichinger
2008-11-01 21:43:14 +00:00
parent 28afdf950e
commit ff92c14a91
4 changed files with 115 additions and 60 deletions

View File

@@ -1,63 +1,81 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
</configSections>
<!-- to see logging output in the attached debugger -->
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="Level" value="ALL"/>
</factoryAdapter>
</logging>
</common>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<pages>
<controls>
<add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web"/>
</controls>
</pages>
<!--
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
</configSections>
<!-- to see logging output in the attached debugger -->
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="Level" value="ALL"/>
</factoryAdapter>
</logging>
</common>
<system.web>
<customErrors mode="Off" />
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages>
<controls>
<add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web"/>
</controls>
</pages>
<!--
The following needs to be configured in order to enable Spring.NET Web Framework features
-->
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="HtmlCommentAppender" type="HtmlCommentAppenderModule"/>
<!-- this custom module is only for DI demonstration purposes -->
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
</system.web>
<!-- demonstrates how to configure IHttpModule instances -->
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- configure our custom HttpModule -->
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.Web">
<property name="ModuleTemplates">
<dictionary>
<entry key="HtmlCommentAppender">
<!-- this name must match the module name -->
<object>
<!-- select "view source" in your browser on any page to see the appended html comment -->
<property name="AppendText" value="My configured comment!"/>
</object>
</entry>
</dictionary>
</property>
</object>
</objects>
</spring>
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="HtmlCommentAppender" type="HtmlCommentAppenderModule"/>
<!-- this custom module is only for DI demonstration purposes -->
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="HtmlCommentAppender" type="HtmlCommentAppenderModule"/>
</modules>
<handlers>
<add name="SpringPageHandler" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</handlers>
</system.webServer>
<!-- demonstrates how to configure IHttpModule instances -->
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- configure our custom HttpModule -->
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.Web">
<property name="ModuleTemplates">
<dictionary>
<entry key="HtmlCommentAppender">
<!-- this name must match the module name -->
<object>
<!-- select "view source" in your browser on any page to see the appended html comment -->
<property name="AppendText" value="My configured comment!"/>
</object>
</entry>
</dictionary>
</property>
</object>
</objects>
</spring>
</configuration>

View File

@@ -90,4 +90,15 @@
</healthMonitoring>
-->
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>
<handlers>
<add name="SpringPageHandler" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</handlers>
</system.webServer>
</configuration>

View File

@@ -34,6 +34,7 @@ using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Objects.Factory.Xml;
using Spring.Objects.Support;
using Spring.Reflection.Dynamic;
using Spring.Util;
#endregion
@@ -161,8 +162,11 @@ namespace Spring.Context.Support
{
string firstRequestPath = HttpRuntime.AppDomainAppVirtualPath.TrimEnd('/') + "/dummy.context";
log.Info("Forcing first request " + firstRequestPath);
HttpRuntime.ProcessRequest(
new SimpleWorkerRequest(firstRequestPath, string.Empty, new StringWriter()));
SafeMethod fnProcessRequestNow = new SafeMethod(typeof(HttpRuntime).GetMethod("ProcessRequestNow", BindingFlags.Static|BindingFlags.NonPublic));
SimpleWorkerRequest wr = new SimpleWorkerRequest(firstRequestPath, string.Empty, new StringWriter());
fnProcessRequestNow.Invoke(null, new object[] { wr });
// HttpRuntime.ProcessRequest(
// wr);
log.Info("Successfully processed first request!");
}
catch (Exception ex)

View File

@@ -34,6 +34,7 @@ using Spring.Core.TypeResolution;
using Spring.Expressions;
using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;
using Spring.Reflection.Dynamic;
using Spring.Threading;
using Spring.Util;
using Spring.Web.Support;
@@ -77,6 +78,10 @@ namespace Spring.Context.Support
// Required for Session End event handling
private static int CACHEKEYPREFIXLENGTH = 0;
private static CacheItemRemovedCallback s_originalCallback;
#if NET_2_0
// required to enable accessing HttpContext.Request during IHttpModule.Init() in integrated mode
private static readonly SafeField ContextHideRequestResponse = new SafeField(typeof(HttpContext).GetField("HideRequestResponse", BindingFlags.Instance|BindingFlags.NonPublic));
#endif
/// <summary>
/// For webapplications always
@@ -142,7 +147,24 @@ namespace Spring.Context.Support
{
throw new InvalidOperationException("Implementations of IApplicationContext must also implement IConfigurableApplicationContext");
}
#if NET_2_0
// TODO: this is only a workaround to get us up & running in IIS7/integrated mode
// We must review all code for relative virtual paths - they must be resolved to application-relative paths
// during parsing of the object definitions
bool hideRequestResponse = (bool) ContextHideRequestResponse.GetValue(app.Context);
ContextHideRequestResponse.SetValue(app.Context, false);
try
{
HttpApplicationConfigurer.Configure(appContext, app);
}
finally
{
ContextHideRequestResponse.SetValue(app.Context, hideRequestResponse);
}
#else
HttpApplicationConfigurer.Configure(appContext, app);
#endif
}
#region IHttpHandler configuration