| Issue 140: | 外部からのインジェクトでもコンポーネントが再作成される | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Lucyで外部インジェクトしてもコンポーネントが再作成されてしまう。
インスタンスを登録するときは、スコープについて考慮が必要。
たとえばシングルトンの場合は渡されたインスタンスを渡すなど。
名前ベースのテストをしているときに発見。
public void testNameBasedInject() throws Exception {
final Lucy lucy = getLucy();
lucy.register(NameBasedTargetImpl.class);
NameBasedTargetImpl t1 = new NameBasedTargetImpl();
lucy.register(t1, "aaa");
lucy.register(NameBasedClient.class);
NameBasedClient nameBasedClient = lucy.get(NameBasedClient.class);
NameBasedTarget t2 = nameBasedClient.getNameBasedTarget();
assertNotNull(t2);
assertEquals(t1, t2);//同一にならない
}
Nov 8, 2008
Project Member
#1
shinpei.ohtani@gmail.com
Labels:
-Milestone-T2-0.5 Milestone-Lucy-0.5
Jan 7, 2009
(No comment was entered for this change.)
Status:
Started
Jan 7, 2009
対応しました。原因はBeanDescFactoryのキャッシュでClassをキーにしていたので それ以前に登録した、想定していないBeanDescが返ってきてしまうためでした. r2863で対応しました.
Status:
Fixed
|