org.apache.wicket.spring
Class SpringWebApplicationFactory

java.lang.Object
  extended by org.apache.wicket.spring.SpringWebApplicationFactory
All Implemented Interfaces:
IWebApplicationFactory

public class SpringWebApplicationFactory
extends Object
implements IWebApplicationFactory

Implementation of IWebApplicationFactory that pulls the WebApplication object out of spring application context. Configuration example:

 <servlet>
    <servlet-name>phonebook</servlet-name>
    <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
    <init-param>
    <param-name>applicationFactoryClassName</param-name>
    <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
 
applicationBean init parameter can be used if there are multiple WebApplications defined on the spring application context. Example:
 <servlet>
    <servlet-name>phonebook</servlet-name>
    <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
    <init-param>
    <param-name>applicationFactoryClassName</param-name>
    <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
    </init-param>
    <init-param>
    <param-name>applicationBean</param-name>
    <param-value>phonebookApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
 

This factory is also capable of creating an additional application context (path to which is specified via the contextConfigLocation filter param) and chaining it to the global one

 <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.spring.SpringWebApplicationFactory</param-value>
   </init-param>
   <init-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>classpath:com/myapplication/customers-app/context.xml</param-value>
   </init-param>
 </filter>
 

Author:
Igor Vaynberg (ivaynberg), Janne Hietamäki (jannehietamaki)

Constructor Summary
SpringWebApplicationFactory()
           
 
Method Summary
 WebApplication createApplication(WicketFilter filter)
          Create application object
protected  org.springframework.web.context.ConfigurableWebApplicationContext createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent, WicketFilter filter)
          Creates and initializes a new WebApplicationContext, with the given context as the parent.
 void destroy()
          
protected  String getContextConfigLocation(WicketFilter filter)
          Returns location of context config that will be used to create an additional application context for this application
protected  org.springframework.web.context.ConfigurableWebApplicationContext newApplicationContext()
          Factory method used to create a new instance of the additional application context, by default an instance o XmlWebApplicationContext will be created.
protected  void postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext wac, WicketFilter filter)
          This is a hook for potential subclasses to perform additional processing on the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringWebApplicationFactory

public SpringWebApplicationFactory()
Method Detail

getContextConfigLocation

protected final String getContextConfigLocation(WicketFilter filter)
Returns location of context config that will be used to create an additional application context for this application

Parameters:
filter -
Returns:
location of context config

newApplicationContext

protected org.springframework.web.context.ConfigurableWebApplicationContext newApplicationContext()
Factory method used to create a new instance of the additional application context, by default an instance o XmlWebApplicationContext will be created.

Returns:
application context instance

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)

createWebApplicationContext

protected final org.springframework.web.context.ConfigurableWebApplicationContext createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent,
                                                                                                              WicketFilter filter)
                                                                                                       throws org.springframework.beans.BeansException
Creates and initializes a new WebApplicationContext, with the given context as the parent. Based on the logic in FrameworkServlet#createWebApplicationContext

Parameters:
parent - parent application context
filter - wicket filter
Returns:
instance of additional application context
Throws:
org.springframework.beans.BeansException

postProcessWebApplicationContext

protected void postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext wac,
                                                WicketFilter filter)
This is a hook for potential subclasses to perform additional processing on the context. Based on the logic in FrameworkServlet#postProcessWebApplicationContext

Parameters:
wac - additional application context
filter - wicket filter

destroy

public void destroy()



Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.