You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by al...@apache.org on 2007/06/01 19:37:44 UTC
svn commit: r543548 - in
/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket:
Application.java protocol/http/WebApplication.java
Author: almaw
Date: Fri Jun 1 10:37:43 2007
New Revision: 543548
URL: http://svn.apache.org/viewvc?view=rev&rev=543548
Log:
WICKET-6 - Configuration of app mode isn't customisable.
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java?view=diff&rev=543548&r1=543547&r2=543548
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application.java Fri Jun 1 10:37:43 2007
@@ -58,14 +58,12 @@
import org.apache.wicket.settings.ISecuritySettings;
import org.apache.wicket.settings.ISessionSettings;
import org.apache.wicket.settings.Settings;
-import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.util.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Base class for all Wicket applications. To create a Wicket application, you
* generally should <i>not </i> directly subclass this class. Instead, you will
@@ -214,9 +212,6 @@
/** list of {@link IComponentInstantiationListener}s. */
private IComponentInstantiationListener[] componentInstantiationListeners = new IComponentInstantiationListener[0];
- /** Record what the configuration is, so that we can query for it later. */
- private String configurationType;
-
/** list of initializers. */
private List initializers = new ArrayList();
@@ -315,43 +310,13 @@
}
/**
- * Convenience method that sets application settings to good defaults for
- * the given configuration type (either DEVELOPMENT or DEPLOYMENT).
- *
- * @param configurationType
- * The configuration type (either DEVELOPMENT or DEPLOYMENT)
- * @see org.apache.wicket.Application#configure(String, IResourceFinder)
- */
- public final void configure(final String configurationType)
- {
- configure(configurationType, (IResourceFinder)null);
- }
-
- /**
- * Configures application settings to good defaults for the given
- * configuration type (either DEVELOPMENT or DEPLOYMENT).
- *
- * @param configurationType
- * The configuration type. Must currently be either DEVELOPMENT
- * or DEPLOYMENT. Currently, if the configuration type is
- * DEVELOPMENT, resources are polled for changes, component usage
- * is checked, wicket tags are not stripped from ouput and a
- * detailed exception page is used. If the type is DEPLOYMENT,
- * component usage is not checked, wicket tags are stripped from
- * output and a non-detailed exception page is used to display
- * errors.
- * @param resourceFinder
- * Resource finder for looking up resources
+ * Configures application settings to good defaults.
*/
- public final void configure(final String configurationType, final IResourceFinder resourceFinder)
+ public final void configure()
{
- this.configurationType = configurationType;
+ final String configurationType = getConfigurationType();
- if (resourceFinder != null)
- {
- getResourceSettings().setResourceFinder(resourceFinder);
- }
- // As long as this is public api the developermenat and deployment mode
+ // As long as this is public api the development and deployment mode
// should counter act each other for all properties.
if (DEVELOPMENT.equalsIgnoreCase(configurationType))
{
@@ -381,24 +346,6 @@
}
/**
- * Convenience method that sets application settings to good defaults for
- * the given configuration type (either DEVELOPMENT or DEPLOYMENT).
- *
- * @param configurationType
- * The configuration type (either DEVELOPMENT or DEPLOYMENT)
- * @param resourceFolder
- * Folder for polling resources
- */
- public final void configure(final String configurationType, final String resourceFolder)
- {
- configure(configurationType);
- if (resourceFolder != null)
- {
- getResourceSettings().addResourceFolder(resourceFolder);
- }
- }
-
- /**
* Gets the unique key of this application within a given context (like a
* web application). NOT INTENDED FOR FRAMEWORK CLIENTS.
*
@@ -417,16 +364,24 @@
}
/**
- * Gets the configuration mode that is currently set, either
+ * Gets the configuration mode to use for configuring the app, either
* {@link #DEVELOPMENT} or {@link #DEPLOYMENT}.
*
+ *
+ * The configuration type. Must currently be either DEVELOPMENT
+ * or DEPLOYMENT. Currently, if the configuration type is
+ * DEVELOPMENT, resources are polled for changes, component usage
+ * is checked, wicket tags are not stripped from ouput and a
+ * detailed exception page is used. If the type is DEPLOYMENT,
+ * component usage is not checked, wicket tags are stripped from
+ * output and a non-detailed exception page is used to display
+ * errors.
+ *
* @return configuration
- * @since 1.2.3
+ * @since 1.2.3 (function existed as a property getter)
+ * @since 1.3.0 (abstract, used to configure things)
*/
- public String getConfigurationType()
- {
- return configurationType;
- }
+ public abstract String getConfigurationType();
/**
* @return Application's debug related settings
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java?view=diff&rev=543548&r1=543547&r2=543548
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebApplication.java Fri Jun 1 10:37:43 2007
@@ -45,6 +45,7 @@
import org.apache.wicket.request.target.coding.SharedResourceRequestTargetUrlCodingStrategy;
import org.apache.wicket.session.ISessionStore;
import org.apache.wicket.util.collections.MostRecentlyUsedMap;
+import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.file.WebApplicationPath;
import org.apache.wicket.util.lang.PackageName;
import org.apache.wicket.util.watch.ModificationWatcher;
@@ -524,42 +525,62 @@
getPageSettings().addComponentResolver(new AutoLinkResolver());
// Set resource finder to web app path
- getResourceSettings().setResourceFinder(new WebApplicationPath(getServletContext()));
+ getResourceSettings().setResourceFinder(getResourceFinder());
- // Check if system property -Dwicket.configuration exists
- String configuration = null;
+ // Add optional sourceFolder for resources.
+ String resourceFolder = getInitParameter("sourceFolder");
+ if (resourceFolder != null)
+ {
+ getResourceSettings().addResourceFolder(resourceFolder);
+ }
+
+ // Configure the app.
+ configure();
+ }
+
+ /**
+ * @see org.apache.wicket.Application#getConfigurationType()
+ */
+ public String getConfigurationType()
+ {
+ String result = null;
try
{
- configuration = System.getProperty("wicket." + Application.CONFIGURATION);
+ result = System.getProperty("wicket." + Application.CONFIGURATION);
}
catch (SecurityException e)
{
- // ignore; it is not allowed to read system properties
+ // Ignore - we're not allowed to read system properties.
}
- // If no system parameter check servlet specific <init-param>
- if (configuration == null)
+ // If no system parameter check filter/servlet specific <init-param>
+ if (result == null)
{
- configuration = getInitParameter(Application.CONFIGURATION);
+ result = getInitParameter(Application.CONFIGURATION);
}
+
// If no system parameter and no <init-param>, then check
// <context-param>
- if (configuration == null)
+ if (result == null)
{
- configuration = getServletContext().getInitParameter(Application.CONFIGURATION);
+ result = getServletContext().getInitParameter(Application.CONFIGURATION);
}
- // Development mode is the default if no settings have been found
- if (configuration != null)
- {
- configure(configuration, getInitParameter("sourceFolder"));
- }
- else
+ // Return result if we have found it, else fall back to DEVELOPMENT mode
+ // as the default.
+ if (result != null)
{
- configure(Application.DEVELOPMENT, getInitParameter("sourceFolder"));
+ return result;
}
+
+ return Application.DEVELOPMENT;
}
+ protected IResourceFinder getResourceFinder()
+ {
+ return new WebApplicationPath(getServletContext());
+ }
+
/**
* Gets a new request cycle processor for web requests. May be replaced by
* subclasses which whishes to uses there own implementation of