- 56 名前:デフォルトの名無しさん mailto:sage [2007/03/25(日) 02:58:08 ]
- ■ Guice
@Singleton public class TestFactory{ Map<String,Test> map; static{ Injector injector = Guice.createInjector(); map = new HashMap<String,Test>(); map.put("test1",injector.getInstance(Test1.class); map.put("test2",injector.getInstance(Test2.class); map.put("test3",injector.getInstance(Test3.class); } public TestFactory(){} ・・・ } TestFactory testTactory = injector.getInstance(TestFactory .class); Test test = testTactory.getTest(key); test.process();
|

|