@Test public void testHearInitializable() throws Exception { TypeEncounter encounter = createMock(TypeEncounter.class); encounter.register(anyObject(InitializableInjectionListener.class)); replay(encounter); LifecycleTypeListener underTest = new LifecycleTypeListener(null); underTest.hear(TypeLiteral.get(MyInitializable.class), encounter); verify(encounter); }
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))); } }
LifecycleTypeListener implements TypeListener { 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))); } } }
LifecycleTypeListener implements TypeListener { 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))); } } LifecycleTypeListener(DestroyableInjectionListener.DestroyableRegistry registry); }
LifecycleTypeListener implements TypeListener { 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))); } } LifecycleTypeListener(DestroyableInjectionListener.DestroyableRegistry registry); void hear(TypeLiteral<I> type, TypeEncounter<I> encounter); }
LifecycleTypeListener implements TypeListener { 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))); } } LifecycleTypeListener(DestroyableInjectionListener.DestroyableRegistry registry); void hear(TypeLiteral<I> type, TypeEncounter<I> encounter); static final Matcher<TypeLiteral> MATCHER; }