NVelocity configuration integration classes - thanks Erez Mazor and welcome to the project!

This commit is contained in:
markpollack
2009-06-04 01:34:53 +00:00
parent 9c0d6fe821
commit f418aaa4d9
14 changed files with 1076 additions and 0 deletions

View File

@@ -354,6 +354,8 @@ Build properties that may be set:
<nant buildfile="src/Spring/Spring.Messaging.Nms/Spring.Messaging.Nms.build" target="build" if="${build-nms and not net-3.0}"/>
<nant buildfile="src/Spring/Spring.Scheduling.Quartz/Spring.Scheduling.Quartz.build" target="build" if="${build-quartz and not net-3.0}"/>
<nant buildfile="src/Spring/Spring.Messaging/Spring.Messaging.build" target="build" if="${build-msmq and not net-3.0}"/>
<nant buildfile="src/Spring/Spring.Template.Velocity/Spring.Template.Velocity.build" target="build" if="${build-velocity and not net-3.0}"/>
<!-- build examples -->
@@ -381,6 +383,7 @@ Build properties that may be set:
<nant buildfile="test/Spring/Spring.Messaging.Nms.Tests/Spring.Messaging.Nms.Tests.build" target="test" if="${build-nms and not net-3.0}"/>
<nant buildfile="test/Spring/Spring.Scheduling.Quartz.Tests/Spring.Scheduling.Quartz.Tests.build" target="build" if="${build-quartz and not net-3.0}"/>
<nant buildfile="test/Spring/Spring.Messaging.Tests/Spring.Messaging.Tests.build" target="test" if="${build-msmq-tests and not net-3.0}"/>
<nant buildfile="test/Spring/Spring.Template.Velocity.Tests/Spring.Template.Velocity.Tests.build" target="build" if="${build-quartz and not net-3.0}"/>
</target>
<target name="compile-net-1.0" description="Builds .NET Framework 1.0 version"
@@ -394,6 +397,7 @@ Build properties that may be set:
<property name="build-quartz" value="false" />
<property name="build-msmq" value="false" />
<property name="build-msmq-tests" value="false" />
<property name="build-velocity" value="false" />
<call target="compile-test" />
</target>
@@ -405,6 +409,7 @@ Build properties that may be set:
<property name="build-quartz" value="true" />
<property name="build-msmq" value="false" />
<property name="build-msmq-tests" value="false" />
<property name="build-velocity" value="false" />
<call target="compile-test" />
</target>
@@ -416,6 +421,7 @@ Build properties that may be set:
<property name="build-quartz" value="true" />
<property name="build-msmq" value="true" />
<property name="build-msmq-tests" value="false" />
<property name="build-velocity" value="true" />
<call target="compile-test" />
</target>
@@ -427,6 +433,7 @@ Build properties that may be set:
<property name="build-quartz" value="false" />
<property name="build-msmq" value="false" />
<property name="build-msmq-tests" value="false" />
<property name="build-velocity" value="false" />
<call target="compile-test" />
</target>
@@ -438,6 +445,7 @@ Build properties that may be set:
<property name="build-quartz" value="true" />
<property name="build-msmq" value="false" />
<property name="build-msmq-tests" value="false" />
<property name="build-velocity" value="true" />
<call target="compile-test" />
</target>
@@ -613,6 +621,8 @@ Build properties that may be set:
<delete dir="src/Spring/Spring.Messaging/bin" failonerror="false"/>
<delete dir="src/Spring/Spring.Scheduling.Quartz/obj" failonerror="false"/>
<delete dir="src/Spring/Spring.Scheduling.Quartz/bin" failonerror="false"/>
<delete dir="src/Spring/Spring.Template.Velocity/obj" failonerror="false"/>
<delete dir="src/Spring/Spring.Template.Velocity/bin" failonerror="false"/>
<delete dir="src/Spring/Spring.Testing.NUnit/obj" failonerror="false"/>
<delete dir="src/Spring/Spring.Testing.NUnit/bin" failonerror="false"/>
<delete dir="src/Spring/Spring.Web/obj" failonerror="false"/>
@@ -648,6 +658,8 @@ Build properties that may be set:
<delete dir="test/Spring/Spring.Messaging.Tests/bin" failonerror="false"/>
<delete dir="test/Spring/Spring.Scheduling.Quartz.Tests/obj" failonerror="false"/>
<delete dir="test/Spring/Spring.Scheduling.Quartz.Tests/bin" failonerror="false"/>
<delete dir="test/Spring/Spring.Template.Velocity.Tests/obj" failonerror="false"/>
<delete dir="test/Spring/Spring.Template.Velocity.Tests/bin" failonerror="false"/>
<delete dir="test/Spring/Spring.Web.Tests/obj" failonerror="false"/>
<delete dir="test/Spring/Spring.Web.Tests/bin" failonerror="false"/>
<delete dir="test/Spring/Spring.Testing.NUnit.Tests/obj" failonerror="false"/>
@@ -1011,6 +1023,10 @@ Build properties that may be set:
<include name="**/Spring.Scheduling.Quartz.xml"/>
<include name="**/Spring.Scheduling.Quartz.pdb"/>
<include name="**/Spring.Template.Velocity.dll"/>
<include name="**/Spring.Template.Velocity.xml"/>
<include name="**/Spring.Template.Velocity.pdb"/>
<include name="**/antlr.runtime.dll"/>
<include name="**/Common.Logging.dll"/>
@@ -1369,6 +1385,7 @@ Build properties that may be set:
<include name="src/Spring/Spring.Messaging/**"/>
<include name="src/Spring/Spring.Messaging.Nms/**"/>
<include name="src/Spring/Spring.Scheduling.Quartz/**"/>
<include name="src/Spring/Spring.Template.Velocity/**"/>
<include name="src/Spring/Spring.Testing.NUnit/**"/>
<include name="src/Spring/CommonAssemblyInfo.cs"/>
@@ -1385,6 +1402,7 @@ Build properties that may be set:
<include name="test/Spring/Spring.Messaging.Tests/**"/>
<include name="test/Spring/Spring.Messaging.Nms.Tests/**"/>
<include name="test/Spring/Spring.Scheduling.Quartz.Tests/**"/>
<include name="test/Spring/Spring.Template.Velocity.Tests/**"/>
<include name="test/Spring/Spring.Testing.NUnit.Tests/**"/>
<include name="test/Spring/CommonAssemblyInfo.cs"/>

View File

@@ -0,0 +1,66 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.2008", "..\..\src\Spring\Spring.Core\Spring.Core.2008.csproj", "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Tests.2008", "..\..\test\Spring\Spring.Core.Tests\Spring.Core.Tests.2008.csproj", "{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}"
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
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Release|.NET = Release|.NET
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|.NET.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|.NET.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.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
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
<TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6">
<RunConfiguration id="2f7969af-da92-4539-ac9d-76a6393f0ab9" name="Local Test Run" storage="localtestrun.testrunconfig" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, PublicKeyToken=b03f5f7f11d50a3a" />
</TestList>
</TestLists>

BIN
lib/Net/2.0/NVelocity.dll Normal file

Binary file not shown.

BIN
lib/Net/2.0/NVelocity.pdb Normal file

Binary file not shown.

View File

@@ -0,0 +1,110 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BF3AB954-8375-407C-9E98-4C51D8072784}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring</RootNamespace>
<AssemblyName>Spring.Template.Velocity</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<PublishUrl>http://localhost/Spring.Template.Velocity/</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>true</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\build\VS.NET.2005\Spring.Template.Velocity\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\..\build\VS.NET.2005\Spring.Template.Velocity\Debug\Spring.Template.Velocity.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\build\VS.NET.2005\Spring.Template.Velocity\Release\</OutputPath>
<DefineConstants>TRACE;NET_2_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="NVelocity, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\Net\2.0\NVelocity.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spring.Core\Spring.Core.2008.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2008</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Template\Velocity\CommonsLoggingLogSystem.cs" />
<Compile Include="Template\Velocity\SpringResourceLoader.cs" />
<Compile Include="Template\Velocity\VelocityEngineFactory.cs" />
<Compile Include="Template\Velocity\VelocityEngineFactoryObject.cs" />
<Compile Include="Template\Velocity\VelocityEngineUtils.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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,65 @@
#region License
/*
* Copyright 2002-2009 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 Common.Logging;
using NVelocity.Runtime;
using NVelocity.Runtime.Log;
using LogLevel=NVelocity.Runtime.Log.LogLevel;
using LogManager=Common.Logging.LogManager;
namespace Spring.Template.Velocity
{
/// <summary>
/// Velocity LogSystem implementation for Jakarta Commons Logging.
/// </summary>
/// <author>Erez Mazor</author>
public class CommonsLoggingLogSystem : ILogSystem {
protected static readonly ILog log = LogManager.GetLogger(typeof(CommonsLoggingLogSystem));
/// <summary>
/// Inits the specified runtime services. No-op in current implementatin
/// </summary>
/// <param name="runtimeServices">The runtime services.</param>
public void Init(IRuntimeServices runtimeServices) {
}
/// <summary>
/// Log a velocity message using the commons logging system
/// </summary>
/// <param name="level">LogLevel to match</param>
/// <param name="message">Message to log</param>
public void LogVelocityMessage(LogLevel level, string message) {
switch (level) {
case LogLevel.Error:
log.Error(message);
break;
case LogLevel.Warn:
log.Warn(message);
break;
case LogLevel.Info:
log.Info(message);
break;
case LogLevel.Debug:
log.Debug(message);
break;
}
}
}
}

View File

@@ -0,0 +1,136 @@
#region License
/*
* Copyright 2002-2009 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 System.IO;
using Common.Logging;
using Commons.Collections;
using NVelocity.Runtime.Resource;
using NVelocity.Runtime.Resource.Loader;
using Spring.Core.IO;
namespace Spring.Template.Velocity
{
/// <summary>
/// Velocity ResourceLoader adapter that loads via a Spring IResourceLoader.
/// Used by VelocityEngineFactory for any resource loader path that cannot
/// be resolved to a File
///
/// <p>Take notoce that this loader does not allow for modification detection:
/// Use Velocity's default FileResourceLoader for File resources.
///
/// <p>Expects "spring.resource.loader" and "spring.resource.loader.path"
/// application attributes in the Velocity runtime: the former of type
/// <code>IResourceLoader</code>, the latter a String.
/// </summary>
/// <see cref="VelocityEngineFactory.ResourceLoaderPath"/>
/// <see cref="IResourceLoader"/>
/// <see cref="FileResourceLoader"/>
/// <author>Erez Mazor (.NET) </author>
public class SpringResourceLoader : ResourceLoader {
public static readonly string NAME = "spring";
public static readonly string SPRING_RESOURCE_LOADER_CLASS = "spring.resource.loader.class";
public static readonly string SPRING_RESOURCE_LOADER_CACHE = "spring.resource.loader.cache";
public static readonly string SPRING_RESOURCE_LOADER = "spring.resource.loader";
public static readonly string SPRING_RESOURCE_LOADER_PATH = "spring.resource.loader.path";
protected static readonly ILog log = LogManager.GetLogger(typeof(SpringResourceLoader));
private IResourceLoader resourceLoader;
private string[] resourceLoaderPaths;
/// <summary>
/// Initialize the template loader with a resources class.
/// </summary>
/// <param name="configuration">The configuration.</param>
public override void Init(ExtendedProperties configuration) {
resourceLoader = (IResourceLoader)rsvc.GetApplicationAttribute(SPRING_RESOURCE_LOADER);
string resourceLoaderPath = (string)rsvc.GetApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
if (resourceLoader == null) {
throw new ArgumentException("'resourceLoader' application attribute must be present for SpringResourceLoader");
}
if (resourceLoaderPath == null) {
throw new ArgumentException("'resourceLoaderPath' application attribute must be present for SpringResourceLoader");
}
resourceLoaderPaths = resourceLoaderPath.Split(',');
for (int i = 0; i < resourceLoaderPaths.Length; i++) {
string path = resourceLoaderPaths[i];
if (!path.EndsWith("/")) {
resourceLoaderPaths[i] = path + "/";
}
}
if (log.IsInfoEnabled) {
log.Info(string.Format("SpringResourceLoader for Velocity: using resource loader [{0}] and resource loader paths {1}", resourceLoader, resourceLoaderPaths));
}
}
/// <summary>
/// Get the InputStream that the Runtime will parse to create a template.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public override Stream GetResourceStream(string source) {
if (log.IsDebugEnabled) {
log.Debug(string.Format("Looking for Velocity resource with name [{0}]", source));
}
for (int i = 0; i < resourceLoaderPaths.Length; i++) {
IResource resource =
resourceLoader.GetResource(resourceLoaderPaths[i] + source);
try {
return resource.InputStream;
} catch (IOException ex) {
if (log.IsErrorEnabled) {
log.Error(string.Format("Could not find Velocity resource: {0}", resource), ex);
}
}
}
throw new ArgumentException(string.Format("Could not find resource [{0}] in Spring resource loader path", source));
}
/// <summary>
/// Given a template, check to see if the source of InputStream has been modified.
/// </summary>
/// <param name="resource">The resource.</param>
/// <returns>
/// <c>true</c> if the source of the InputStream has been modified; otherwise, <c>false</c>.
/// </returns>
public override bool IsSourceModified(Resource resource) {
return false;
}
/// <summary>
/// Get the last modified time of the InputStream source
/// that was used to create the template. We need the template
/// here because we have to extract the name of the template
/// in order to locate the InputStream source.
/// </summary>
/// <param name="resource">The resource.</param>
/// <returns></returns>
public override long GetLastModified(Resource resource) {
return 0;
}
}
}

View File

@@ -0,0 +1,332 @@
#region License
/*
* Copyright 2002-2009 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 System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Common.Logging;
using Commons.Collections;
using NVelocity.App;
using NVelocity.Exception;
using NVelocity.Runtime;
using NVelocity.Runtime.Resource.Loader;
using Spring.Context.Support;
using Spring.Core.IO;
namespace Spring.Template.Velocity{
/// <summary>
/// Factory that configures a VelocityEngine. Can be used standalone,
/// but typically you will either use {@link VelocityEngineFactoryBean}
/// for preparing a VelocityEngine as bean reference.
///
/// <p>The optional "ConfigLocation" property sets the location of the Velocity
/// properties file, within the current application. Velocity properties can be
/// overridden via "VelocityProperties", or even completely specified locally,
/// avoiding the need for an external properties file.
///
/// <p>The "ResourceLoaderPath" property can be used to specify the Velocity
/// resource loader path via Spring's Resource abstraction, possibly relative
/// to the Spring application context.
///
/// <p>If "OverrideLogging" is true (the default), the VelocityEngine will be
/// configured to log via Commons Logging, that is, using the Spring-provided
/// "CommonsLoggingLogSystem" as log system.
///
/// <p>The simplest way to use this class is to specify a ResourceLoaderPath
/// property; the VelocityEngine typically then does not need any further
/// configuration.
///
/// </summary>
/// <see cref="CommonsLoggingLogSystem" />
/// <see cref="VelocityEngineFactoryObject" />
/// <see cref="CommonsLoggingLogSystem" />
/// <author>Erez Mazor (.NET) </author>
public class VelocityEngineFactory {
private const char DELIMITER = ',';
protected static readonly ILog log = LogManager.GetLogger(typeof(VelocityEngineFactory));
private IResource configLocation;
private IDictionary<string, object> velocityProperties = new Dictionary<string, object>();
private String resourceLoaderPath;
private IResourceLoader resourceLoader = new ConfigurableResourceLoader();
private bool preferFileSystemAccess = true;
private bool overrideLogging = true;
/// <summary>
/// Set the location of the Velocity config file. Alternatively, you can specify all properties locally.
/// </summary>
/// <see cref="VelocityProperties"/>
/// <see cref="ResourceLoaderPath"/>
public IResource ConfigLocation {
set { configLocation = value; }
}
/// <summary>
/// Set Velocity properties as Map, to allow for non-String values like "ds.resource.loader.instance".
/// </summary>
/// <see cref="VelocityProperties"/>
public IDictionary<string, object> VelocityProperties {
set { velocityProperties = value; }
}
/// <summary>
///
/// Set the Velocity resource loader path via a Spring resource location.
/// Accepts multiple locations in Velocity's comma-separated path style.
/// <p>When populated via a String, standard URLs like "file:" and "assembly:"
/// pseudo URLs are supported, as understood by ResourceLoader. Allows for
/// relative paths when running in an ApplicationContext.
/// <p>Will define a path for the default Velocity resource loader with the name
/// "file". If the specified resource cannot be resolved to a <code>java.io.File</code>,
/// a generic SpringResourceLoader will be used under the name "spring", without
/// modification detection.
/// <p> Take notice that resource caching will be enabled in any case. With the file
/// resource loader, the last-modified timestamp will be checked on access to
/// detect changes. With SpringResourceLoader, the resource will be cached
/// forever (for example for class path resources).
/// <p>To specify a modification check interval for files, use Velocity's
/// standard "file.resource.loader.modificationCheckInterval" property. By default,
/// the file timestamp is checked on every access (which is surprisingly fast).
/// Of course, this just applies when loading resources from the file system.
/// <p>To enforce the use of SpringResourceLoader, i.e. to not resolve a path
/// as file system resource in any case, turn off the "preferFileSystemAccess"
/// flag. See the latter's javadoc for details.
/// </summary>
/// <see cref="ResourceLoader"/>
/// <see cref="VelocityProperties"/>
/// <see cref="PreferFileSystemAccess"/>
/// <see cref="SpringResourceLoader"/>
/// <see cref="FileResourceLoader"/>
public string ResourceLoaderPath {
set { resourceLoaderPath = value; }
}
/// <summary>
/// Set the Spring ResourceLoader to use for loading Velocity template files.
/// The default is DefaultResourceLoader. Will get overridden by the
/// ApplicationContext if running in a context.
///
/// </summary>
/// <see cref="ConfigurableResourceLoader"/>
/// <see cref="ContextRegistry"/>
///
public IResourceLoader ResourceLoader {
get { return resourceLoader; }
set { resourceLoader = value; }
}
/// <summary>
/// Set whether to prefer file system access for template loading.
/// File system access enables hot detection of template changes.
/// <p>If this is enabled, VelocityEngineFactory will try to resolve the
/// specified "resourceLoaderPath" as file system resource (which will work
/// for expanded class path resources and ServletContext resources too).
/// <p>Default is "true". Turn this off to always load via SpringResourceLoader
/// (i.e. as stream, without hot detection of template changes), which might
/// be necessary if some of your templates reside in an expanded classes
/// directory while others reside in jar files.
/// </summary>
/// <see cref="ResourceLoaderPath"/>
public bool PreferFileSystemAccess {
get { return preferFileSystemAccess; }
set { preferFileSystemAccess = value; }
}
/// <summary>
/// Set whether Velocity should log via Commons Logging, i.e. whether Velocity's
/// log system should be set to CommonsLoggingLogSystem. Default value is true
/// </summary>
/// <see cref="CommonsLoggingLogSystem"/>
public bool OverrideLogging {
get { return overrideLogging; }
set { overrideLogging = value; }
}
/// <summary>
/// Prepare the VelocityEngine instance and return it.
/// </summary>
/// <returns>VelocityEngine</returns>
/// <exception cref="VelocityException" />
/// <see cref="FillProperties" />
/// <see cref="InitVelocityResourceLoader" />
/// <see cref="PostProcessVelocityEngine" />
/// <see cref="VelocityEngine.Init()" />
public VelocityEngine CreateVelocityEngine() {
VelocityEngine velocityEngine = NewVelocityEngine();
ExtendedProperties props = new ExtendedProperties();
// Load config file if set.
if (configLocation != null) {
if (log.IsInfoEnabled) {
log.Info(string.Format("Loading Velocity config from [{0}]", configLocation));
}
FillProperties(props, configLocation);
}
// Merge local properties if set.
if (velocityProperties.Count > 0) {
foreach (KeyValuePair<string, object> pair in velocityProperties) {
props.Add(pair.Key, pair.Value);
}
}
// Set a resource loader path, if required.
if (null != resourceLoaderPath) {
InitVelocityResourceLoader(velocityEngine, resourceLoaderPath);
}
// Log via Commons Logging?
if (overrideLogging) {
velocityEngine.SetProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLoggingLogSystem());
}
PostProcessVelocityEngine(velocityEngine);
try {
// do not init with extended properties rather set one by one
foreach (DictionaryEntry prop in props) {
velocityEngine.SetProperty(Convert.ToString(prop.Key), prop.Value);
}
// Perform actual initialization.
velocityEngine.Init();
} catch (Exception ex) {
throw new VelocityException(ex.ToString(), ex);
}
return velocityEngine;
}
/// <summary>
/// Return a new VelocityEngine. Subclasses can override this for*
/// custom initialization, or for using a mock object for testing. * <p>Called by
/// <code>CreateVelocityEngine()</code>
/// </summary>
/// <returns>VelocityEngine</returns>
/// <see cref="CreateVelocityEngine"/>
protected static VelocityEngine NewVelocityEngine() {
return new VelocityEngine();
}
/// <summary>
/// Initialize a Velocity resource loader for the given VelocityEngine:*
/// either a standard Velocity FileResourceLoader or a SpringResourceLoader.
/// <p>Called by <code>CreateVelocityEngine()</code>.
/// </summary>
/// <param name="velocityEngine">velocityEngine the VelocityEngine to configure</param>
/// <param name="resourceLoaderFullPath">resourceLoaderPath the path to load Velocity resources from</param>
/// <see cref="FileResourceLoader"/>
/// <see cref="SpringResourceLoader"/>
/// <see cref="InitSpringResourceLoader"/>
/// <see cref="CreateVelocityEngine"/>
protected void InitVelocityResourceLoader(VelocityEngine velocityEngine, String resourceLoaderFullPath) {
if (PreferFileSystemAccess) {
// Try to load via the file system, fall back to SpringResourceLoader
// (for hot detection of template changes, if possible).
try {
StringBuilder resolvedPath = new StringBuilder();
String[] paths = resourceLoaderFullPath.Split(DELIMITER);
for (int i = 0; i < paths.Length; i++) {
string path = paths[i];
IResource resource = ResourceLoader.GetResource(path);
if (log.IsDebugEnabled) {
log.Debug(string.Format("Resource loader path [{0}] resolved to file [{1}]", path, resource.File.FullName));
}
resolvedPath.Append(resource.File.FullName);
if (i < paths.Length - 1) {
resolvedPath.Append(',');
}
}
velocityEngine.SetProperty(RuntimeConstants.RESOURCE_LOADER, "file");
velocityEngine.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
velocityEngine.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, resolvedPath.ToString());
} catch (IOException ex) {
if (log.IsDebugEnabled) {
log.Error(string.Format("Cannot resolve resource loader path [{0}] to [File]: using SpringResourceLoader", resourceLoaderFullPath), ex);
}
InitSpringResourceLoader(velocityEngine, resourceLoaderFullPath);
}
} else {
// Always load via SpringResourceLoader
// (without hot detection of template changes).
if (log.IsDebugEnabled) {
log.Debug("File system access not preferred: using SpringResourceLoader");
}
InitSpringResourceLoader(velocityEngine, resourceLoaderFullPath);
}
}
/// <summary>
/// Initialize a SpringResourceLoader for the given VelocityEngine.
/// <p>Called by <code>InitVelocityResourceLoader</code>.
/// </summary>
/// <param name="velocityEngine">velocityEngine the VelocityEngine to configure</param>
/// <param name="resourceLoaderPathString">resourceLoaderPath the path to load Velocity resources from</param>
/// <see cref="SpringResourceLoader"/>
/// <see cref="InitVelocityResourceLoader"/>
protected void InitSpringResourceLoader(VelocityEngine velocityEngine, string resourceLoaderPathString) {
velocityEngine.SetProperty(
RuntimeConstants.RESOURCE_LOADER, SpringResourceLoader.NAME);
velocityEngine.SetProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CLASS, typeof(SpringResourceLoader).Name);
velocityEngine.SetProperty(
SpringResourceLoader.SPRING_RESOURCE_LOADER_CACHE, "true");
velocityEngine.SetApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER, ResourceLoader);
velocityEngine.SetApplicationAttribute(
SpringResourceLoader.SPRING_RESOURCE_LOADER_PATH, resourceLoaderPathString);
}
/// <summary>
/// To be implemented by subclasses that want to to perform custom
/// post-processing of the VelocityEngine after this FactoryBean
/// performed its default configuration (but before VelocityEngine.init)
/// <p>Called by <code>CreateVelocityEngine()</code>
/// </summary>
/// <param name="velocityEngine">velocityEngine the current VelocityEngine</param>
/// <exception cref="IOException" />
/// <see cref="CreateVelocityEngine"/>
/// <see cref="VelocityEngine.Init()"/>
protected static void PostProcessVelocityEngine(VelocityEngine velocityEngine) {
}
/// <summary>
/// Populates the velocity properties from the given resource
/// </summary>
/// <param name="props">ExtendedProperties instance to populate</param>
/// <param name="resource">The resource from which to load the properties</param>
private static void FillProperties(ExtendedProperties props, IInputStreamSource resource) {
try {
props.Load(resource.InputStream);
} finally {
resource.InputStream.Close();
}
}
}
}

View File

@@ -0,0 +1,69 @@
#region License
/*
* Copyright 2002-2009 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 NVelocity.App;
using Spring.Context;
using Spring.Objects.Factory;
namespace Spring.Template.Velocity
{
/// <summary>
/// FactoryObject implementation that configures a VelocityEngine and provides it as an object
/// reference. This object is intended for any kind of usage of Velocity in
/// application code, e.g. for generating email content.
///
/// See the base class VelocityEngineFactory for configuration details.
/// </summary>
/// <see cref="VelocityEngineFactory"/>
/// <author>Erez Mazor (.NET) </author>
public class VelocityEngineFactoryObject : VelocityEngineFactory, IFactoryObject, IInitializingObject, IResourceLoaderAware {
private VelocityEngine velocityEngine;
/// <summary>
/// Get the velocity engine underlying object
/// </summary>
/// <returns>An instance of a configured VelocityEngine</returns>
/// <see cref="IFactoryObject"/>
public object GetObject() {
return velocityEngine;
}
/// <summary>
/// Get the type of the velocity engine
/// </summary>
public Type ObjectType {
get { return velocityEngine.GetType(); }
}
/// <summary>
/// Returns true
/// </summary>
public bool IsSingleton {
get { return true; }
}
/// <summary>
/// Facilitate the creation of the velocity engine object
/// </summary>
public void AfterPropertiesSet() {
velocityEngine = CreateVelocityEngine();
}
}
}

View File

@@ -0,0 +1,120 @@
#region License
/*
* Copyright 2002-2009 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 System.Collections;
using System.IO;
using Common.Logging;
using NVelocity;
using NVelocity.App;
using NVelocity.Exception;
namespace Spring.Template.Velocity{
/// <summary>
/// Generalized Utility class for merging velocity templates into a text writer or return the result as a string
/// </summary>
/// <author>Erez Mazor (.NET) </author>
public class VelocityEngineUtils {
protected static readonly ILog log = LogManager.GetLogger(typeof(VelocityEngineUtils));
/// <summary>
/// Merge the specified Velocity template with the given model and write
/// the result to the given Writer.
/// </summary>
/// <param name="velocityEngine">VelocityEngine to work with</param>
/// <param name="templateLocation">the location of template, relative to Velocity's resource loader path</param>
/// <param name="model">the Hashtable that contains model names as keys and model objects</param>
/// <param name="writer">writer the TextWriter to write the result to</param>
/// <exception cref="VelocityException">thrown if any exception is thrown by the velocity engine</exception>
[Obsolete("Use the overload that takes the encoding as parameter")]
public static void MergeTemplate(VelocityEngine velocityEngine, string templateLocation, Hashtable model, TextWriter writer) {
try {
VelocityContext velocityContext = new VelocityContext(model);
velocityEngine.MergeTemplate(templateLocation, velocityContext, writer);
} catch (VelocityException) {
throw;
} catch (Exception ex) {
throw new VelocityException(ex.ToString(), ex);
}
}
/// <summary>
/// Merge the specified Velocity template with the given model and write
/// the result to the given Writer.
/// </summary>
/// <param name="velocityEngine">VelocityEngine to work with</param>
/// <param name="templateLocation">the location of template, relative to Velocity's resource loader path</param>
/// <param name="encoding">encoding the encoding of the template file</param>
/// <param name="model">the Hashtable that contains model names as keys and model objects</param>
/// <param name="writer">writer the TextWriter to write the result to</param>
/// <exception cref="VelocityException">thrown if any exception is thrown by the velocity engine</exception>
public static void MergeTemplate(
VelocityEngine velocityEngine, string templateLocation, string encoding, Hashtable model, TextWriter writer) {
try {
VelocityContext velocityContext = new VelocityContext(model);
velocityEngine.MergeTemplate(templateLocation, encoding, velocityContext, writer);
} catch (VelocityException) {
throw;
} catch (Exception ex) {
throw new VelocityException(ex.ToString(), ex);
}
}
/// <summary>
/// Merge the specified Velocity template with the given model into a string.
/// <p>When using this method to prepare a text for a mail to be sent with Spring's
/// mail support, consider wrapping VelocityException in MailPreparationException.
/// </summary>
/// <param name="velocityEngine">VelocityEngine to work with</param>
/// <param name="templateLocation">the location of template, relative to Velocity's resource loader path</param>
/// <param name="model">the Hashtable that contains model names as keys and model objects</param>
/// <returns>the result as string</returns>
/// <exception cref="VelocityException">thrown if any exception is thrown by the velocity engine</exception>
[Obsolete("Use the overload that takes the encoding as parameter")]
public static string MergeTemplateIntostring(
VelocityEngine velocityEngine, string templateLocation, Hashtable model) {
TextWriter result = new StringWriter();
MergeTemplate(velocityEngine, templateLocation, model, result);
return result.ToString();
}
/// <summary>
/// Merge the specified Velocity template with the given model into a string.
/// <p>When using this method to prepare a text for a mail to be sent with Spring's
/// mail support, consider wrapping VelocityException in MailPreparationException.
/// </summary>
/// <param name="velocityEngine">VelocityEngine to work with</param>
/// <param name="templateLocation">the location of template, relative to Velocity's resource loader path</param>
/// <param name="model">the Hashtable that contains model names as keys and model objects</param>
/// <returns>the result as string</returns>
/// <exception cref="VelocityException">thrown if any exception is thrown by the velocity engine</exception>
public static string MergeTemplateIntostring(
VelocityEngine velocityEngine, string templateLocation, string encoding, Hashtable model) {
StringWriter result = new StringWriter();
MergeTemplate(velocityEngine, templateLocation, encoding, model, result);
return result.ToString();
}
}
}

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{10405837-CB67-40D8-9326-84C9383983E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring.Template.Velocity.Tests</RootNamespace>
<AssemblyName>Spring.Template.Velocity.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.4.1.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\Net\2.0\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="NVelocity, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\Net\2.0\NVelocity.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Template\Velocity\VelocityEngineFactoryObjectTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2008.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2008</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Template.Velocity\Spring.Template.Velocity.2008.csproj">
<Project>{BF3AB954-8375-407C-9E98-4C51D8072784}</Project>
<Name>Spring.Template.Velocity.2008</Name>
</ProjectReference>
<ProjectReference Include="..\Spring.Core.Tests\Spring.Core.Tests.2008.csproj">
<Project>{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}</Project>
<Name>Spring.Core.Tests.2008</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Template\Velocity\VelocityEngineFactoryObjectTests.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</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,58 @@
#region License
/*
* Copyright <20> 2002-2009 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
#region Imports
using NUnit.Framework;
using NVelocity.App;
using Spring.Context.Support;
using Spring.Objects.Factory.Xml;
#endregion
namespace Spring.Template.Velocity.Tests.Template.Velocity
{
/// <summary>
/// This class contains tests for VelocityEngineFactoryObject
/// </summary>
/// <author>Mark Pollack</author>
[TestFixture]
public class VelocityEngineFactoryObjectTests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test()
{
XmlApplicationContext appContext = new XmlApplicationContext(false,
ReadOnlyXmlTestResource.GetFilePath(
"VelocityEngineFactoryObjectTests.xml",
typeof (VelocityEngineFactoryObjectTests)));
VelocityEngine velocityEngine = appContext.GetObject("velocityEngine") as VelocityEngine;
Assert.IsNotNull(velocityEngine);
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:tx="http://www.springframework.net/tx">
<object id="velocityEngine" type="Spring.Content.Velocity.VelocityEngineFactoryObject, Spring.Content">
<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"/>
<entry key="resource.manager.class" value="NVelocity.Runtime.Resource.ResourceManagerImpl"/>
<entry key="directive.manager" value="NVelocity.Runtime.Directive.DirectiveManager"/>
<entry key="runtime.introspector.uberspect" value="NVelocity.Util.Introspection.UberspectImpl"/>
</dictionary>
</property>
</object>
</objects>