public class GuiceWebApplicationFactory extends Object implements IWebApplicationFactory
<filter> <filter-name>MyApplication</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationFactoryClassName</param-name> <param-value>org.apache.wicket.guice.GuiceWebApplicationFactory</param-value> </init-param> <init-param> <param-name>module</param-name> <param-value>com.company.MyGuiceModule,com.company.MyOtherGuiceModule</param-value> </init-param> <init-param> <param-name>wicket-guice.stage</param-name> <param-value>DEVELOPMENT</param-value> </init-param> </filter>This factory will create an Injector configured using the Guice Module implementation you pass it above. Multiple modules can be specified by naming multiple classes separated by a comma. The Guice Module (MyGuiceModule in the example above) needs to bind WebApplication.class and provide a concrete implementation of it. The stage used when creating the Injector may be specified by the optional wicket-guice.stage parameter. When this parameter is not present this factory does not use specify a Stage when creating the Injector. This parameter can also be set as a context parameter to provide configuration for all instances in the web application. Alternatively, you can dig the Injector out of the ServletContext as an attribute, like so:
<filter> <filter-name>MyApplication</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationFactoryClassName</param-name> <param-value>org.apache.wicket.guice.GuiceWebApplicationFactory</param-value> </init-param> <init-param> <param-name>injectorContextAttribute</param-name> <param-value>GuiceInjector</param-value> </init-param> </filter>NB: You no longer have to add a GuiceComponentInjector manually in your
WebApplication.init()
method - this factory will do that for you automatically.Modifier and Type | Field and Description |
---|---|
static String |
STAGE_PARAMETER |
Constructor and Description |
---|
GuiceWebApplicationFactory() |
Modifier and Type | Method and Description |
---|---|
WebApplication |
createApplication(WicketFilter filter)
Create application object
|
void |
destroy(WicketFilter filter)
Called when the filter instance that used this factory is destroyed
|
public static final String STAGE_PARAMETER
public WebApplication createApplication(WicketFilter filter)
IWebApplicationFactory
createApplication
in interface IWebApplicationFactory
filter
- the wicket filterIWebApplicationFactory.createApplication(WicketFilter)
public void destroy(WicketFilter filter)
destroy
in interface IWebApplicationFactory
filter
- the wicket filterCopyright © 2006–2022 Apache Software Foundation. All rights reserved.