Skip to content

Commit

Permalink
[WICKET-7077] no need to re-create global spring context (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
solomax authored Sep 27, 2023
1 parent b265da3 commit 933b0d5
Showing 1 changed file with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.Map;

import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletContext;

import org.apache.wicket.protocol.http.IWebApplicationFactory;
Expand All @@ -36,9 +35,9 @@
/**
* Implementation of IWebApplicationFactory that pulls the WebApplication object out of spring
* application context.
*
*
* Configuration example:
*
*
* <pre>
* &lt;filter&gt;
* &lt;filter-name&gt;MyApplication&lt;/filter-name&gt;
Expand All @@ -49,12 +48,12 @@
* &lt;/init-param&gt;
* &lt;/filter&gt;
* </pre>
*
*
* <code>applicationBean</code> init parameter can be used if there are multiple WebApplications
* defined on the spring application context.
*
*
* Example:
*
*
* <pre>
* &lt;filter&gt;
* &lt;filter-name&gt;MyApplication&lt;/filter-name&gt;
Expand All @@ -69,13 +68,13 @@
* &lt;/init-param&gt;
* &lt;/filter&gt;
* </pre>
*
*
* <p>
* This factory is also capable of creating a {@link WebApplication}-specific application context
* (path to which is specified via the {@code contextConfigLocation} filter param) and chaining it
* to the global one
* </p>
*
*
* <pre>
* &lt;filter&gt;
* &lt;filter-name&gt;MyApplication&lt;/filter-name&gt;
Expand All @@ -90,10 +89,10 @@
* &lt;/init-param&gt;
* &lt;/filter&gt;
* </pre>
*
*
* @author Igor Vaynberg (ivaynberg)
* @author Janne Hietam&auml;ki (jannehietamaki)
*
*
*/
public class SpringWebApplicationFactory implements IWebApplicationFactory
{
Expand All @@ -104,30 +103,19 @@ public class SpringWebApplicationFactory implements IWebApplicationFactory
/**
* Returns location of context config that will be used to create a {@link WebApplication}
* -specific application context.
*
*
* @param filter
* @return location of context config
*/
protected final String getContextConfigLocation(final WicketFilter filter)
{
String contextConfigLocation;

final FilterConfig filterConfig = filter.getFilterConfig();
contextConfigLocation = filterConfig.getInitParameter("contextConfigLocation");

if (contextConfigLocation == null)
{
final ServletContext servletContext = filterConfig.getServletContext();
contextConfigLocation = servletContext.getInitParameter("contextConfigLocation");
}

return contextConfigLocation;
return filter.getFilterConfig().getInitParameter("contextConfigLocation");
}

/**
* Factory method used to create a new instance of the web application context, by default an
* instance of {@link XmlWebApplicationContext} will be created.
*
*
* @return application context instance
*/
protected ConfigurableWebApplicationContext newApplicationContext()
Expand Down Expand Up @@ -191,7 +179,7 @@ private WebApplication createApplication(final ApplicationContext applicationCon
/**
* Creates and initializes a new {@link WebApplicationContext}, with the given context as the
* parent. Based on the logic in Spring's FrameworkServlet#createWebApplicationContext()
*
*
* @param parent
* parent application context
* @param filter
Expand All @@ -216,7 +204,7 @@ protected final ConfigurableWebApplicationContext createWebApplicationContext(
/**
* This is a hook for potential subclasses to perform additional processing on the context.
* Based on the logic in Spring's FrameworkServlet#postProcessWebApplicationContext()
*
*
* @param wac
* additional application context
* @param filter
Expand Down

0 comments on commit 933b0d5

Please sign in to comment.