I've based my project on Spring's Northwind example, but I must be doing something wrong. I'm having Spring construct a DAO object and inject it into an ASP page, which it does, but I see that the same page gets constructed by IIS, without the benefit of Spring's injection, and it's that latter page that gets run.
The page, WorkFlowDetail.aspx, inherits from a base class called BasePage1. BasePage1 has a public property for the DAO, giving us something like this:
BasePage1.vb:
Public Class BasePage1
Inherits System.Web.UI.Page
Private _wfdao As IWfDao
Public Property wfDao As IWfDao
Get
Return _wfdao
End Get
Set(value As IWfDao)
_wfdao = value
End Set
End Property
End Class
WorkFlowDetail.aspx.vb:
Public Class WorkFlowDetail
Inherits BasePage1
End Class
Web.xml:
<object name="BasePage1">
<property name="wfDao" ref="wfDao" />
</object>
<object type="WorkFlowDetail.aspx" parent="BasePage1">
</object>
Web.config:
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web" />
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" />
</parsers>
<context annotation-config="">
<resource uri="~/Config/Aspects.xml" />
<resource uri="~/Web.xml" />
</context>
</spring>
<system.web>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
</system.web>
<system.webServer>
<handlers>
<add name="SpringPageHandler" verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
<add name="SpringWebServiceHandler" verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" />
<add name="SpringContextMonitor" verb="*" path="ContextMonitor.ashx" type="Spring.Web.Support.ContextMonitor, Spring.Web"/>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" />
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate32" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<appSettings>
<add key="Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName" value="NHibernateSessionFactory" />
</appSettings>
</configuration>
[Clearly I've left out a lot of stuff that I don't think is relevant.]
Setting a couple of strategic breakpoints I find that WorkFlowDetail.aspx gets constructed first by Spring and the DAO object is injected. It shows up in the debugger's Watch list as a "(ASP.workflowdetail_aspx)" and the stack looks like this:
[External Code]
Spring.Web.dll!Spring.Util.VirtualEnvironment.HttpRuntimeEnvironment.CreateInstanceFromVirtualPath(string virtualPath, System.Type requiredBaseType) Line 409 + 0x12 bytes C#
Spring.Web.dll!Spring.Util.VirtualEnvironment.CreateInstanceFromVirtualPath(string virtualPath, System.Type requiredBaseType) Line 515 + 0x44 bytes C#
Spring.Web.dll!Spring.Objects.Factory.Support.WebObjectUtils.CreateHandler(string pageUrl) Line 156 + 0x20 bytes C#
Spring.Web.dll!Spring.Objects.Factory.Support.WebObjectUtils.CreatePageInstance(string pageUrl) Line 105 + 0xc bytes C#
Spring.Web.dll!Spring.Objects.Factory.Support.WebInstantiationStrategy.Instantiate(Spring.Objects.Factory.Support.RootObjectDefinition definition, string name, Spring.Objects.Factory.IObjectFactory factory) Line 76 + 0x50 bytes C#
Spring.Core.dll!Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(string objectName, Spring.Objects.Factory.Support.RootObjectDefinition definition) Line 1036 + 0x43 bytes C#
Spring.Core.dll!Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.CreateObjectInstance(string objectName, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition, object[] arguments) Line 1000 + 0x2a bytes C#
Spring.Core.dll!Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(string name, Spring.Objects.Factory.Support.RootObjectDefinition definition, object[] arguments, bool allowEagerCaching, bool suppressConfigure) Line 904 + 0x21 bytes C#
Spring.Core.dll!Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(string name, System.Type requiredType, object[] arguments, bool suppressConfigure) Line 2037 + 0x3a bytes C#
Spring.Core.dll!Spring.Objects.Factory.Support.AbstractObjectFactory.CreateObject(string name, System.Type requiredType, object[] arguments) Line 1817 + 0x1e bytes C#
Spring.Core.dll!Spring.Context.Support.AbstractApplicationContext.CreateObject(string name, System.Type requiredType, object[] arguments) Line 1495 + 0x4d bytes C#
Spring.Web.dll!Spring.Web.Support.PageHandlerFactory.CreateHandlerInstance(Spring.Context.IConfigurableApplicationContext appContext, System.Web.HttpContext context, string requestType, string rawUrl, string physicalPath) Line 108 + 0x85 bytes C#
Spring.Web.dll!Spring.Web.Support.AbstractHandlerFactory.GetHandler(System.Web.HttpContext context, string requestType, string url, string physicalPath) Line 208 + 0x43 bytes C#
Spring.Web.dll!Spring.Web.Support.PageHandlerFactory.GetHandler(System.Web.HttpContext context, string requestType, string url, string physicalPath) Line 77 + 0x23 bytes C#
[External Code]
Then the constructor is called again. This time the object shows up as "scheduleSite.WorkFlowDetail" in the debugger's Watch list and the stack just shows
[External Code]
Please tell me what I'm doing wrong with this configuration. I've already tried leaving all mention of BasePage1 out of Web.xml, with the same results.
UPDATE:
First-of-all, the page is being constructed more than just twice; I thought only twice because it was throwing an exception on the second time, but I find that if I get past there I hit the constructor 3-4 more times.
Second, I suspect that my problems stem from a misconfiguration of Web.config. I notice that Northwind has only the <system.web> section, whereas my app (set up before I came onto the project) has both <system.web> and <system.webServer>. Northwind is targeting .NET 3.5 whereas we're targeting 4.0 and IIS7.0 in Integrated mode. I'm now looking into how to configure it, but would still appreciate help.