Class SpringWebApplicationFactory

  • All Implemented Interfaces:
    org.apache.wicket.protocol.http.IWebApplicationFactory

    public class SpringWebApplicationFactory
    extends Object
    implements org.apache.wicket.protocol.http.IWebApplicationFactory
    Implementation of IWebApplicationFactory that pulls the WebApplication object out of spring application context. Configuration example:
     <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>
     </filter>
     
    applicationBean init parameter can be used if there are multiple WebApplications defined on the spring application context. Example:
     <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>applicationBean</param-name>
         <param-value>phonebookApplication</param-value>
       </init-param>
     </filter>
     

    This factory is also capable of creating a WebApplication-specific 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)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.wicket.protocol.http.WebApplication createApplication​(org.apache.wicket.protocol.http.WicketFilter filter)  
      protected org.springframework.web.context.ConfigurableWebApplicationContext createWebApplicationContext​(org.springframework.web.context.WebApplicationContext parent, org.apache.wicket.protocol.http.WicketFilter filter)
      Creates and initializes a new WebApplicationContext, with the given context as the parent.
      void destroy​(org.apache.wicket.protocol.http.WicketFilter filter)
      protected String getContextConfigLocation​(org.apache.wicket.protocol.http.WicketFilter filter)
      Returns location of context config that will be used to create a WebApplication -specific application context.
      protected org.springframework.web.context.ConfigurableWebApplicationContext newApplicationContext()
      Factory method used to create a new instance of the web application context, by default an instance o XmlWebApplicationContext will be created.
      protected void postProcessWebApplicationContext​(org.springframework.web.context.ConfigurableWebApplicationContext wac, org.apache.wicket.protocol.http.WicketFilter filter)
      This is a hook for potential subclasses to perform additional processing on the context.
    • Constructor Detail

      • SpringWebApplicationFactory

        public SpringWebApplicationFactory()
    • Method Detail

      • getContextConfigLocation

        protected final String getContextConfigLocation​(org.apache.wicket.protocol.http.WicketFilter filter)
        Returns location of context config that will be used to create a WebApplication -specific application context.
        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 web application context, by default an instance o XmlWebApplicationContext will be created.
        Returns:
        application context instance
      • createApplication

        public org.apache.wicket.protocol.http.WebApplication createApplication​(org.apache.wicket.protocol.http.WicketFilter filter)
        Specified by:
        createApplication in interface org.apache.wicket.protocol.http.IWebApplicationFactory
        See Also:
        IWebApplicationFactory.createApplication(WicketFilter)
      • createWebApplicationContext

        protected final org.springframework.web.context.ConfigurableWebApplicationContext createWebApplicationContext​(org.springframework.web.context.WebApplicationContext parent,
                                                                                                                      org.apache.wicket.protocol.http.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 web application context
        Throws:
        org.springframework.beans.BeansException
      • postProcessWebApplicationContext

        protected void postProcessWebApplicationContext​(org.springframework.web.context.ConfigurableWebApplicationContext wac,
                                                        org.apache.wicket.protocol.http.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​(org.apache.wicket.protocol.http.WicketFilter filter)
        Specified by:
        destroy in interface org.apache.wicket.protocol.http.IWebApplicationFactory