You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2011/03/16 21:00:25 UTC
svn commit: r1082283 -
/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Author: mgrigorov
Date: Wed Mar 16 20:00:25 2011
New Revision: 1082283
URL: http://svn.apache.org/viewvc?rev=1082283&view=rev
Log:
WICKET-3536 Cache the value from Application.getConfigurationType()
Cache the parsed value of 'wicket.configuration' setting.
A system property or servlet init/context parameter will not ever change at runtime.
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?rev=1082283&r1=1082282&r2=1082283&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java Wed Mar 16 20:00:25 2011
@@ -123,6 +123,13 @@ public abstract class WebApplication ext
private FilterFactoryManager filterFactoryManager;
/**
+ * Cached value of the parsed (from system properties or Servlet init/context parameter)
+ * <code>wicket.configuration</code> setting. No need to re-read it because it wont change at
+ * runtime.
+ */
+ private RuntimeConfigurationType configurationType;
+
+ /**
* Covariant override for easy getting the current {@link WebApplication} without having to cast
* it.
*/
@@ -525,58 +532,66 @@ public abstract class WebApplication ext
@Override
public RuntimeConfigurationType getConfigurationType()
{
- String result = null;
- try
- {
- result = System.getProperty("wicket." + Application.CONFIGURATION);
- }
- catch (SecurityException e)
- {
- // Ignore - we're not allowed to read system properties.
- }
-
- // If no system parameter check filter/servlet <init-param> and <context-param>
- if (result == null)
+ if (configurationType == null)
{
- result = getInitParameter("wicket." + Application.CONFIGURATION);
- }
- if (result == null)
- {
- result = getServletContext().getInitParameter("wicket." + Application.CONFIGURATION);
- }
+ String result = null;
+ try
+ {
+ result = System.getProperty("wicket." + Application.CONFIGURATION);
+ }
+ catch (SecurityException e)
+ {
+ // Ignore - we're not allowed to read system properties.
+ }
- // If no system parameter check filter/servlet specific <init-param>
- if (result == null)
- {
- result = getInitParameter(Application.CONFIGURATION);
- }
+ // If no system parameter check filter/servlet <init-param> and <context-param>
+ if (result == null)
+ {
+ result = getInitParameter("wicket." + Application.CONFIGURATION);
+ }
+ if (result == null)
+ {
+ result = getServletContext().getInitParameter("wicket." + Application.CONFIGURATION);
+ }
- // If no system parameter and no <init-param>, then check
- // <context-param>
- if (result == null)
- {
- result = getServletContext().getInitParameter(Application.CONFIGURATION);
- }
+ // If no system parameter check filter/servlet specific <init-param>
+ if (result == null)
+ {
+ result = getInitParameter(Application.CONFIGURATION);
+ }
- // Return result if we have found it, else fall back to DEVELOPMENT mode
- // as the default.
- if (result != null)
- {
- try
+ // If no system parameter and no <init-param>, then check
+ // <context-param>
+ if (result == null)
{
- return RuntimeConfigurationType.valueOf(result.toUpperCase());
+ result = getServletContext().getInitParameter(Application.CONFIGURATION);
}
- catch (IllegalArgumentException e)
+
+ // Return result if we have found it, else fall back to DEVELOPMENT mode
+ // as the default.
+ if (result != null)
{
- // Ignore : fall back to DEVELOPMENT mode
- // log.warn("Unknown runtime configuration type '" + result +
- // "', falling back to DEVELOPMENT mode.");
- throw new IllegalArgumentException("Invalid configuration type: '" + result +
- "'. Must be \"development\" or \"deployment\".");
+ try
+ {
+ configurationType = RuntimeConfigurationType.valueOf(result.toUpperCase());
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ignore : fall back to DEVELOPMENT mode
+ // log.warn("Unknown runtime configuration type '" + result +
+ // "', falling back to DEVELOPMENT mode.");
+ throw new IllegalArgumentException("Invalid configuration type: '" + result +
+ "'. Must be \"development\" or \"deployment\".");
+ }
}
}
- return RuntimeConfigurationType.DEVELOPMENT;
+ if (configurationType == null)
+ {
+ configurationType = RuntimeConfigurationType.DEVELOPMENT;
+ }
+
+ return configurationType;
}
/**