Skip to content

Commit 6610f5e

Browse files
committed
sprnet-504
sprnet-1005
1 parent a98965e commit 6610f5e

12 files changed

+264
-130
lines changed

src/Spring/Spring.Core/Context/Support/AbstractApplicationContext.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ private void RefreshObjectPostProcessorChecker(IConfigurableListableObjectFactor
547547
/// </summary>
548548
private void InitEventRegistry()
549549
{
550-
if (ContainsObject(EventRegistryObjectName))
550+
if (ContainsLocalObject(EventRegistryObjectName))
551551
{
552552
object candidateRegistry = GetObject(EventRegistryObjectName);
553553
if (candidateRegistry is IEventRegistry)
@@ -631,7 +631,7 @@ AbstractApplicationContext parent
631631
/// </remarks>
632632
private void InitMessageSource()
633633
{
634-
if (ContainsObject(MessageSourceObjectName))
634+
if (ContainsLocalObject(MessageSourceObjectName))
635635
{
636636
object candidateSource = GetObject(MessageSourceObjectName);
637637
if (candidateSource is IMessageSource)
@@ -685,6 +685,7 @@ IMessageSource parentMessageSource
685685
{
686686
_messageSource = new DelegatingMessageSource(
687687
GetInternalParentMessageSource());
688+
ObjectFactory.RegisterSingleton(MessageSourceObjectName, _messageSource);
688689

689690
#region Instrumentation
690691

@@ -700,6 +701,7 @@ IMessageSource parentMessageSource
700701
else
701702
{
702703
_messageSource = new StaticMessageSource();
704+
ObjectFactory.RegisterSingleton(MessageSourceObjectName, _messageSource);
703705

704706
#region Instrumentation
705707

src/Spring/Spring.Core/Objects/Factory/Config/ObjectReferenceFactoryObject.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,24 @@ public sealed class ObjectReferenceFactoryObject
5050
private string _targetObjectName;
5151
private IObjectFactory _objectFactory;
5252

53-
/// <summary>
53+
/// <summary>
54+
/// Initialize a new default instance
55+
/// </summary>
56+
public ObjectReferenceFactoryObject()
57+
{
58+
}
59+
/// <summary>
60+
/// Initialize this instance with the predefined <paramref name="targetObjectName"/> and <paramref name="objectFactory"/>.
61+
/// </summary>
62+
/// <param name="targetObjectName"></param>
63+
/// <param name="objectFactory"></param>
64+
public ObjectReferenceFactoryObject(string targetObjectName, IObjectFactory objectFactory)
65+
{
66+
this.TargetObjectName = targetObjectName;
67+
this.ObjectFactory = objectFactory;
68+
}
69+
70+
/// <summary>
5471
/// The name of the target object.
5572
/// </summary>
5673
/// <remarks>

src/Spring/Spring.Core/Objects/Factory/IListableObjectFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ public interface IListableObjectFactory : IObjectFactory
132132
/// <see cref="Spring.Objects.Factory.IFactoryObject"/>s will be instantiated).
133133
/// </p>
134134
/// <p>
135-
/// Does not consider any hierarchy this factory may participate in.
135+
/// Does not consider any hierarchy this factory may participate in.
136+
/// Use <see cref="ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(Spring.Objects.Factory.IListableObjectFactory,System.Type,bool,bool)"/>
137+
/// to include beans in ancestor factories too.
138+
/// &lt;p&gt;Note: Does &lt;i&gt;not&lt;/i&gt; ignore singleton objects that have been registered
139+
/// by other means than bean definitions.
136140
/// </p>
137141
/// </remarks>
138142
/// <param name="type">

src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ protected void ApplyPropertyValues(string name, RootObjectDefinition definition,
339339
{
340340
return;
341341
}
342-
ObjectDefinitionValueResolver valueResolver = new ObjectDefinitionValueResolver(this, name, definition);
342+
ObjectDefinitionValueResolver valueResolver = CreateValueResolver(name, definition);
343343

344344
MutablePropertyValues deepCopy = new MutablePropertyValues(properties);
345345
PropertyValue[] copiedProperties = deepCopy.PropertyValues;
@@ -365,6 +365,14 @@ protected void ApplyPropertyValues(string name, RootObjectDefinition definition,
365365
}
366366
}
367367

368+
/// <summary>
369+
/// Create the value resolver strategy to use for resolving raw property values
370+
/// </summary>
371+
protected virtual ObjectDefinitionValueResolver CreateValueResolver(string name, IObjectDefinition definition)
372+
{
373+
return new ObjectDefinitionValueResolver(this, name, definition);
374+
}
375+
368376
/// <summary>
369377
/// Return an array of object-type property names that are unsatisfied.
370378
/// </summary>

0 commit comments

Comments
 (0)