Add .NET 3.0 framework to the build.

Spring.Services.ServiceModel compiles under .NET 3.0 (i.e. no .NET 3.5 language features used anymore)
This commit is contained in:
markpollack
2008-08-13 20:11:46 +00:00
parent 4e5a785273
commit 7ebe06f69b
12 changed files with 296 additions and 41 deletions

View File

@@ -252,6 +252,24 @@
</if>
</target>
<target name="compile-build-3.0" description="Builds for .NET 3.0 if available">
<if test="${net-3.0.installed}">
<call target="compile-net-3.0"/>
</if>
<if test="${not net-3.0.installed}">
<if test="${property::exists('project.build.package') and project.build.package}">
.NET 3.0 Build Skipped for Package
<fail message="The .NET Framework 3.0 is not available."/>
<echo message="The .NET Framework 3.0 is not available. Build skipped during package."/>
</if>
<if test="${not(property::exists('project.build.package') and project.build.package)}">
<echo message="The .NET Framework 3.0 is not available. Build skipped."/>
</if>
</if>
</target>
<!-- Targets for other .NET frameworks -->
@@ -377,6 +395,19 @@
<call target="compile-test" />
</target>
<target name="compile-net-3.0" description="Builds .NET Framework 3.0 version"
depends="set-net-3.0-runtime-configuration, check-spring-basedir, clean-current-bin-dir, TestInit">
<call target="copykeys" if="${project.build.sign}"/>
<call target="common.generate-assemblyinfo"/>
<property name="build-nms" value="false" />
<property name="build-ems" value="false" />
<property name="build-ems-tests" value="false" />
<property name="build-quartz" value="false" />
<property name="build-msmq" value="false" />
<property name="build-msmq-tests" value="false" />
<call target="compile-test" />
</target>
<target name="compile-mono-2.0" description="Builds MONO Framework 2.0 version"
depends="set-mono-2.0-runtime-configuration, check-spring-basedir, clean-current-bin-dir, TestInit">
<call target="copykeys" if="${project.build.sign}"/>
@@ -489,6 +520,25 @@
</if>
</target>
<target name="build-3.0">
<call target="set-build-namespaces-release"/>
<echo message="------------------------"/>
<echo message="Building .NET 3.0 DEBUG "/>
<echo message="------------------------"/>
<call target="set-debug-build-configuration"/>
<call target="compile-build-3.0"/>
<if test="${property::exists('project.build.package') and project.build.package}">
<echo message="--------------------------"/>
<echo message="Building .NET 3.0 RELEASE "/>
<echo message="--------------------------"/>
<call target="set-release-build-configuration"/>
<call target="compile-build-3.0"/>
</if>
</target>
<target name="build-mono-2.0">
<if test="${property::exists('project.build.package') and project.build.package}">
@@ -689,6 +739,7 @@
<call target="${nant.target.root.name}-1.0" />
<call target="${nant.target.root.name}-1.1" />
<call target="${nant.target.root.name}-2.0" />
<call target="${nant.target.root.name}-3.0" />
<!-- ignore Mono 2.0 for now -->
<!-- <call target="${nant.target.root.name}-mono-2.0" /> -->
@@ -915,6 +966,7 @@
<include name="**/Common.Logging.dll"/>
<include name="**/Common.Logging.*.dll"/>
<exclude name="**/3.0/**"/>
<exclude name="**/release/Spring/**"/>
<exclude name="**/debug/Spring/**"/>
<exclude name="**/examples/**"/>
@@ -924,6 +976,16 @@
</copy>
</if>
<if test="${net-3.0.installed}">
<copy todir="${current.package.dir}/bin/net">
<fileset basedir="./build/net">
<include name="**/Spring.Services.dll"/>
<include name="**/Spring.Services.xml"/>
<include name="**/Spring.Services.pdb"/>
</fileset>
</copy>
</if>
<if test="${property::exists('build.allnamespaces') and build.allnamespaces}">
<copy todir="${current.package.dir}/bin/net">
<fileset basedir="./build/net">

View File

@@ -16,6 +16,32 @@
<property name="spring.output.dir"
value="${spring.basedir}/bin/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}"
dynamic="true"/>
<property name="registry.net-3.0.installed" value="0" overwrite="false"/>
<readregistry property="registry.net-3.0.installed"
key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Install"
hive="LocalMachine"
failonerror="false" />
<readregistry property="registry.dotnet.v3.0.Installed"
key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess"
hive="LocalMachine"
unless="${property::exists('registry.net-3.0.installed')}"
failonerror="false" />
<property name="net-3.0.installed" value="${registry.net-3.0.installed == '1'}" />
<if test="${net-3.0.installed}">
<readregistry property="net-3.0.ReferenceInstallPath"
key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Communication Foundation\ReferenceInstallPath"
hive="LocalMachine"
if="${net-3.0.installed}" />
</if>
<target name="check-bin-dir">
<if test="${not property::exists('bin.dir')}">
<property name="bin.dir" value="${project::get-base-directory()}/build"/>
@@ -173,7 +199,7 @@
</imports>
<code>
<!-- format for assembly revision is RRXXX where RR = framework number (1.0=10; 1.1=11; 2.0=20 etc) and
<!-- format for assembly revision is RRXXX where RR = framework number (1.0=10; 1.1=11; 2.0=20, 3.0=30, 3.5=35, etc.) and
XXX is the number of days from the year the project 'started', property project.year. -->
<![CDATA[
public static void ScriptMain(Project project) {
@@ -354,6 +380,23 @@
<property name="current.sdkdoc.debug" value="${sdkdoc.debug}" dynamic="true"/>
<property name="nowarn.numbers.test" value="${nowarn.numbers.test.default},1701"/>
</target>
<target name="set-net-3.0-runtime-configuration"
depends="check-bin-dir, check-sdkdoc-dir, check-sdkdoc-debug, check-current-build-config, check-build-debug, check-build-defines">
<property name="nant.settings.currentframework" value="net-2.0"/>
<property name="nant.settings.currentframework.number" value="2.0"/>
<property name="nant.settings.currentframework.revisionnumber" value="3"/>
<property name="net-2.0" value="true"/>
<property name="net-3.0" value="true"/>
<property name="current.build.debug" value="${build.debug}" dynamic="true"/>
<property name="current.build.defines.csc" value="${build.defines.csc},NET,NET_2_0,NET_3_0" dynamic="true"/>
<property name="current.build.defines.cl" value="${build.defines.cl} /D NET /D NET_2_0 /D NET_3_0" dynamic="true"/>
<property name="current.bin.dir"
value="${bin.dir}/${framework::get-family(framework::get-target-framework())}/3.0/${current.build.config}"/>
<property name="current.sdkdoc.dir"
value="${sdkdoc.dir}/${framework::get-family(framework::get-target-framework())}/3.0"/>
<property name="current.sdkdoc.debug" value="${sdkdoc.debug}" dynamic="true"/>
<property name="nowarn.numbers.test" value="${nowarn.numbers.test.default},1701"/>
</target>
<target name="set-netcf-1.0-runtime-configuration"
depends="check-bin-dir, check-sdkdoc-dir, check-sdkdoc-debug, check-current-build-config, check-build-debug, check-build-defines">
<property name="nant.settings.currentframework" value="netcf-1.0"/>

View File

@@ -72,6 +72,14 @@ namespace Spring.ServiceModel.Activation
return base.CreateServiceHost(reference, baseAddresses);
}
/// <summary>
/// Creates a SpringService for a specified type of service with a specific base address.
/// </summary>
/// <param name="serviceType">Specifies the type of service to host.</param>
/// <param name="baseAddresses">The <see cref="T:System.Array"/> of type <see cref="T:System.Uri"/> that contains the base addresses for the service hosted.</param>
/// <returns>
/// A <see cref="T:System.ServiceModel.ServiceHost"/> for the type of service specified with a specific base address.
/// </returns>
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
return new SpringServiceHost(serviceType, baseAddresses);

View File

@@ -23,19 +23,15 @@
using System;
using System.ServiceModel;
using System.ServiceModel.Activation;
using Spring.Util;
using Spring.Context;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
#endregion
namespace Spring.ServiceModel.Activation
{
/// <summary>
/// Factory that provides instances of <see cref="Spring.ServiceModel.ServiceHost" />
/// Factory that provides instances of <see cref="ServiceHost" />
/// to host objects created with Spring's IoC container.
/// </summary>
/// <author>Bruno Baia</author>
@@ -198,6 +194,9 @@ namespace Spring.ServiceModel.Activation
#region IDisposable Members
/// <summary>
/// Close the SpringServiceHost
/// </summary>
public void Dispose()
{
if (springServiceHost != null)

View File

@@ -27,7 +27,6 @@ using Spring.Util;
using Spring.Context;
using Spring.Context.Support;
using Spring.ServiceModel.Support;
using Spring.ServiceModel.Dispatcher;
#endregion
@@ -41,7 +40,18 @@ namespace Spring.ServiceModel
{
private bool useSpringServiceBehavior = false;
public IApplicationContext ApplicationContext { get; set; }
private IApplicationContext applicationContext;
/// <summary>
/// Gets or sets the application context.
/// </summary>
/// <value>The application context.</value>
public IApplicationContext ApplicationContext
{
get { return applicationContext; }
set { applicationContext = value; }
}
#region Constructor(s) / Destructor
@@ -78,11 +88,23 @@ namespace Spring.ServiceModel
ApplicationContext = applicationContext;
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringServiceHost"/> class.
/// </summary>
/// <remarks>Calls the contructor with an IApplicationContext argument.</remarks>
/// <param name="serviceType">Type of the service.</param>
/// <param name="baseAddresses">The base addresses.</param>
public SpringServiceHost(Type serviceType, params Uri[] baseAddresses)
: this(serviceType, GetApplicationContext(null), baseAddresses)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringServiceHost"/> class.
/// </summary>
/// <param name="serviceType">Type of the service.</param>
/// <param name="applicationContext">The application context.</param>
/// <param name="baseAddresses">The base addresses.</param>
public SpringServiceHost(Type serviceType, IApplicationContext applicationContext, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
@@ -116,6 +138,10 @@ namespace Spring.ServiceModel
#endregion
/// <summary>
/// Invoked during the transition of a communication object into the opening state.
/// Adds the SpringServiceBehavior.
/// </summary>
protected override void OnOpening()
{
if (this.useSpringServiceBehavior &&

View File

@@ -27,7 +27,6 @@ using System.Reflection.Emit;
using Spring.Proxy;
using Spring.Context;
using Spring.Context.Support;
using Spring.Objects.Factory;
#endregion
@@ -77,6 +76,14 @@ namespace Spring.ServiceModel.Support
#region Protected Methods
/// <summary>
/// Creates a proxy that delegates calls to an instance of the
/// target object. This overriden implementation also sets the field __applicationContext.
/// </summary>
/// <exception cref="System.ArgumentException">
/// If the <see cref="IProxyTypeBuilder.TargetType"/>
/// does not implement any interfaces.
/// </exception>
public override Type BuildProxyType()
{
Type proxyType = base.BuildProxyType();
@@ -119,7 +126,7 @@ namespace Spring.ServiceModel.Support
}
/// <summary>
/// Creates an appropriate type builder.
/// Creates an appropriate type builder. Add a field to hold a reference to the application context.
/// </summary>
/// <param name="name">The name to use for the proxy type name.</param>
/// <param name="baseType">The type to extends if provided.</param>

View File

@@ -31,40 +31,87 @@ using System.Globalization;
#endregion
namespace Spring.ServiceModel.Dispatcher
namespace Spring.ServiceModel.Support
{
/// <summary>
/// An IInstanceProvider implementation that delegates to the Spring container to instantiate a given
/// service type. This allows for the service intstance to be configured via dependency injection and
/// have AOP advice applied
/// </summary>
/// <author>Bruno Baia</author>
public class SpringInstanceProvider : IInstanceProvider
{
public IApplicationContext ApplicationContext { get; set; }
public Type ServiceType { get; set; }
private IApplicationContext applicationContext;
private Type serviceType;
/// <summary>
/// Gets or sets the application context.
/// </summary>
/// <value>The application context.</value>
public IApplicationContext ApplicationContext
{
get { return applicationContext; }
set { applicationContext = value; }
}
/// <summary>
/// Gets or sets the type of the service.
/// </summary>
/// <value>The type of the service.</value>
public Type ServiceType
{
get { return serviceType; }
set { serviceType = value; }
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringInstanceProvider"/> class.
/// </summary>
/// <param name="applicationContext">The application context.</param>
public SpringInstanceProvider(IApplicationContext applicationContext)
{
ApplicationContext = applicationContext;
}
public SpringInstanceProvider(IApplicationContext applicationContext, Type type)
/// <summary>
/// Initializes a new instance of the <see cref="SpringInstanceProvider"/> class.
/// </summary>
/// <param name="applicationContext">The application context.</param>
/// <param name="serviceType">The type.</param>
public SpringInstanceProvider(IApplicationContext applicationContext, Type serviceType)
{
ApplicationContext = applicationContext;
ServiceType = type;
ServiceType = serviceType;
}
#region IInstanceProvider Members
/// <summary>
/// Returns a service object given the specified <see cref="T:System.ServiceModel.InstanceContext"/> object.
/// </summary>
/// <param name="instanceContext">The current <see cref="T:System.ServiceModel.InstanceContext"/> object.</param>
/// <returns>A user-defined service object.</returns>
public object GetInstance(InstanceContext instanceContext)
{
return GetInstance(instanceContext, null);
}
/// <summary>
/// Returns a service object given the specified <see cref="T:System.ServiceModel.InstanceContext"/> object.
/// Delegates to the Spring container to instantiate the given object type.
/// </summary>
/// <param name="instanceContext">The current <see cref="T:System.ServiceModel.InstanceContext"/> object.</param>
/// <param name="message">The message that triggered the creation of a service object.</param>
/// <returns>The service object.</returns>
public object GetInstance(InstanceContext instanceContext, Message message)
{
object result = null;
{
string[] objectNames = ApplicationContext.GetObjectNamesForType(ServiceType);
if (objectNames.Length != 1)
{
// TODO : Exception type and message ?
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
@@ -75,6 +122,12 @@ namespace Spring.ServiceModel.Dispatcher
return ApplicationContext.GetObject(objectNames[0]);
}
/// <summary>
/// Called when an <see cref="T:System.ServiceModel.InstanceContext"/> object recycles a service object.
/// A no-op implementation
/// </summary>
/// <param name="instanceContext">The service's instance context.</param>
/// <param name="instance">The service object to be recycled.</param>
public void ReleaseInstance(InstanceContext instanceContext, object instance)
{
}

View File

@@ -34,41 +34,95 @@ using Spring.Util;
#endregion
namespace Spring.ServiceModel.Dispatcher
namespace Spring.ServiceModel.Support
{
/// <summary>
/// An implementation of IServiceBehavior that applies the <see cref="SpringInstanceProvider"/> to all endpoints.
/// </summary>
/// <author>Bruno Baia</author>
public class SpringServiceBehavior : IServiceBehavior
{
public SpringInstanceProvider InstanceProvider { get; set; }
private SpringInstanceProvider springInstanceProvider;
public string ContextName { get; set; }
private string contextName;
public SpringServiceBehavior()
/// <summary>
/// Gets or sets the spring instance provider.
/// </summary>
/// <value>The spring instance provider.</value>
public SpringInstanceProvider InstanceProvider
{
get { return springInstanceProvider; }
}
/// <summary>
/// Gets the name of the spring context used when creating this behavior.
/// </summary>
/// <value>The name of the context.</value>
public string ContextName
{
get { return contextName; }
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringServiceBehavior"/> class and initializes the
/// SpringInstanceProvider
/// </summary>
public SpringServiceBehavior() : this((string)null)
{
springInstanceProvider = new SpringInstanceProvider(ContextRegistry.GetContext());
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringServiceBehavior"/> class with a given Spring
/// context name.
/// </summary>
/// <param name="contextName">Name of the context.</param>
public SpringServiceBehavior(string contextName)
{
IApplicationContext applicationContext;
if (StringUtils.IsNullOrEmpty(ContextName))
if (StringUtils.IsNullOrEmpty(contextName))
{
applicationContext = ContextRegistry.GetContext();
}
else
{
applicationContext = ContextRegistry.GetContext(ContextName);
applicationContext = ContextRegistry.GetContext(contextName);
}
InstanceProvider = new SpringInstanceProvider(applicationContext);
this.contextName = contextName;
springInstanceProvider = new SpringInstanceProvider(applicationContext);
}
/// <summary>
/// Initializes a new instance of the <see cref="SpringServiceBehavior"/> class.
/// </summary>
/// <param name="applicationContext">The application context.</param>
public SpringServiceBehavior(IApplicationContext applicationContext)
{
InstanceProvider = new SpringInstanceProvider(applicationContext);
springInstanceProvider = new SpringInstanceProvider(applicationContext);
}
#region IServiceBehavior Members
/// <summary>
/// Provides the ability to pass custom data to binding elements to support the contract implementation.
/// No-op implementation
/// </summary>
/// <param name="serviceDescription">The service description of the service.</param>
/// <param name="serviceHostBase">The host of the service.</param>
/// <param name="endpoints">The service endpoints.</param>
/// <param name="bindingParameters">Custom objects to which binding elements have access.</param>
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
}
/// <summary>
/// Add the SpringInstanceProvider to all endpoint dispatcher.
/// </summary>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The host that is currently being built.</param>
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
@@ -85,6 +139,14 @@ namespace Spring.ServiceModel.Dispatcher
}
}
/// <summary>
/// Provides the ability to inspect the service host and the service description to confirm that the service can run successfully.
/// </summary>
/// <remarks>
/// No-op implementation
/// </remarks>
/// <param name="serviceDescription">The service description.</param>
/// <param name="serviceHostBase">The service host that is currently being constructed.</param>
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
}

View File

@@ -30,7 +30,7 @@
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<DefineConstants>TRACE;DEBUG;NET_2_0;NET_3_0</DefineConstants>
<DocumentationFile>Spring.Services.xml</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
@@ -40,7 +40,7 @@
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>

View File

@@ -8,9 +8,6 @@
-->
<target name="build">
<!-- TO REMOVE : for .NET 3.0 build -->
<!--<property if="${net-2.0}" name="current.build.defines.csc" value="${current.build.defines.csc},NET_3_0" />-->
<!-- build Spring.Services -->
<csc target="library" define="${current.build.defines.csc}"
warnaserror="true"
@@ -41,9 +38,7 @@
<include name="Spring.Aop.dll" />
<include name="Spring.Web.dll" />
<include name="System.Web.Services.dll" />
<!-- TO REMOVE : for .NET 3.0 build -->
<!--<include if="${net-2.0}" name="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll" />-->
<include if="${net-3.0.installed}" name="${net-3.0.ReferenceInstallPath}\System.ServiceModel.dll" />-->
</references>
</csc>

View File

@@ -30,7 +30,7 @@
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<DefineConstants>TRACE;DEBUG;NET_2_0;NET_3_0</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
@@ -120,6 +120,7 @@
<Compile Include="Remoting\SimpleCounter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ServiceModel\ServiceExporterTests.cs" />
<Compile Include="Web\Services\WebServiceProxyFactoryTests.cs" />
<EmbeddedResource Include="Data\Spring\Web\Services\rpc-literal.wsdl" />
<EmbeddedResource Include="Data\Spring\Web\Services\document-literal.wsdl" />
@@ -177,9 +178,6 @@
<ItemGroup>
<EmbeddedResource Include="Data\Spring\Remoting\saoSingleton-aop.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="ServiceModel\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>

View File

@@ -7,6 +7,7 @@
* current.build.defines.csc - framework-specific build defines for C# compiler
-->
<target name="build">
<echo message="current.bin.dir = ${current.bin.dir}"/>
<!-- build Spring.Services.Tests -->
<csc target="library" define="${current.build.defines.csc}"
warnaserror="true"
@@ -27,6 +28,7 @@
</resources>
<references basedir="${current.bin.dir}">
<include name="*.dll" />
<include if="${net-3.0.installed}" name="${net-3.0.ReferenceInstallPath}\System.ServiceModel.dll" />-->
<exclude name="${project::get-name()}.dll" />
<exclude name="CloverRuntime.dll" />
</references>