From ce0dd7602424dbbf307661ca5bf588e68622e456 Mon Sep 17 00:00:00 2001 From: bbaia Date: Mon, 14 Dec 2009 23:55:49 +0000 Subject: [PATCH] IConfigurableFactoryObject should not use ConfigureObject method to configure the product's factory [SPRNET-1296] --- .../AbstractAutowireCapableObjectFactory.cs | 20 +++++++++++ .../Factory/Support/AbstractObjectFactory.cs | 34 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs index 46a4bcca..5b802c5d 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs @@ -268,6 +268,26 @@ namespace Spring.Objects.Factory.Support ApplyPropertyValues(name, definition, new ObjectWrapper(instance), definition.PropertyValues); } } + + /// + /// Apply the property values of the object definition with the supplied + /// to the supplied . + /// + /// + /// The existing object that the property values for the named object will + /// be applied to. + /// + /// + /// The name of the object definition associated with the property values that are + /// to be applied. + /// + /// + /// An object definition that should be used to apply property values. + /// + public override void ApplyObjectPropertyValues(object instance, string name, IObjectDefinition definition) + { + ApplyPropertyValues(name, new RootObjectDefinition(definition), new ObjectWrapper(instance), definition.PropertyValues); + } /// /// Apply any diff --git a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs index 3b857003..3e43d9ee 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs @@ -341,6 +341,36 @@ namespace Spring.Objects.Factory.Support // explicit no-op... } + /// + /// Apply the property values of the object definition with the supplied + /// to the supplied . + /// + /// + ///

+ /// The object definition can either define a fully self-contained object, + /// reusing it's property values, or just property values meant to be used + /// for existing object instances. + ///

+ ///
+ /// + /// The existing object that the property values for the named object will + /// be applied to. + /// + /// + /// The name of the object definition associated with the property values that are + /// to be applied. + /// + /// + /// An object definition that should be used to apply property values. + /// + /// + /// In case of errors. + /// + public virtual void ApplyObjectPropertyValues(object instance, string name, IObjectDefinition definition) + { + // explicit no-op... + } + // /// // /// Create an object instance for the given object definition. // /// @@ -954,9 +984,7 @@ namespace Spring.Objects.Factory.Support if (configurableFactory.ProductTemplate != null) { - instance = ConfigureObject(instance, - String.Format("{0}.ProductTemplate", objectName), - configurableFactory.ProductTemplate); + ApplyObjectPropertyValues(instance, objectName, configurableFactory.ProductTemplate); } }