diff --git a/Spring.Net.2008.sln b/Spring.Net.2008.sln
index e5dc5b7b..982b141c 100644
--- a/Spring.Net.2008.sln
+++ b/Spring.Net.2008.sln
@@ -63,6 +63,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate21.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate21.2008", "src\Spring\Spring.Data.NHibernate21\Spring.Data.NHibernate21.2008.csproj", "{E57B4652-0231-49CB-B058-87E10EFE540D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Template.Velocity.2008", "src\Spring\Spring.Template.Velocity\Spring.Template.Velocity.2008.csproj", "{BF3AB954-8375-407C-9E98-4C51D8072784}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Template.Velocity.Tests", "test\Spring\Spring.Template.Velocity.Tests\Spring.Template.Velocity.Tests.csproj", "{10405837-CB67-40D8-9326-84C9383983E2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
@@ -377,6 +381,26 @@ Global
{E57B4652-0231-49CB-B058-87E10EFE540D}.Release|Any CPU.Build.0 = Release|Any CPU
{E57B4652-0231-49CB-B058-87E10EFE540D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E57B4652-0231-49CB-B058-87E10EFE540D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Debug|.NET.ActiveCfg = Debug|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Release|.NET.ActiveCfg = Release|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {BF3AB954-8375-407C-9E98-4C51D8072784}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Debug|.NET.ActiveCfg = Debug|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Release|.NET.ActiveCfg = Release|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {10405837-CB67-40D8-9326-84C9383983E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/doc/reference/src/index.xml b/doc/reference/src/index.xml
index c6370f6c..5610d79d 100644
--- a/doc/reference/src/index.xml
+++ b/doc/reference/src/index.xml
@@ -1,4 +1,4 @@
-
+
@@ -17,6 +17,7 @@
+
@@ -62,7 +63,7 @@
The Spring.NET FrameworkReference DocumentationVersion 1.2.1
- Last Updated April xx, 2009 (Latest documentation)
+ Last Updated July xx, 2009 (Latest documentation)Mark
@@ -104,6 +105,10 @@
ChoyRim
+
+ Erez
+ Mazor
+ The SpringJava Team
@@ -328,11 +333,17 @@
+
+
+
+
+
&messaging;
&msmq;
&scheduling;
+ &templating;
VS.NET Integration
diff --git a/doc/reference/src/templating.xml b/doc/reference/src/templating.xml
new file mode 100644
index 00000000..5fc77f98
--- /dev/null
+++ b/doc/reference/src/templating.xml
@@ -0,0 +1,223 @@
+
+
+
+ Template Engine Support
+
+
+ Introduction
+
+ The Spring Framework features integration classes for templating
+ engine support. Currently, Spring supports the NVelocity
+ templating engine.
+
+
+
+ Dependencies
+
+ The Spring NVelocity support depends on the Castle project's
+ NVelocity implementation which is provided in the lib directory of the
+ spring release.
+
+
+
+ Using the NVelocity Factory Object
+
+ The NVelocity template engine is set up using a
+ IFactoryObject with optional configuration parameters
+ to define where templates reside, define logging and more.
+
+
+ Simple file based template engine definition
+
+ A simple definition of the template engine:
+
+ <!-- Simple no arg file based configuration use's NVeclocity default file resource loader -->
+<object id="velocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity" />
+
+ The velocity engine could then be used to load and merge a local
+ template using a simple relative path:
+
+ StringWriter stringWriter = new StringWriter();
+Hashtable modelTable = new Hashtable();
+modelTable.Add("var1", TEST_VALUE);
+VelocityContext velocityContext = new VelocityContext(modelTable);
+velocityEngine.MergeTemplate("Template/Velocity/MyTemplate.vm", Encoding.UTF8.WebName, velocityContext, stringWriter);
+string mergedContent = stringWriter.ToString();
+
+
+
+ Assembly based template loading
+
+ When templates are packaged in an assembly, NVelocity's assembly
+ resource loader can be used to define where templates reside:
+
+ <!-- Assembly based template loading with NVelocity assembly resource loader -->
+<object id="assemblyBasedVelocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity">
+ <property name="VelocityProperties">
+ <dictionary key-type="string" value-type="object">
+ <entry key="resource.loader" value="assembly"/>
+ <entry key="assembly.resource.loader.class" value="NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader"/>
+ <entry key="assembly.resource.loader.assembly" value="MyAssembly"/>
+ </dictionary>
+ </property>
+</object>
+
+ Using the example above the template would be loaded using a
+ namespace syntax for the template resource:
+
+ velocityEngine.MergeTemplate("MyAssembly.MyNamespace.MyTemplate.vm", Encoding.UTF8.WebName, velocityContext, stringWriter);
+
+ Using the custom namespace the same definition could be
+ simplified:
+
+ <template:nvelocity id="velocityEngine" >
+ <template:resource-loader>
+ <template:assembly name="MyAssembly" />
+ </template:resource-loader>
+</template:nvelocity>
+
+
+
+ Using Spring's IResourceLoader to load
+ templates
+
+ In some cases Spring's resource abstraction can be beneficial to
+ load templates from a variety of resources. A spring resource loader
+ extension to the NVelocity resource loader implementation is provided
+ for this use case.
+
+ <object id="velocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity" >
+ <property name="ResourceLoaderPath" value="file://MyTemplateFolder/AnotherFolder/" />
+</object>
+
+
+ Or with multiple locations
+
+ <object id="velocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity" >
+ <property name="ResourceLoaderPaths" >
+ <list>
+ <value>file://MyTemplateFolder/</value>
+ <value>file://MyOtherTemplateFolder/</value>
+ </list>
+ </property>
+</object>
+
+
+ By default spring will attempt to load resources using file
+ based template loading (useful for detection of template changes at
+ runtime). If this is not desirable you set the
+ preferFileSystemAccess property of the factory
+ object to false
+ (prefer-file-system-access="false" for custom
+ namespace use)
+
+
+ Using the example above when resource loader paths are defined
+ templates can be loaded using their name:
+
+ string mergedTemplate = VelocityEngineUtils.MergeTemplateIntostring(velocityEngine, "MyTemplate.vm", Encoding.UTF8.WebName, model);
+
+
+
+ Using a custom configuration file
+
+ If so desired one could provide a custom configuration resource to
+ customize the NVelocity configuration:
+
+ <object id="velocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity" >
+ <property name="ConfigLocation " value="file://Template/Velocity/config.properties" />
+</object>
+
+
+
+ You can override specific properties by providing the VelocityProperties property to the NVelocity factory object (shown above)
+
+
+
+
+
+
+
+ Logging
+
+
+
+ By default Spring will override NVelocity's default
+ ILogSystem implementation with its own
+ CommonsLoggingLogSystem implementation. If this is
+ not desirable, you can specify the following property of the NVelocity
+ factory object:
+
+
+
+ <object id="velocityEngine" type="Spring.Template.Velocity.VelocityEngineFactoryObject, Spring.Template.Velocity" >
+ <property name="OverrideLogging" value="false" />
+</object>
+
+ or
+
+ <template:nvelocity id="velocityEngine" override-logging="false" />
+
+
+
+
+
+ You can override specific NVelocity properties locally by
+ providing a dictionary as the VelocityProperties
+ property of the NVelocity factory object (shown above)
+
+
+
+
+
+
+
+ Merging a template
+
+ Spring provides the VelocityEngineUtils utility
+ for merging templates using an engine instance:
+
+ string mergedTemplate = VelocityEngineUtils.MergeTemplateIntostring(velocityEngine, "MyTemplate.vm", Encoding.UTF8.WebName, model);
+
+
+
+ Namespace
+
+ For convinience in defining NVelocity engine instances a custom
+ namespace is provided, for example the resource loader definition could be
+ done this way:
+
+
+<objects xmlns="http://www.springframework.net" xmlns:template="http://www.springframework.net/template">
+
+<template:nvelocity id="customNamespaceVelocityTemplate" >
+ <template:resource-loader>
+ <template:file path="Template/Velocity/" />
+ </template:resource-loader>
+</template:nvelocity>
+
+</objects>
+
+
diff --git a/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserRegistry.cs b/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserRegistry.cs
index 863b5a1a..74fa07ac 100644
--- a/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserRegistry.cs
+++ b/src/Spring/Spring.Core/Objects/Factory/Xml/NamespaceParserRegistry.cs
@@ -102,6 +102,7 @@ namespace Spring.Objects.Factory.Xml
wellknownNamespaceParserTypeNames["http://www.springframework.net/nms"] = "Spring.Messaging.Nms.Config.NmsNamespaceParser, Spring.Messaging.Nms";
wellknownNamespaceParserTypeNames["http://www.springframework.net/ems"] = "Spring.Messaging.Ems.Config.EmsNamespaceParser, Spring.Messaging.Ems";
wellknownNamespaceParserTypeNames["http://www.springframework.net/validation"] = "Spring.Validation.Config.ValidationNamespaceParser, Spring.Core";
+ wellknownNamespaceParserTypeNames["http://www.springframework.net/template"] = "Spring.Template.Config.TemplateNamespaceParser, Spring.Template.Velocity";
Reset();
}
diff --git a/src/Spring/Spring.Template.Velocity/Spring.Template.Velocity.2008.csproj b/src/Spring/Spring.Template.Velocity/Spring.Template.Velocity.2008.csproj
index 316884ec..82731207 100644
--- a/src/Spring/Spring.Template.Velocity/Spring.Template.Velocity.2008.csproj
+++ b/src/Spring/Spring.Template.Velocity/Spring.Template.Velocity.2008.csproj
@@ -58,6 +58,7 @@
..\..\..\lib\Net\2.0\NVelocity.dll
+
@@ -66,6 +67,7 @@
+
@@ -99,6 +101,9 @@
false
+
+
+
-
\ No newline at end of file