You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2006/10/12 01:11:55 UTC
svn commit: r463042 -
/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java
Author: ehillenius
Date: Wed Oct 11 16:11:54 2006
New Revision: 463042
URL: http://svn.apache.org/viewvc?view=rev&rev=463042
Log:
keep a reference to the configurationType and expose using a getter
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java
Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java?view=diff&rev=463042&r1=463041&r2=463042
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/Application.java Wed Oct 11 16:11:54 2006
@@ -110,18 +110,18 @@
/** Configuration constant for the 2 types */
public static final String CONFIGURATION = "configuration";
- /** Configuration type constant for deployment */
- public static final String DEPLOYMENT = "deployment";
-
- /** Configuration type constant for development */
- public static final String DEVELOPMENT = "development";
-
/**
* Configuration type constant for getting the context path out of the
* web.xml
*/
public static final String CONTEXTPATH = "contextpath";
+ /** Configuration type constant for deployment */
+ public static final String DEPLOYMENT = "deployment";
+
+ /** Configuration type constant for development */
+ public static final String DEVELOPMENT = "development";
+
/**
* Applications keyed on the {@link #getApplicationKey()} so that they can
* be retrieved even without being in a request/ being set in the thread
@@ -135,29 +135,17 @@
/** Log. */
private static final Log log = LogFactory.getLog(Application.class);
- /** list of {@link IComponentInstantiationListener}s. */
- private IComponentInstantiationListener[] componentInstantiationListeners = new IComponentInstantiationListener[0];
-
- /** Markup cache for this application */
- private final MarkupCache markupCache;
-
- /** Application level meta data. */
- private MetaDataEntry[] metaData;
-
- /** Name of application subclass. */
- private final String name;
-
- /** Settings for this application. */
- private Settings settings;
-
- /** can the settings object be set/used. */
- private boolean settingsAccessible;
-
- /** Shared resources for this application */
- private final SharedResources sharedResources;
-
- /** The session facade. */
- private ISessionStore sessionStore;
+ /**
+ * Checks if the <code>Application</code> threadlocal is set in this
+ * thread
+ *
+ * @return true if {@link Application#get()} can return the instance of
+ * application, false otherwise
+ */
+ public static boolean exists()
+ {
+ return current.get() != null;
+ }
/**
* Get Application for current thread.
@@ -176,18 +164,6 @@
}
/**
- * Checks if the <code>Application</code> threadlocal is set in this
- * thread
- *
- * @return true if {@link Application#get()} can return the instance of
- * application, false otherwise
- */
- public static boolean exists()
- {
- return current.get() != null;
- }
-
- /**
* Gets the Application based on the application key of that application.
* THIS METHOD IS NOT MEANT INTENDED FOR FRAMEWORK CLIENTS.
*
@@ -235,6 +211,33 @@
current.set(null);
}
+ /** 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;
+
+ /** Markup cache for this application */
+ private final MarkupCache markupCache;
+
+ /** Application level meta data. */
+ private MetaDataEntry[] metaData;
+
+ /** Name of application subclass. */
+ private final String name;
+
+ /** The session facade. */
+ private ISessionStore sessionStore;
+
+ /** Settings for this application. */
+ private Settings settings;
+
+ /** can the settings object be set/used. */
+ private boolean settingsAccessible;
+
+ /** Shared resources for this application */
+ private final SharedResources sharedResources;
+
/**
* Constructor. <strong>Use {@link #init()} for any configuration of your
* application instead of overriding the constructor.</strong>
@@ -336,6 +339,8 @@
*/
public final void configure(final String configurationType, final IResourceFinder resourceFinder)
{
+ this.configurationType = configurationType;
+
if (resourceFinder != null)
{
getResourceSettings().setResourceFinder(resourceFinder);
@@ -389,6 +394,24 @@
}
/**
+ * @return Application's ajax related settings
+ * @see IAjaxSettings
+ * @since 1.2
+ */
+ public final IAjaxSettings getAjaxSettings()
+ {
+ return getSettings();
+ }
+
+ /**
+ * Gets the unique key of this application within a given context (like a
+ * web application). NOT INTENDED FOR FRAMEWORK CLIENTS.
+ *
+ * @return The unique key of this application
+ */
+ public abstract String getApplicationKey();
+
+ /**
* @return Application's application-wide settings
* @see IApplicationSettings
* @since 1.2
@@ -399,6 +422,17 @@
}
/**
+ * Gets the configuration mode that is currently set, either
+ * {@link #DEVELOPMENT} or {@link #DEPLOYMENT}.
+ *
+ * @return configuration
+ */
+ public String getConfigurationType()
+ {
+ return configurationType;
+ }
+
+ /**
* @return Application's debug related settings
* @see IDebugSettings
* @since 1.2
@@ -500,16 +534,6 @@
}
/**
- * @return Application's ajax related settings
- * @see IAjaxSettings
- * @since 1.2
- */
- public final IAjaxSettings getAjaxSettings()
- {
- return getSettings();
- }
-
- /**
* @return Application's resources related settings
* @see IResourceSettings
* @since 1.2
@@ -540,6 +564,16 @@
}
/**
+ * Gets the facade object for working getting/ storing session instances.
+ *
+ * @return The session facade
+ */
+ public final ISessionStore getSessionStore()
+ {
+ return sessionStore;
+ }
+
+ /**
* This method is still here for backwards compatibility with 1.1 source
* code. The getXXXSettings() methods are now preferred. This method will be
* removed post 1.2 version.
@@ -584,60 +618,6 @@
}
/**
- * Removes a component instantiation listener. This method should typicaly
- * only be called during application startup; it is not thread safe.
- *
- * @param listener
- * the listener to remove
- */
- public final void removeComponentInstantiationListener(
- final IComponentInstantiationListener listener)
- {
- final IComponentInstantiationListener[] listeners = componentInstantiationListeners;
- final int len = listeners.length;
-
- if (listener != null && len > 0)
- {
- int pos = 0;
-
- for (pos = 0; pos < len; pos++)
- {
- if (listener == listeners[pos])
- {
- break;
- }
- }
-
- if (pos < len)
- {
- listeners[pos] = listeners[len - 1];
- final IComponentInstantiationListener[] newListeners = new IComponentInstantiationListener[len - 1];
- System.arraycopy(listeners, 0, newListeners, 0, newListeners.length);
-
- componentInstantiationListeners = newListeners;
- }
- }
- }
-
- /**
- * Sets the metadata for this application using the given key. If the
- * metadata object is not of the correct type for the metadata key, an
- * IllegalArgumentException will be thrown. For information on creating
- * MetaDataKeys, see {@link MetaDataKey}.
- *
- * @param key
- * The singleton key for the metadata
- * @param object
- * The metadata object
- * @throws IllegalArgumentException
- * @see MetaDataKey
- */
- public final void setMetaData(final MetaDataKey key, final Serializable object)
- {
- metaData = key.set(metaData, object);
- }
-
- /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
*
* Initializes wicket components.
@@ -695,30 +675,67 @@
}
/**
- * Gets the unique key of this application within a given context (like a
- * web application). NOT INTENDED FOR FRAMEWORK CLIENTS.
+ * Removes a component instantiation listener. This method should typicaly
+ * only be called during application startup; it is not thread safe.
*
- * @return The unique key of this application
+ * @param listener
+ * the listener to remove
*/
- public abstract String getApplicationKey();
+ public final void removeComponentInstantiationListener(
+ final IComponentInstantiationListener listener)
+ {
+ final IComponentInstantiationListener[] listeners = componentInstantiationListeners;
+ final int len = listeners.length;
+
+ if (listener != null && len > 0)
+ {
+ int pos = 0;
+
+ for (pos = 0; pos < len; pos++)
+ {
+ if (listener == listeners[pos])
+ {
+ break;
+ }
+ }
+
+ if (pos < len)
+ {
+ listeners[pos] = listeners[len - 1];
+ final IComponentInstantiationListener[] newListeners = new IComponentInstantiationListener[len - 1];
+ System.arraycopy(listeners, 0, newListeners, 0, newListeners.length);
+
+ componentInstantiationListeners = newListeners;
+ }
+ }
+ }
/**
- * Gets the facade object for working getting/ storing session instances.
+ * Sets the metadata for this application using the given key. If the
+ * metadata object is not of the correct type for the metadata key, an
+ * IllegalArgumentException will be thrown. For information on creating
+ * MetaDataKeys, see {@link MetaDataKey}.
*
- * @return The session facade
+ * @param key
+ * The singleton key for the metadata
+ * @param object
+ * The metadata object
+ * @throws IllegalArgumentException
+ * @see MetaDataKey
*/
- public final ISessionStore getSessionStore()
+ public final void setMetaData(final MetaDataKey key, final Serializable object)
{
- return sessionStore;
+ metaData = key.set(metaData, object);
}
/**
- * Creates a new session facade. Is called once per application, and is
- * typically not something clients reimplement.
- *
- * @return The session facade
+ * Called when wicket servlet is destroyed. Overrides do not have to call
+ * super.
*/
- protected abstract ISessionStore newSessionStore();
+ protected void destroy()
+ {
+
+ }
/**
* Gets the factory for creating session instances.
@@ -736,6 +753,15 @@
}
/**
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
+ */
+ protected void internalDestroy()
+ {
+ destroy();
+ applicationKeyToApplication.remove(getApplicationKey());
+ }
+
+ /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT OVERRIDE OR
* CALL.
*
@@ -765,22 +791,12 @@
}
/**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
- */
- protected void internalDestroy()
- {
- destroy();
- applicationKeyToApplication.remove(getApplicationKey());
- }
-
- /**
- * Called when wicket servlet is destroyed. Overrides do not have to call
- * super.
+ * Creates a new session facade. Is called once per application, and is
+ * typically not something clients reimplement.
+ *
+ * @return The session facade
*/
- protected void destroy()
- {
-
- }
+ protected abstract ISessionStore newSessionStore();
/**
* Notifies the registered component instantiation listeners of the