From 7ebe06f69b83c76f95ca46119e567ea0de4f2b91 Mon Sep 17 00:00:00 2001 From: markpollack Date: Wed, 13 Aug 2008 20:11:46 +0000 Subject: [PATCH] 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) --- Spring.build | 62 ++++++++++++++ Spring.include | 45 ++++++++++- .../Activation/ServiceHostFactory.cs | 8 ++ .../Activation/ServiceHostFactoryObject.cs | 9 +-- .../ServiceModel/SpringServiceHost.cs | 30 ++++++- .../Support/ServiceProxyTypeBuilder.cs | 11 ++- .../Support/SpringInstanceProvider.cs | 73 ++++++++++++++--- .../Support/SpringServiceBehavior.cs | 80 ++++++++++++++++--- .../Spring.Services.2005.csproj | 4 +- .../Spring.Services/Spring.Services.build | 7 +- .../Spring.Services.Tests.2005.csproj | 6 +- .../Spring.Services.Tests.build | 2 + 12 files changed, 296 insertions(+), 41 deletions(-) diff --git a/Spring.build b/Spring.build index bde0951b..99bf36db 100644 --- a/Spring.build +++ b/Spring.build @@ -252,6 +252,24 @@ + + + + + + + + + .NET 3.0 Build Skipped for Package + + + + + + + + + @@ -377,6 +395,19 @@ + + + + + + + + + + + + @@ -489,6 +520,25 @@ + + + + + + + + + + + + + + + + + + + @@ -689,6 +739,7 @@ + @@ -915,6 +966,7 @@ + @@ -924,6 +976,16 @@ + + + + + + + + + + diff --git a/Spring.include b/Spring.include index 47e7ddac..fe55a776 100644 --- a/Spring.include +++ b/Spring.include @@ -16,6 +16,32 @@ + + + + + + + + + + + + + + + + @@ -173,7 +199,7 @@ - + + + + + + + + + + + + + + diff --git a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactory.cs b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactory.cs index 49a92d2a..cfd63fba 100644 --- a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactory.cs +++ b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactory.cs @@ -72,6 +72,14 @@ namespace Spring.ServiceModel.Activation return base.CreateServiceHost(reference, baseAddresses); } + /// + /// Creates a SpringService for a specified type of service with a specific base address. + /// + /// Specifies the type of service to host. + /// The of type that contains the base addresses for the service hosted. + /// + /// A for the type of service specified with a specific base address. + /// protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { return new SpringServiceHost(serviceType, baseAddresses); diff --git a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs index c9c6dfea..9d969420 100644 --- a/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs +++ b/src/Spring/Spring.Services/ServiceModel/Activation/ServiceHostFactoryObject.cs @@ -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 { /// - /// Factory that provides instances of + /// Factory that provides instances of /// to host objects created with Spring's IoC container. /// /// Bruno Baia @@ -198,6 +194,9 @@ namespace Spring.ServiceModel.Activation #region IDisposable Members + /// + /// Close the SpringServiceHost + /// public void Dispose() { if (springServiceHost != null) diff --git a/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs b/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs index 31e1f72e..78d193f6 100644 --- a/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs +++ b/src/Spring/Spring.Services/ServiceModel/SpringServiceHost.cs @@ -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; + + + /// + /// Gets or sets the application context. + /// + /// The application context. + public IApplicationContext ApplicationContext + { + get { return applicationContext; } + set { applicationContext = value; } + } #region Constructor(s) / Destructor @@ -78,11 +88,23 @@ namespace Spring.ServiceModel ApplicationContext = applicationContext; } + /// + /// Initializes a new instance of the class. + /// + /// Calls the contructor with an IApplicationContext argument. + /// Type of the service. + /// The base addresses. public SpringServiceHost(Type serviceType, params Uri[] baseAddresses) : this(serviceType, GetApplicationContext(null), baseAddresses) { } + /// + /// Initializes a new instance of the class. + /// + /// Type of the service. + /// The application context. + /// The base addresses. public SpringServiceHost(Type serviceType, IApplicationContext applicationContext, params Uri[] baseAddresses) : base(serviceType, baseAddresses) { @@ -116,6 +138,10 @@ namespace Spring.ServiceModel #endregion + /// + /// Invoked during the transition of a communication object into the opening state. + /// Adds the SpringServiceBehavior. + /// protected override void OnOpening() { if (this.useSpringServiceBehavior && diff --git a/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs b/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs index e60a251a..5338d880 100644 --- a/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs +++ b/src/Spring/Spring.Services/ServiceModel/Support/ServiceProxyTypeBuilder.cs @@ -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 + /// + /// Creates a proxy that delegates calls to an instance of the + /// target object. This overriden implementation also sets the field __applicationContext. + /// + /// + /// If the + /// does not implement any interfaces. + /// public override Type BuildProxyType() { Type proxyType = base.BuildProxyType(); @@ -119,7 +126,7 @@ namespace Spring.ServiceModel.Support } /// - /// Creates an appropriate type builder. + /// Creates an appropriate type builder. Add a field to hold a reference to the application context. /// /// The name to use for the proxy type name. /// The type to extends if provided. diff --git a/src/Spring/Spring.Services/ServiceModel/Support/SpringInstanceProvider.cs b/src/Spring/Spring.Services/ServiceModel/Support/SpringInstanceProvider.cs index 85cdff90..34121be9 100644 --- a/src/Spring/Spring.Services/ServiceModel/Support/SpringInstanceProvider.cs +++ b/src/Spring/Spring.Services/ServiceModel/Support/SpringInstanceProvider.cs @@ -31,40 +31,87 @@ using System.Globalization; #endregion -namespace Spring.ServiceModel.Dispatcher +namespace Spring.ServiceModel.Support { + /// + /// 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 + /// + /// Bruno Baia public class SpringInstanceProvider : IInstanceProvider { - public IApplicationContext ApplicationContext { get; set; } - - public Type ServiceType { get; set; } + private IApplicationContext applicationContext; + private Type serviceType; + + + /// + /// Gets or sets the application context. + /// + /// The application context. + public IApplicationContext ApplicationContext + { + get { return applicationContext; } + set { applicationContext = value; } + + } + + + /// + /// Gets or sets the type of the service. + /// + /// The type of the service. + public Type ServiceType + { + get { return serviceType; } + set { serviceType = value; } + } + + /// + /// Initializes a new instance of the class. + /// + /// The application context. public SpringInstanceProvider(IApplicationContext applicationContext) { ApplicationContext = applicationContext; } - public SpringInstanceProvider(IApplicationContext applicationContext, Type type) + /// + /// Initializes a new instance of the class. + /// + /// The application context. + /// The type. + public SpringInstanceProvider(IApplicationContext applicationContext, Type serviceType) { ApplicationContext = applicationContext; - ServiceType = type; + ServiceType = serviceType; } #region IInstanceProvider Members + /// + /// Returns a service object given the specified object. + /// + /// The current object. + /// A user-defined service object. public object GetInstance(InstanceContext instanceContext) { return GetInstance(instanceContext, null); } + /// + /// Returns a service object given the specified object. + /// Delegates to the Spring container to instantiate the given object type. + /// + /// The current object. + /// The message that triggered the creation of a service object. + /// The service object. 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]); } + /// + /// Called when an object recycles a service object. + /// A no-op implementation + /// + /// The service's instance context. + /// The service object to be recycled. public void ReleaseInstance(InstanceContext instanceContext, object instance) { } diff --git a/src/Spring/Spring.Services/ServiceModel/Support/SpringServiceBehavior.cs b/src/Spring/Spring.Services/ServiceModel/Support/SpringServiceBehavior.cs index 3898d2f7..77b8202c 100644 --- a/src/Spring/Spring.Services/ServiceModel/Support/SpringServiceBehavior.cs +++ b/src/Spring/Spring.Services/ServiceModel/Support/SpringServiceBehavior.cs @@ -34,41 +34,95 @@ using Spring.Util; #endregion -namespace Spring.ServiceModel.Dispatcher +namespace Spring.ServiceModel.Support { + /// + /// An implementation of IServiceBehavior that applies the to all endpoints. + /// + /// Bruno Baia public class SpringServiceBehavior : IServiceBehavior { - public SpringInstanceProvider InstanceProvider { get; set; } + private SpringInstanceProvider springInstanceProvider; - public string ContextName { get; set; } + private string contextName; - public SpringServiceBehavior() + /// + /// Gets or sets the spring instance provider. + /// + /// The spring instance provider. + public SpringInstanceProvider InstanceProvider + { + get { return springInstanceProvider; } + } + + + /// + /// Gets the name of the spring context used when creating this behavior. + /// + /// The name of the context. + public string ContextName + { + get { return contextName; } + } + + /// + /// Initializes a new instance of the class and initializes the + /// SpringInstanceProvider + /// + public SpringServiceBehavior() : this((string)null) + { + springInstanceProvider = new SpringInstanceProvider(ContextRegistry.GetContext()); + } + + /// + /// Initializes a new instance of the class with a given Spring + /// context name. + /// + /// Name of the context. + 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); } + /// + /// Initializes a new instance of the class. + /// + /// The application context. public SpringServiceBehavior(IApplicationContext applicationContext) { - InstanceProvider = new SpringInstanceProvider(applicationContext); + springInstanceProvider = new SpringInstanceProvider(applicationContext); } #region IServiceBehavior Members + /// + /// Provides the ability to pass custom data to binding elements to support the contract implementation. + /// No-op implementation + /// + /// The service description of the service. + /// The host of the service. + /// The service endpoints. + /// Custom objects to which binding elements have access. public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection endpoints, BindingParameterCollection bindingParameters) { } + /// + /// Add the SpringInstanceProvider to all endpoint dispatcher. + /// + /// The service description. + /// The host that is currently being built. public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) @@ -85,6 +139,14 @@ namespace Spring.ServiceModel.Dispatcher } } + /// + /// Provides the ability to inspect the service host and the service description to confirm that the service can run successfully. + /// + /// + /// No-op implementation + /// + /// The service description. + /// The service host that is currently being constructed. public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { } diff --git a/src/Spring/Spring.Services/Spring.Services.2005.csproj b/src/Spring/Spring.Services/Spring.Services.2005.csproj index c09333e0..2da8c262 100644 --- a/src/Spring/Spring.Services/Spring.Services.2005.csproj +++ b/src/Spring/Spring.Services/Spring.Services.2005.csproj @@ -30,7 +30,7 @@ false - TRACE;DEBUG;NET_2_0 + TRACE;DEBUG;NET_2_0;NET_3_0 Spring.Services.xml true 4096 @@ -40,7 +40,7 @@ false false false - false + true 4 full prompt diff --git a/src/Spring/Spring.Services/Spring.Services.build b/src/Spring/Spring.Services/Spring.Services.build index 64298e38..49b11328 100644 --- a/src/Spring/Spring.Services/Spring.Services.build +++ b/src/Spring/Spring.Services/Spring.Services.build @@ -8,9 +8,6 @@ --> - - - - - - + --> diff --git a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2005.csproj b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2005.csproj index 5d1678f5..8d240805 100644 --- a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2005.csproj +++ b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.2005.csproj @@ -30,7 +30,7 @@ false - TRACE;DEBUG;NET_2_0 + TRACE;DEBUG;NET_2_0;NET_3_0 true @@ -120,6 +120,7 @@ Code + @@ -177,9 +178,6 @@ - - - diff --git a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.build b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.build index 29371eed..b40e3928 100644 --- a/test/Spring/Spring.Services.Tests/Spring.Services.Tests.build +++ b/test/Spring/Spring.Services.Tests/Spring.Services.Tests.build @@ -7,6 +7,7 @@ * current.build.defines.csc - framework-specific build defines for C# compiler --> + + -->