SPRNET-1343

Added initial support for ASP.NET MVC (v2)
This commit is contained in:
sbohlen
2010-10-26 21:38:18 +00:00
parent f49ab125f7
commit 124c18b59c
27 changed files with 1255 additions and 2 deletions

View File

@@ -70,6 +70,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate30.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate21.Integration.Tests.2010", "test\Spring\Spring.Data.NHibernate21.Integration.Tests\Spring.Data.NHibernate21.Integration.Tests.2010.csproj", "{4A07E150-ED90-407C-8CAD-4760444DDFD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.Mvc.2010", "src\Spring\Spring.Web.Mvc\Spring.Web.Mvc.2010.csproj", "{5166CE3A-14BE-478A-88DA-729A39DE1E29}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.Mvc.Tests.2010", "test\Spring\Spring.Web.Mvc.Tests\Spring.Web.Mvc.Tests.2010.csproj", "{D4032434-D9A8-437B-95E8-9D4DE0AD9932}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
@@ -410,6 +414,26 @@ Global
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Any CPU.Build.0 = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Debug|.NET.ActiveCfg = Debug|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Release|.NET.ActiveCfg = Release|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Release|Any CPU.Build.0 = Release|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5166CE3A-14BE-478A-88DA-729A39DE1E29}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Debug|.NET.ActiveCfg = Debug|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|.NET.ActiveCfg = Release|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Any CPU.Build.0 = Release|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D4032434-D9A8-437B-95E8-9D4DE0AD9932}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -50,6 +50,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -87,6 +88,9 @@
<Compile Include="..\Spring.Data.NHibernate12\Data\NHibernate\SpringSessionSynchronization.cs">
<Link>Data\NHibernate\SpringSessionSynchronization.cs</Link>
</Compile>
<Compile Include="..\Spring.Data.NHibernate21\Data\NHibernate\HibernateTxScopeTransactionManager.cs">
<Link>Data\NHibernate\HibernateTxScopeTransactionManager.cs</Link>
</Compile>
<Compile Include="..\Spring.Data.NHibernate\Data\NHibernate\HibernateAdoException.cs">
<Link>Data\NHibernate\HibernateAdoException.cs</Link>
</Compile>

View File

@@ -676,6 +676,10 @@ namespace Spring.Data.NHibernate
}
/// <summary>
/// Does the tx scope commit.
/// </summary>
/// <param name="status">The status.</param>
protected void DoTxScopeCommit(DefaultTransactionStatus status)
{
TxScopeTransactionManager.PromotableTxScopeTransactionObject txObject =
@@ -742,6 +746,10 @@ namespace Spring.Data.NHibernate
}
}
/// <summary>
/// Does the tx scope rollback.
/// </summary>
/// <param name="status">The status.</param>
protected void DoTxScopeRollback(DefaultTransactionStatus status)
{
TxScopeTransactionManager.PromotableTxScopeTransactionObject txObject =
@@ -779,6 +787,10 @@ namespace Spring.Data.NHibernate
DoTxScopeSetRollbackOnly(status);
}
/// <summary>
/// Does the tx scope set rollback only.
/// </summary>
/// <param name="status">The status.</param>
protected void DoTxScopeSetRollbackOnly(DefaultTransactionStatus status)
{
if (status.Debug)

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Context.Support;
using Spring.Core.IO;
namespace Spring.Context.Support
{
/// <summary>
/// Application Context for ASP.NET MVC Applications
/// </summary>
public class MvcApplicationContext : AbstractXmlApplicationContext
{
private readonly string[] _configurationLocations;
private readonly IResource[] _configurationResources;
/// <summary>
/// Create a new MvcApplicationContext, loading the definitions
/// from the given XML resource.
/// </summary>
/// <param name="name">The application context name.</param>
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
/// <param name="configurationLocations">Names of configuration resources.</param>
public MvcApplicationContext(string name, bool caseSensitive, params string[] configurationLocations)
: this(new MvcApplicationContextArgs(name, null, configurationLocations, null, caseSensitive))
{
}
/// <summary>
/// Create a new MvcApplicationContext with the given parent,
/// loading the definitions from the given XML resources.
/// </summary>
/// <param name="name">The application context name.</param>
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">Names of configuration resources.</param>
public MvcApplicationContext(string name, bool caseSensitive, IApplicationContext parentContext,
params string[] configurationLocations)
: this(new MvcApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive))
{ }
/// <summary>
/// Initializes a new instance of the <see cref="MvcApplicationContext"/> class.
/// </summary>
/// <param name="args">The args.</param>
public MvcApplicationContext(MvcApplicationContextArgs args)
: base(args.Name, args.CaseSensitive, args.ParentContext)
{
_configurationLocations = args.ConfigurationLocations;
_configurationResources = args.ConfigurationResources;
Refresh();
if (log.IsDebugEnabled)
{
log.Debug("created instance " + this.ToString());
}
}
/// <summary>
/// Create a new MvcApplicationContext, loading the definitions
/// from the given XML resource.
/// </summary>
/// <param name="name">The application context name.</param>
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
/// <param name="configurationLocations">Names of configuration resources.</param>
/// <param name="configurationResources">Configuration resources.</param>
public MvcApplicationContext(string name, bool caseSensitive, string[] configurationLocations, IResource[] configurationResources)
: this(new MvcApplicationContextArgs(name, null, configurationLocations, configurationResources, caseSensitive))
{
}
/// <summary>
/// Create a new MvcApplicationContext, loading the definitions
/// from the given XML resource.
/// </summary>
/// <param name="configurationLocations">Names of configuration resources.</param>
public MvcApplicationContext(params string[] configurationLocations)
: this(new MvcApplicationContextArgs(string.Empty, null, configurationLocations, null, false))
{
}
protected override string[] ConfigurationLocations
{
get { return _configurationLocations; }
}
protected override IResource[] ConfigurationResources
{
get { return _configurationResources; }
}
}
}

View File

@@ -0,0 +1,76 @@
#region License
/*
* Copyright © 2002-2005 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 Spring.Core.IO;
namespace Spring.Context.Support
{
/// <summary>
/// Encapsulates arguments to the <see cref="Spring.Context.Support.MvcApplicationContext"/> class.
/// </summary>
public class MvcApplicationContextArgs : AbstractXmlApplicationContextArgs
{
private const bool DEFAULT_CASESENSITIVE = false;
private const bool DEFAULT_REFRESH = false;
/// <summary>
/// Initializes a new instance of the MvcApplicationContextArgs class.
/// </summary>
public MvcApplicationContextArgs()
{
CaseSensitive = DEFAULT_CASESENSITIVE;
}
/// <summary>
/// Initializes a new instance of the MvcApplicationContextArgs class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
public MvcApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
: this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE)
{ }
/// <summary>
/// Initializes a new instance of the MvcApplicationContextArgs class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
/// <param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
public MvcApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources, bool caseSensitive)
{
Name = name;
ParentContext = parentContext;
ConfigurationLocations = configurationLocations;
ConfigurationResources = configurationResources;
CaseSensitive = caseSensitive;
Refresh = DEFAULT_REFRESH;
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Context.Support;
namespace Spring.Context.Support
{
/// <summary>
/// Context Handler for ASP.NET MVC Applications
/// </summary>
public class MvcContextHandler : ContextHandler
{
/// <summary>
/// The <see cref="System.Type"/> of <see cref="Spring.Context.IApplicationContext"/>
/// created if no <c>type</c> attribute is specified on a <c>context</c> element.
/// </summary>
/// <value></value>
/// <seealso cref="GetContextType"/>
protected override Type DefaultApplicationContextType
{
get { return typeof(MvcApplicationContext); }
}
/// <summary>
/// Get the context's case-sensitivity to use if none is specified
/// </summary>
/// <value></value>
/// <remarks>
/// <p>
/// Derived handlers may override this property to change their default case-sensitivity.
/// </p>
/// <p>
/// Defaults to 'true'.
/// </p>
/// </remarks>
protected override bool DefaultCaseSensitivity
{
get { return false; }
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Spring.Web.Mvc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Spring.Web.Mvc")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4e7f33fc-585f-44cb-b8b9-500223e9b760")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5166CE3A-14BE-478A-88DA-729A39DE1E29}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring.Web.Mvc</RootNamespace>
<AssemblyName>Spring.Web.Mvc</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\bin\net\3.5\debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Context\Support\MvcApplicationContext.cs" />
<Compile Include="Context\Support\MvcApplicationContextArgs.cs" />
<Compile Include="Context\Support\MvcContextHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpringControllerFactory.cs" />
<Compile Include="SpringMvcApplication.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spring.Core\Spring.Core.2010.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2010</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" ?>
<project name="Spring.Web" default="build" xmlns="http://nant.sf.net/schemas/nant.xsd">
<!--
Required properties:
* current.bin.dir - (path) root level to build to
* current.build.debug - (true|false) debug build?
* current.build.defines.csc - framework-specific build defines for C# compiler
-->
<target name="build">
<!-- build Spring.Web.Mvc -->
<csc target="library" define="${current.build.defines.csc}"
warnaserror="true"
optimize="${build.optimize}"
debug="${current.build.debug}"
output="${current.bin.dir}/${project::get-name()}.dll"
doc="${current.bin.dir}/${project::get-name()}.xml"
>
<arg line="${compiler.args}"/>
<nowarn>
<warning number="${nowarn.numbers},0108,0114,0612,0109" />
<warning number="${nowarn.numbers},1591" if="${nant.settings.currentframework=='mono-2.0'}"/>
</nowarn>
<sources failonempty="true">
<include name="**/*.cs" />
<include name="../GenCommonAssemblyInfo.cs" />
</sources>
<resources basedir="Resources">
<include name="**/*" />
</resources>
<references basedir="${current.bin.dir}">
<include name="Common.Logging.dll"/>
<include name="antlr.runtime.dll" />
<include name="Spring.Core.dll" />
<include name="Spring.Aop.dll" />
<include name="System.Configuration.dll" />
<include name="System.Web.dll" />
<include name="System.Web.Mvc.dll" />
<include name="System.Web.Services.dll" />
<include if="${net-4.0.installed and net-4.0}" name="System.Web.ApplicationServices.dll" />
</references>
</csc>
</target>
</project>

View File

@@ -0,0 +1,93 @@
using System;
using System.Web.Mvc;
using System.Web.Routing;
using Spring.Objects.Factory;
using Spring.Core;
using Spring.Context;
using Spring.Context.Support;
using System.Linq;
using System.Collections;
namespace Spring.Web.Mvc
{
/// <summary>
/// Controller Factory for ASP.NET MVC
/// </summary>
public class SpringControllerFactory : DefaultControllerFactory
{
private static IApplicationContext _context;
public static IApplicationContext ApplicationContext
{
get
{
if (_context == null || _context.Name != ApplicationContextName)
{
if (string.IsNullOrEmpty(ApplicationContextName))
{
_context = ContextRegistry.GetContext();
}
else
{
_context = ContextRegistry.GetContext(ApplicationContextName);
}
}
return _context;
}
}
/// <summary>
/// Creates the specified controller by using the specified request context.
/// </summary>
/// <param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
/// <param name="controllerName">The name of the controller.</param>
/// <returns>A reference to the controller.</returns>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="requestContext"/> parameter is null.</exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="controllerName"/> parameter is null or empty.</exception>
public override IController CreateController(RequestContext requestContext, string controllerName)
{
if (ApplicationContext.ContainsObjectDefinition(controllerName))
return ApplicationContext.GetObject(controllerName) as IController;
return base.CreateController(requestContext, controllerName);
}
/// <summary>
/// Gets or sets the name of the application context.
/// </summary>
/// <remarks>
/// Defaults to using the root (default) Application Context.
/// </remarks>
/// <value>The name of the application context.</value>
public static string ApplicationContextName { get; set; }
/// <summary>
/// Retrieves the controller instance for the specified request context and controller type.
/// </summary>
/// <param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
/// <param name="controllerType">The type of the controller.</param>
/// <returns>The controller instance.</returns>
/// <exception cref="T:System.Web.HttpException">
/// <paramref name="controllerType"/> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="controllerType"/> cannot be assigned.</exception>
/// <exception cref="T:System.InvalidOperationException">An instance of <paramref name="controllerType"/> cannot be created.</exception>
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
if (controllerType != null)
{
var controllers = ApplicationContext.GetObjectsOfType(controllerType);
if (controllers.Count > 0)
{
return (IController)controllers.Cast<DictionaryEntry>().First<DictionaryEntry>().Value;
}
}
//pass to base class for remainder of handling if can't find it in the context
return base.GetControllerInstance(requestContext, controllerType);
}
}
}

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Spring.Objects.Factory;
using Spring.Core.IO;
using Spring.Objects.Factory.Xml;
using System.Web.Routing;
using Spring.Context.Support;
namespace Spring.Web.Mvc
{
public abstract class SpringMvcApplication : HttpApplication
{
protected virtual void Application_Start(object sender, EventArgs e)
{
RegisterAreas();
RegisterRoutes(RouteTable.Routes);
}
/// <summary>
/// Configures the <see cref="ApplicationContext"/> instance.
/// </summary>
/// <remarks>
/// You must override this method in a derived class to control the manner in which the
/// <see cref="ApplicationContext"/> is configured.
/// </remarks>
protected virtual void ConfigureApplicationContext()
{
}
public override void Init()
{
base.Init();
//the Spring HTTP Module won't have built the context for us until now so we have to delay until the init
ConfigureApplicationContext();
RegisterSpringControllerFactory();
}
/// <summary>
/// Registers the areas.
/// </summary>
/// <remarks>
/// Override this method in a derived class to modify the registered areas as neeeded.
/// </remarks>
protected virtual void RegisterAreas()
{
AreaRegistration.RegisterAllAreas();
}
/// <summary>
/// Registers the routes.
/// </summary>
/// <remarks>
/// Override this method in a derived class to modify the registered routes as neeeded.
/// </remarks>
protected virtual void RegisterRoutes(RouteCollection routes)
{
// This IgnoreRoute call is provided to avoid the trouble of CASSINI passing all req's thru
// ASP.NET (and thus the controller pipeline) during debugging
// see http://stackoverflow.com/questions/487230/serving-favicon-ico-in-asp-net-mvc and elsewhere for more info
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
/// <summary>
/// Registers the controller factory with the Mvc Framework.
/// </summary>
protected virtual void RegisterSpringControllerFactory()
{
ControllerBuilder.Current.SetControllerFactory(typeof(SpringControllerFactory));
}
}
}

View File

@@ -29,12 +29,14 @@ using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using Spring.Data.Common;
using Spring.Data.Support;
using Spring.Transaction;
using Spring.Transaction.Support;
using Spring.Transaction.Interceptor;
using System.Transactions;
using System.Collections.Generic;
using Spring.Core.IO;
using NHibernate.Cfg;
using System.Diagnostics;
using System.Threading;
#endregion
@@ -202,5 +204,135 @@ namespace Spring.Data.NHibernate
cmd.ExecuteNonQuery();
}
[Test]
public void Test2()
{
for (int i = 0; i < 200; i++)
{
//DaoOperationsViaProxyFactoryWithTxAttributes();
try
{
zzzExecuteDaoOperations();
}
catch (Exception)
{
}
}
}
private void zzzExecuteDaoOperations()
{
ITestObjectDao dao = (ITestObjectDao)ctx["SimpleTestDao"];
TestObject toGeorge = new TestObject();
toGeorge.Name = "George";
toGeorge.Age = 33;
dao.Create(toGeorge);
}
//private void MethodForThread()
//{
//
// MethodForThread((0));
//}
private void MethodForThread(object taskCounter)
{
int counter = (int)taskCounter;
for (int i = 0; i < 200; i++)
{
try
{
Debug.WriteLine(String.Format("Task: {0} | Loop Count: {1}", counter, i));
zzzExecuteDaoOperations();
}
catch (Exception)
{
}
}
Debug.WriteLine(String.Format("\n---------\nCompleting Task Number {0}\n---------\n", taskCounter));
}
[Test]
public void Test()
{
BasicConfigurator.Configure();
string assemblyName = GetType().Assembly.GetName().Name;
ctx = new XmlApplicationContext("assembly://" + assemblyName + "/Spring.Data.NHibernate/txScopeBugTests.xml");
dbProvider = ctx["DbProvider"] as IDbProvider;
transactionManager = ctx["TransactionManager"] as IPlatformTransactionManager;
CleanupDatabase(dbProvider.CreateConnection());
List<Thread> threads = new List<Thread>();
for (int i = 0; i < 200; i++)
{
int taskCounter = i;
Debug.WriteLine(String.Format("\n---------\nSpawning Task Number {0}\n---------\n", taskCounter));
Thread t = new Thread(MethodForThread);
threads.Add(t);
t.Start(taskCounter);
}
foreach (Thread thread in threads)
{
thread.Join();
}
}
public void DoNothing()
{
ConfigurableResourceLoader loader = new ConfigurableResourceLoader();
Configuration c = new Configuration();
String resourceName =
"assembly://Spring.Data.NHibernate21.Integration.Tests/Spring.Data.NHibernate/TestObject.hbm.xml";
c.AddInputStream(loader.GetResource(resourceName).InputStream);
ISessionFactory sf = c.BuildSessionFactory();
}
[Test]
public void LeaksConnectionSampleCodeFromBlogPost()
{
int counter = 200;
for (int i = 0; i < counter; i++)
{
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
using (ISession session = ((ISessionFactory)ctx["SessionFactory"]).OpenSession())
{
/*
IQuery q = session.CreateQuery("from Spring.Data.NHibernate.TestObject");
q.List();
*/
using (ITransaction transaction = session.BeginTransaction())
{
IQuery q = session.CreateQuery("from Spring.Data.NHibernate.TestObject");
q.List();
//transaction.Rollback();
}
}
}
}
}
}
}

View File

@@ -0,0 +1,61 @@
using System;
using NHibernate;
using Spring.Transaction.Interceptor;
using System.Threading;
namespace Spring.Data.NHibernate
{
[Transaction]
public class SimpleTestDao : ITestObjectDao
{
private int _secondsToSleepBeforeException;
public int SecondsToSleepBeforeException
{
get { return _secondsToSleepBeforeException; }
set
{
_secondsToSleepBeforeException = value * 1000;
}
}
public ISessionFactory SessionFactory
{
get { return sessionFactory; }
set { sessionFactory = value; }
}
private ISessionFactory sessionFactory;
[Transaction]
public void Create(TestObject to)
{
sessionFactory.GetCurrentSession().FlushMode = FlushMode.Always;
sessionFactory.GetCurrentSession().Save(to);
Thread.Sleep(_secondsToSleepBeforeException);
throw new Exception();
}
public void Update(TestObject to)
{
throw new NotImplementedException();
}
public void Delete(TestObject to)
{
throw new NotImplementedException();
}
public TestObject FindByName(string name)
{
throw new NotImplementedException();
}
public void CreateUpdateRollback(TestObject to)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns='http://www.springframework.net'
xmlns:db="http://www.springframework.net/database"
xmlns:tx="http://www.springframework.net/tx">
<!--<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=(local);Initial Catalog=rewards;Integrated Security=True;Max Pool Size=10"/>-->
<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=(local)\sql2005;Initial Catalog=rewards;user id=sa;password=password"/>
<!--<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=MARK6500\NR2007;Initial Catalog=spring;user id=springqa;password=springqa;Max Pool Size=10"/>-->
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate21">
<property name="DbProvider" ref="DbProvider"/>
<property name="ExposeTransactionAwareSessionFactory" value="true" />
<property name="MappingResources">
<list>
<value>assembly://Spring.Data.NHibernate21.Integration.Tests/Spring.Data.NHibernate/TestObject.hbm.xml</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="dialect"
value="NHibernate.Dialect.MsSql2000Dialect"/>
<entry key="connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"/>
</dictionary>
</property>
</object>
<object id="SimpleTestDao" type="Spring.Data.NHibernate.SimpleTestDao, Spring.Data.NHibernate21.Integration.Tests">
<property name="SessionFactory" ref="SessionFactory"/>
<property name="SecondsToSleepBeforeException" value="0" />
</object>
<!--<object id="TransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate21">
<property name="DbProvider" ref="DbProvider"/>
<property name="sessionFactory" ref="SessionFactory"/>
</object>-->
<!--<object id="TransactionManager" type="Spring.Data.Core.TxScopeTransactionManager, Spring.Data" />-->
<object id="TransactionManager" type="Spring.Data.NHibernate.HibernateTxScopeTransactionManager, Spring.Data.NHibernate21">
<property name="DbProvider" ref="DbProvider"/>
<property name="sessionFactory" ref="SessionFactory"/>
</object>
<tx:attribute-driven transaction-manager="TransactionManager"/>
</objects>

View File

@@ -147,6 +147,7 @@
<Compile Include="Data\NHibernate\AccountController.cs" />
<Compile Include="Data\NHibernate\HibernateTxScopeTransactionManagerTests.cs" />
<Compile Include="Data\NHibernate\IAccountController.cs" />
<Compile Include="Data\NHibernate\SimpleTestDao.cs" />
<Compile Include="Setup.cs" />
</ItemGroup>
<ItemGroup>
@@ -205,6 +206,7 @@
<ItemGroup>
<Content Include="Data\NHibernate\Bytecode\Foo.Spechbm.xml" />
<EmbeddedResource Include="Data\NHibernate\HibernateTxScopeTransactionManagerTests.xml" />
<EmbeddedResource Include="Data\NHibernate\txScopeBugTests.xml" />
<Content Include="TestEnbeddedConfig.cfg.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Web;
using System.Web.Routing;
using Spring.Core.IO;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;
using System.Web.Mvc;
using Spring.Web.Mvc.Tests.Controllers;
using Spring.Context.Support;
using System.Reflection;
namespace Spring.Web.Mvc.Tests
{
public static class ControllerFactoryTestExtension
{
private static readonly PropertyInfo _typeCacheProperty;
private static readonly FieldInfo _cacheField;
static ControllerFactoryTestExtension()
{
_typeCacheProperty = typeof(DefaultControllerFactory).GetProperty("ControllerTypeCache", BindingFlags.Instance | BindingFlags.NonPublic);
_cacheField = _typeCacheProperty.PropertyType.GetField("_cache", BindingFlags.NonPublic | BindingFlags.Instance);
}
/// <summary>
/// Replaces the cache field of a the DefaultControllerFactory's ControllerTypeCache.
/// This ensures that only the specified controller types will be searched when instantiating a controller.
/// As the ControllerTypeCache is internal, this uses some reflection hackery.
/// </summary>
public static void InitializeWithControllerTypes(this IControllerFactory factory, params Type[] controllerTypes)
{
var cache = controllerTypes
.GroupBy(t => t.Name.Substring(0, t.Name.Length - "Controller".Length), StringComparer.OrdinalIgnoreCase)
.ToDictionary(g => g.Key, g => g.ToLookup(t => t.Namespace ?? string.Empty, StringComparer.OrdinalIgnoreCase), StringComparer.OrdinalIgnoreCase);
var buildManager = _typeCacheProperty.GetValue(factory, null);
_cacheField.SetValue(buildManager, cache);
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Spring.Web.Mvc.Tests.Controllers
{
public class FirstContainerRegisteredController : Controller
{
public string TestValue { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Spring.Web.Mvc.Tests.Controllers
{
public class NamedContextController : Controller
{
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Spring.Web.Mvc.Tests.Controllers
{
public class NotInContainerController : Controller
{
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Web;
using System.Web.Mvc;
namespace Spring.Web.Mvc.Tests.Controllers
{
public class SecondContainerRegisteredController : Controller
{
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Spring.Web.Mvc.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Spring.Web.Mvc.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3f96ac7b-cd25-4d07-8b1c-ee2eb77cf5eb")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D4032434-D9A8-437B-95E8-9D4DE0AD9932}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring.Web.Mvc.Tests</RootNamespace>
<AssemblyName>Spring.Web.Mvc.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ControllerFactoryTestExtension.cs" />
<Compile Include="Controllers\NamedContextController.cs" />
<Compile Include="Controllers\SecondContainerRegisteredController.cs" />
<Compile Include="Controllers\NotInContainerController.cs" />
<Compile Include="Controllers\FirstContainerRegisteredController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpringControllerFactoryTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2010.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2010</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Web.Mvc\Spring.Web.Mvc.2010.csproj">
<Project>{5166CE3A-14BE-478A-88DA-729A39DE1E29}</Project>
<Name>Spring.Web.Mvc.2010</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="objects.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="namedContextObjects.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="objectsMatchByType.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" ?>
<project name="Spring.Web.Tests" default="test" xmlns="http://nant.sf.net/schemas/nant.xsd">
<include buildfile="${spring.basedir}/common-project.include" />
<!--
Required properties:
* current.bin.dir - (path) root level to build to
* build.debug - (true|false) debug build?
* current.build.defines.csc - framework-specific build defines
* lib.dir - framework-specific assembly references
-->
<target name="build">
<!-- build Spring.Web.Mvc -->
<csc target="library" define="${current.build.defines.csc}"
warnaserror="true"
optimize="${build.optimize}"
debug="${current.build.debug}"
output="${current.bin.dir}/${project::get-name()}.dll"
doc="${current.bin.dir}/${project::get-name()}.xml">
<nowarn>
<warning number="${nowarn.numbers.test}" /> <!-- 1701 -->
<warning number="${nowarn.numbers.test},1587" if="${nant.settings.currentframework=='mono-2.0'}"/>
</nowarn>
<sources failonempty="true">
<include name="**/*.cs" />
<include name="../CommonAssemblyInfo.cs" />
</sources>
<resources prefix="Spring" dynamicprefix="true" failonempty="true">
<include name="**/*.resx" />
<include name="**/*.xsd" />
<include name="**/*.txt" />
<include name="**/*.xml" />
<exclude name="Data/**/*" />
<exclude name="obj/**/*" />
</resources>
<references basedir="${current.bin.dir}">
<include name="*.dll" />
<include name="System.Configuration.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<include name="System.Drawing.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<include name="System.Xml.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<include name="System.Web.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<include name="System.Web.Services.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<include name="System.Data.dll" if="${nant.settings.currentframework=='mono-2.0'}" />
<exclude name="${project::get-name()}.dll" />
<exclude name="CloverRuntime.dll" />
<include name="${lib.dir}/nunit.core.interfaces.dll" />
<exclude if="${net-4.0}" name="System.Web.Extensions.dll" />
</references>
</csc>
<copy todir="${current.bin.dir}">
<fileset basedir="${project::get-base-directory()}/Data">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="test" depends="build">
<!-- property name="test.assemblyname" value="${project::get-name()}" / -->
<call target="common.run-tests" />
</target>
<!--
<target name="test" depends="build">
<nunit2outproc>
<formatter type="Plain" />
<formatter type="Xml" usefile="true" extension=".xml" outputdir="${current.bin.dir}/results" />
<test assemblyname="${current.bin.dir}/${project::get-name()}.dll" />
</nunit2outproc>
</target>
-->
</project>

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Web;
using System.Web.Routing;
using Spring.Core.IO;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;
using System.Web.Mvc;
using Spring.Web.Mvc.Tests.Controllers;
using Spring.Context.Support;
using System.Reflection;
namespace Spring.Web.Mvc.Tests
{
internal class MockContext : HttpContextBase { }
[TestFixture]
public class SpringControllerFactoryTests
{
private MvcApplicationContext _context;
private MvcApplicationContext _mvcNamedContext;
private SpringControllerFactory _factory;
[SetUp]
public void _TestSetup()
{
ContextRegistry.Clear();
_context = new MvcApplicationContext("assembly://Spring.Web.Mvc.Tests/Spring.Web.Mvc.Tests/objects.xml");
_mvcNamedContext = new MvcApplicationContext("named", false, "assembly://Spring.Web.Mvc.Tests/Spring.Web.Mvc.Tests/namedContextObjects.xml");
ContextRegistry.RegisterContext(_context);
ContextRegistry.RegisterContext(_mvcNamedContext);
_factory = new SpringControllerFactory();
//due to ridiculous internal methods in DefaultControllerFactory, have to set the ControllerTypeCache using this extension method
// see http://stackoverflow.com/questions/727181/asp-net-mvc-system-web-compilation-compilationlock for more info
_factory.InitializeWithControllerTypes(new[]
{
typeof(FirstContainerRegisteredController),
typeof(SecondContainerRegisteredController),
typeof(NotInContainerController),
typeof(NamedContextController),
});
}
[Test]
public void ProperlyResolvesCaseInsensitiveControllerNames()
{
IController pascalcaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
IController lowercaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "firstcontainerregistered");
Assert.AreEqual(typeof(FirstContainerRegisteredController), pascalcaseController.GetType());
Assert.AreEqual(typeof(FirstContainerRegisteredController), lowercaseController.GetType());
}
[Test]
public void CanPreferIdMatchOverTypeMatch()
{
IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
Assert.AreEqual("Should_Be_Matched_By_Id", ((FirstContainerRegisteredController)controller).TestValue);
}
[Test]
public void CanRevertToTypeMatchIfIdMatchUnsuccessful()
{
MvcApplicationContext context = new MvcApplicationContext("assembly://Spring.Web.Mvc.Tests/Spring.Web.Mvc.Tests/objectsMatchByType.xml");
ContextRegistry.Clear();
ContextRegistry.RegisterContext(context);
IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
Assert.AreEqual("Should_Be_Matched_By_Type", ((FirstContainerRegisteredController)controller).TestValue);
}
[Test]
public void CanRetrieveControllersNotRegisteredWithContainer()
{
_factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NotInContainer");
}
[Test]
public void CanUseNamedContextToResolveController()
{
SpringControllerFactory.ApplicationContextName = "named";
IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NamedContext");
Assert.NotNull(controller);
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
<object id="NamedContextController" singleton="false" type="Spring.Web.Mvc.Tests.Controllers.NamedContextController, Spring.Web.Mvc.Tests"/>
</objects>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
<!--id/name intentionally excluded from this definition so that we can ensure retrieve-by-type-match works-->
<object singleton="false" type="Spring.Web.Mvc.Tests.Controllers.FirstContainerRegisteredController, Spring.Web.Mvc.Tests">
<property name="TestValue" value="Should_Be_Matched_By_Type" />
</object>
<!--this object defintion matches the controller name that would be retrieved based on the actual request-->
<object id="FirstContainerRegistered" singleton="false" type="Spring.Web.Mvc.Tests.Controllers.FirstContainerRegisteredController, Spring.Web.Mvc.Tests">
<property name="TestValue" value="Should_Be_Matched_By_Id" />
</object>
<object id="SecondContainerRegisteredController" singleton="false" type="Spring.Web.Mvc.Tests.Controllers.SecondContainerRegisteredController, Spring.Web.Mvc.Tests"/>
</objects>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd">
<!--id/name intentionally excluded from this definition so that we can ensure retrieve-by-type-match works-->
<object singleton="false" type="Spring.Web.Mvc.Tests.Controllers.FirstContainerRegisteredController, Spring.Web.Mvc.Tests">
<property name="TestValue" value="Should_Be_Matched_By_Type" />
</object>
</objects>