org.apache.wicket.guice
Class GuiceWebApplicationFactory
java.lang.Object
org.apache.wicket.guice.GuiceWebApplicationFactory
- All Implemented Interfaces:
- IWebApplicationFactory
public class GuiceWebApplicationFactory
- extends java.lang.Object
- implements IWebApplicationFactory
Implementation of IWebApplicationFactory that pulls the WebApplication object out of a Guice
Module.
Configuration example:
<servlet>
<servlet-name>myApp</servlet-name>
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-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>
<load-on-startup>1</load-on-startup>
</servlet>
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:
<servlet>
<servlet-name>myApp</servlet-name>
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-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>
<load-on-startup>1</load-on-startup>
</servlet>
NB: You no longer have to add a GuiceComponentInjector manually in your
WebApplication.init()
method - this factory will do that for you automatically.
- Author:
- Alastair Maw (almaw)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STAGE_PARAMETER
public static final java.lang.String STAGE_PARAMETER
- See Also:
- Constant Field Values
GuiceWebApplicationFactory
public GuiceWebApplicationFactory()
createApplication
public WebApplication createApplication(WicketFilter filter)
- Description copied from interface:
IWebApplicationFactory
- Create application object
- Specified by:
createApplication
in interface IWebApplicationFactory
- Parameters:
filter
- the wicket filter
- Returns:
- application object instance
- See Also:
IWebApplicationFactory.createApplication(WicketFilter)
Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.