SPRNET-1028 - DefaultListableObjectFactory.IsAutowireCandidate(string , DependencyDescriptor) does not search parent container
This commit is contained in:
@@ -1097,7 +1097,8 @@ namespace Spring.Objects.Factory.Support
|
||||
if (ContainsSingleton(objectName))
|
||||
{
|
||||
return true;
|
||||
} else if (ParentObjectFactory is IConfigurableFactoryObject)
|
||||
}
|
||||
else if (ParentObjectFactory is IConfigurableListableObjectFactory)
|
||||
{
|
||||
// No object definition found in this factory -> delegate to parent
|
||||
return
|
||||
|
||||
@@ -1440,8 +1440,38 @@ namespace Spring.Objects.Factory
|
||||
Assert.AreSame(testObject, resultObject);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HierarchicalObjectFactoryChildParentResolution()
|
||||
{
|
||||
DefaultListableObjectFactory parent = new DefaultListableObjectFactory();
|
||||
DefaultListableObjectFactory child = new DefaultListableObjectFactory(parent);
|
||||
parent.RegisterSingleton("parent", new Parent());
|
||||
child.RegisterObjectDefinition("child", new RootObjectDefinition(typeof (Child), AutoWiringMode.AutoDetect));
|
||||
Child c = (Child) child.GetObject("child");
|
||||
Assert.IsNotNull(c);
|
||||
}
|
||||
|
||||
#region Helper Classes
|
||||
|
||||
public interface IParent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Parent : IParent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public interface IChild
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Child : IChild
|
||||
{
|
||||
public Child(Parent parent) { }
|
||||
}
|
||||
public class GoodDisposable : IDisposable
|
||||
{
|
||||
public static int DisposeCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user