org.guiceyfruit.testing
Class InjectorManager

java.lang.Object
  extended by org.guiceyfruit.testing.InjectorManager

public class InjectorManager
extends java.lang.Object

Used to manage the injectors for the various injection points

Version:
$Revision: 1.1 $

Nested Class Summary
protected  class InjectorManager.TestModule
           
 
Constructor Summary
InjectorManager()
           
 
Method Summary
 void afterClasses()
          Lets close all of the injectors we have created so far
 void afterTest(java.lang.Object test)
           
 void beforeClasses()
           
 void beforeTest(java.lang.Object test)
           
protected  void closeInjectors()
           
 void closeSingletons()
          Closes down any JVM level singletons used in this testing JVM
protected  com.google.inject.Injector createInjector(java.lang.Class<? extends com.google.inject.Module> moduleType)
          Creates the injector for the given key
protected  java.lang.Class<? extends com.google.inject.Module> getModuleForTestClass(java.lang.Class<?> objectType)
          Factory method to return the module type that will be used to create an injector.
 boolean isCloseSingletonsAfterClasses()
           
 void setCloseSingletonsAfterClasses(boolean closeSingletonsAfterClasses)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InjectorManager

public InjectorManager()
Method Detail

beforeClasses

public void beforeClasses()

afterClasses

public void afterClasses()
                  throws CloseFailedException
Lets close all of the injectors we have created so far

Throws:
CloseFailedException

beforeTest

public void beforeTest(java.lang.Object test)
                throws java.lang.Exception
Throws:
java.lang.Exception

afterTest

public void afterTest(java.lang.Object test)
               throws java.lang.Exception
Throws:
java.lang.Exception

closeSingletons

public void closeSingletons()
                     throws CloseFailedException
Closes down any JVM level singletons used in this testing JVM

Throws:
CloseFailedException

isCloseSingletonsAfterClasses

public boolean isCloseSingletonsAfterClasses()

setCloseSingletonsAfterClasses

public void setCloseSingletonsAfterClasses(boolean closeSingletonsAfterClasses)

closeInjectors

protected void closeInjectors()
                       throws CloseFailedException
Throws:
CloseFailedException

getModuleForTestClass

protected java.lang.Class<? extends com.google.inject.Module> getModuleForTestClass(java.lang.Class<?> objectType)
                                                                             throws java.lang.IllegalAccessException,
                                                                                    java.lang.InstantiationException,
                                                                                    java.lang.ClassNotFoundException
Factory method to return the module type that will be used to create an injector. The default implementation will use the system property org.guiceyfruit.modules (see Injectors.MODULE_CLASS_NAMES otherwise if that is not set it will look for the UseModule annotation and use the module defined on that otherwise it will try look for the inner public static class "TestModule"

Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException
See Also:
UseModule, NESTED_MODULE_CLASS

createInjector

protected com.google.inject.Injector createInjector(java.lang.Class<? extends com.google.inject.Module> moduleType)
                                             throws java.lang.InstantiationException,
                                                    java.lang.IllegalAccessException,
                                                    java.lang.ClassNotFoundException
Creates the injector for the given key

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException


Copyright © 2011. All Rights Reserved.