roboguice.event
Class ObservesTypeListener

java.lang.Object
  extended by roboguice.event.ObservesTypeListener
All Implemented Interfaces:
com.google.inject.spi.TypeListener

public class ObservesTypeListener
extends Object
implements com.google.inject.spi.TypeListener

Guice driven type listener which scans for the @Observes annotations. Registers these methods with the EventManager.

Author:
Adam Tybor, John Ericksen

Nested Class Summary
static class ObservesTypeListener.ContextObserverMethodInjector<I,T>
          Injection listener to handle the observation manager registration.
 
Field Summary
protected  com.google.inject.Provider<EventManager> eventManagerProvider
           
protected  EventListenerThreadingDecorator observerThreadingDecorator
           
 
Constructor Summary
ObservesTypeListener(com.google.inject.Provider<EventManager> eventManagerProvider, EventListenerThreadingDecorator observerThreadingDecorator)
           
 
Method Summary
protected  void checkMethodParameters(Method method)
          Error checking method, verifies that the method has the correct number of parameters.
protected
<I> void
findContextObserver(Method method, com.google.inject.spi.TypeEncounter<I> iTypeEncounter)
           
<I> void
hear(com.google.inject.TypeLiteral<I> iTypeLiteral, com.google.inject.spi.TypeEncounter<I> iTypeEncounter)
           
protected
<I,T> void
registerContextObserver(com.google.inject.spi.TypeEncounter<I> iTypeEncounter, Method method, Class<T> parameterType, EventThread threadType)
          Error checks the observed method and registers method with typeEncounter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventManagerProvider

protected com.google.inject.Provider<EventManager> eventManagerProvider

observerThreadingDecorator

protected EventListenerThreadingDecorator observerThreadingDecorator
Constructor Detail

ObservesTypeListener

public ObservesTypeListener(com.google.inject.Provider<EventManager> eventManagerProvider,
                            EventListenerThreadingDecorator observerThreadingDecorator)
Method Detail

hear

public <I> void hear(com.google.inject.TypeLiteral<I> iTypeLiteral,
                     com.google.inject.spi.TypeEncounter<I> iTypeEncounter)
Specified by:
hear in interface com.google.inject.spi.TypeListener

findContextObserver

protected <I> void findContextObserver(Method method,
                                       com.google.inject.spi.TypeEncounter<I> iTypeEncounter)

registerContextObserver

protected <I,T> void registerContextObserver(com.google.inject.spi.TypeEncounter<I> iTypeEncounter,
                                             Method method,
                                             Class<T> parameterType,
                                             EventThread threadType)
Error checks the observed method and registers method with typeEncounter

Parameters:
iTypeEncounter -
method -
parameterType -
threadType -
- T>

checkMethodParameters

protected void checkMethodParameters(Method method)
Error checking method, verifies that the method has the correct number of parameters.

Parameters:
method -


Copyright © 2012. All Rights Reserved.