Author: ehillenius
Date: Fri Dec 8 13:00:34 2006
New Revision: 484779
URL: http://svn.apache.org/viewvc?view=rev&rev=484779
Log:
WICKET-154
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java?view=diff&rev=484779&r1=484778&r2=484779
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java
Fri Dec 8 13:00:34 2006
@@ -53,7 +53,6 @@
import wicket.util.lang.PackageName;
import wicket.util.watch.ModificationWatcher;
-
/**
* A web application is a subclass of Application which associates with an
* instance of WicketServlet to serve pages over the HTTP protocol. This class
@@ -68,19 +67,19 @@
* not do this in the constructor itself because the defaults will then
override
* your settings.
* <p>
- * If you want to use servlet specific configuration, e.g. using init
parameters
- * from the [EMAIL PROTECTED] javax.servlet.ServletConfig}object, you should
override the
+ * If you want to use a filter specific configuration, e.g. using init
parameters
+ * from the [EMAIL PROTECTED] javax.servlet.FilterConfig} object, you should
override the
* init() method. For example:
*
* <pre>
- * public void init()
- * {
- * String webXMLParameter =
getWicketServlet().getInitParameter("myWebXMLParameter");
- * URL schedulersConfig =
getWicketServlet().getServletContext().getResource("/WEB-INF/schedulers.xml");
- * ...
+ * public void init()
+ * {
+ * String webXMLParameter =
getInitParameter("myWebXMLParameter");
+ * URL schedulersConfig =
getServletContext().getResource("/WEB-INF/schedulers.xml");
+ * ...
* </pre>
*
- * @see WicketServlet
+ * @see WicketFilter
* @see wicket.settings.IApplicationSettings
* @see wicket.settings.IDebugSettings
* @see wicket.settings.IExceptionSettings
@@ -90,6 +89,9 @@
* @see wicket.settings.IResourceSettings
* @see wicket.settings.ISecuritySettings
* @see wicket.settings.ISessionSettings
+ * @see javax.servlet.Filter
+ * @see javax.servlet.FilterConfig
+ * @see javax.servlet.ServletContext
*
* @author Jonathan Locke
* @author Chris Turner
@@ -163,6 +165,24 @@
}
/**
+ * Gets an init parameter from the filter's context.
+ *
+ * @param key
+ * the key to search for
+ * @return the value of the filter init parameter
+ */
+ public final String getInitParameter(String key)
+ {
+ if (wicketFilter != null)
+ {
+ return
wicketFilter.getFilterConfig().getInitParameter(key);
+ }
+ throw new IllegalStateException("servletContext is not set yet.
Any code in your"
+ + " Application object that uses the
wicketServlet/Filter instance should be put"
+ + " in the init() method instead of your
constructor");
+ }
+
+ /**
* Gets the default request cycle processor (with lazy initialization).
This
* is the [EMAIL PROTECTED] IRequestCycleProcessor} that will be used by
* [EMAIL PROTECTED] RequestCycle}s when custom implementations of the
request cycle
@@ -192,17 +212,20 @@
}
/**
- * @return The Wicket servlet context for this application
+ * Gets the servlet context for this application. Use this to get
references
+ * to absolute paths, global web.xml parameters (<context-param>), etc.
+ *
+ * @return The servlet context for this application
*/
public final ServletContext getServletContext()
{
- if (wicketFilter == null)
+ if (wicketFilter != null)
{
- throw new IllegalStateException("servletContext is not
set yet. Any code in your"
- + " Application object that uses the
wicketServlet instance should be put"
- + " in the init() method instead of
your constructor");
+ return
wicketFilter.getFilterConfig().getServletContext();
}
- return wicketFilter.getFilterConfig().getServletContext();
+ throw new IllegalStateException("servletContext is not set yet.
Any code in your"
+ + " Application object that uses the wicket
filter instance should be put"
+ + " in the init() method instead of your
constructor");
}
/**
@@ -228,6 +251,14 @@
// Namespacing for session attributes is provided by
// adding the servlet path
return sessionAttributePrefix;
+ }
+
+ /**
+ * @return The Wicket filter for this application
+ */
+ public final WicketFilter getWicketFilter()
+ {
+ return wicketFilter;
}
/**