SPRNET-1028 - DefaultListableObjectFactory.IsAutowireCandidate(string , DependencyDescriptor) does not search parent container

This commit is contained in:
markpollack
2008-09-18 18:28:24 +00:00
parent 80ec33e328
commit 660cf9a31b
2 changed files with 32 additions and 1 deletions

View File

@@ -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

View File

@@ -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;