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
author: Igor Vaynberg (ivaynberg) author: TODO shouldn't we move this class to org.apache.wicket.injection ? |