MentaContainer

Compare Revisions

Ignore whitespace Rev 43 → Rev 44

/trunk/src/test/java/org/mentacontainer/impl/MentaContainerTest.java
69,26 → 69,6
Assert.assertTrue(s1.equals(s2));
}
 
@Test(expected = RuntimeException.class)
public void testAddingComponentTwice() {
 
Container c = new MentaContainer();
 
c.ioc("myStr", String.class);
c.ioc("myStr", String.class);
}
 
@Test(expected = RuntimeException.class)
public void testSettingWiringTwice() {
 
Container c = new MentaContainer();
 
c.autowire("myThread", Runnable.class);
 
c.autowire("myThread", Runnable.class);
}
public static interface MyDAO {
public Object getSomething();
/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java
110,9 → 110,10
 
public Component ioc(String key, Component component) {
if (beans.containsKey(key)) throw new RuntimeException("Container already set for the bean key: " + key);
 
beans.put(key, component);
// clear the singleton cache in case of adding again...
singletons.remove(key);
 
return component;
}
129,8 → 130,6
 
public Dependency autowire(Dependency d) {
 
if (dependencies.contains(d)) throw new RuntimeException("Dependency is already set: " + d.getTarget());
 
dependencies.add(d);
 
return d;