@Test public void testAfterInjection() throws Exception { DestroyableInjectionListener.DestroyableRegistry registry = createMock(DestroyableInjectionListener.DestroyableRegistry.class); Destroyable destroyable = createMock(Destroyable.class); registry.add(destroyable); replay(registry, destroyable); DestroyableInjectionListener underTest = new DestroyableInjectionListener(registry); underTest.afterInjection(destroyable); verify(registry, destroyable); } }
public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) { if (InitializableInjectionListener.MATCHER.matches(type)) { encounter.register(this.<I>castListener(new InitializableInjectionListener<Initializable>())); } if (DestroyableInjectionListener.MATCHER.matches(type)) { encounter.register(this.<I>castListener(new DestroyableInjectionListener<Destroyable>(registry))); } }
public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) { if (InitializableInjectionListener.MATCHER.matches(type)) { encounter.register(this.<I>castListener(new InitializableInjectionListener<Initializable>())); } if (DestroyableInjectionListener.MATCHER.matches(type)) { encounter.register(this.<I>castListener(new DestroyableInjectionListener<Destroyable>(registry))); } }