-
Need to know if this is possible with Spring.net AOP in Web Application
Hi,
I have a simple, sample web application and I'd like to use spring.net AOP to perform methodbefore advices when page events are called. This is what I've tried (unsuccessfully):
1. Create asp.net web app (standard web app in VS 2010)
2. Add "Advices" and "Services" folders to the web app
3. Added a "MethodLoggingBeforeAdvice" class to the Advices folder that implements IMethodBeforeAdvice which writes some text to a file
4. Added an "IExampleServices" interface to the Services folder with a single method
5. Added an "ExampleServices" class to the "Impl" folder under Services which implements the interface method and just writes to the Console
6. In the "Page_Load" event of the Default.aspx file, I instantiate the ExampleServices class and call the method
7. I want this method to be intercepted and have the interceptor write data to a file
Please don't just point me back to the docs...I've read them and, being new to Spring.NET AOP, I can't figure out what I need from them or I wouldn't need to post here :-)
Below is my web.config file (I'm pretty sure the problem is here).
Thanks in advance for any help!!
<?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" />
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSecti onHandler, Spring.Core" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;
Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\asp netdb.mdf;
UserInstance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ApplicationServices"
applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider "
applicationName="/" />
</providers>
</roleManager>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web" />
</httpHandlers>
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<spring>
<parsers>
</parsers>
<context type="Spring.Context.Support.WebApplicationContext , Spring.Web">
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database">
<description>An example that demonstrates simple AOP functionality.</description>
<object id="beforeAdvice"
type="AOPSampleWeb.Aspects.MethodLoggingBeforeAdvi ce, AOPSampleWeb, Version=1.0.0.0, Culture=neutral" />
<object id="exampleService" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="target" ref="exampleServiceTarget" />
<property name="interceptorNames">
<list>
<value>beforeAdvice</value>
</list>
</property>
</object>
<object id="exampleServiceTarget"
type="AOPSampleWeb.Services.Impl.ExampleServiceImp l, AOPSampleWeb, Version=1.0.0.0, Culture=neutral">
</object>
</objects>
</spring>
</configuration>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules