MentaContainer

Compare Revisions

Ignore whitespace Rev 114 → Rev 115

/trunk/src/test/java/org/mentacontainer/impl/MentaContainerTest.java
307,6 → 307,45
Assert.assertNotNull(myDAO.getSomething());
}
public static class MyObject1 {
}
public static class MyObject2 {
}
public static class MyObject3 {
public MyObject3(MyObject2 o2, MyObject1 o1) {
 
}
}
private Container getConfiguredContainer2() {
Container c = new MentaContainer();
c.ioc("myObj1", MyObject1.class);
c.ioc("myObj2", MyObject2.class);
c.ioc("myObj3", MyObject3.class);
c.autowire("myObj1");
c.autowire("myObj2");
return c;
}
@Test
public void testAutoWiringWithTwoConstructors() {
Container c = getConfiguredContainer2();
MyObject3 obj3 = c.get("myObj3");
Assert.assertNotNull(obj3);
}
public static class SomeAction {
private MyDAO myDAO = null;
/trunk/src/main/java/org/mentacontainer/impl/ClassFactory.java
444,6 → 444,8
Iterator<ConstructorDependency> iter = dependencies.iterator();
boolean foundMatch = false;
while(iter.hasNext()) {
ConstructorDependency d = iter.next();
456,9 → 458,16
newInitValues.add(new DependencyKey(d.getSource()));
continue;
foundMatch = true;
break;
}
}
if (foundMatch) {
continue; // next constructor param...
}
}
break; // no param... next constructor...