|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.injection.web.InjectorHolder
public class InjectorHolder
Holds a reference to the injector that will be used to automatically initialize components that are used. Usually the application class should set the injector in the holder when it initializes.
This class can be used for unit-testing to switch the standard injector with an injector that will lookup dependencies from a mock application context.
class MockSpringInjector extends SpringInjector { protected ISpringContextLocator getContextLocator() { return new MockContextLocator(); } } InjectorHolder.setInjector(new MockSpringInjector()); // from this point on InjectableWebPage and InjectablePanel // will be injected using the MockSpringInjector
Constructor Summary | |
---|---|
InjectorHolder()
|
Method Summary | |
---|---|
static ConfigurableInjector |
getInjector()
Gets an injector NOTICE this method is not thread safe if setInjector() is used |
static void |
setInjector(ConfigurableInjector newInjector)
Sets an injector NOTICE this method is not thread safe. |
static void |
setInjector(ConfigurableInjector newInjector,
Application application)
Sets an injector NOTICE this method is not thread safe. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InjectorHolder()
Method Detail |
---|
public static ConfigurableInjector getInjector()
public static void setInjector(ConfigurableInjector newInjector)
newInjector
- new injectorpublic static void setInjector(ConfigurableInjector newInjector, Application application)
newInjector
- new injectorapplication
- application instance to which the injector will be bound
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |