You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2010/11/20 18:12:12 UTC
svn commit: r1037272 [1/2] - in /wicket/trunk/wicket/src:
main/java/org/apache/wicket/ main/java/org/apache/wicket/settings/
main/java/org/apache/wicket/settings/def/
main/java/org/apache/wicket/util/parse/
main/java/org/apache/wicket/version/ test/jav...
Author: jdonnerstag
Date: Sat Nov 20 17:12:11 2010
New Revision: 1037272
URL: http://svn.apache.org/viewvc?rev=1037272&view=rev
Log:
fixed WICKET-1358 Make Application Class More Bean-ish
Issue: WICKET-1358
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultMapperContext.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultApplicationSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultDebugSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultExceptionSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultFrameworkSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultMarkupSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultPageSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultRequestCycleSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultRequestLoggerSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultResourceSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultSecuritySettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultSessionSettings.java
Removed:
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/parse/
wicket/trunk/wicket/src/main/java/org/apache/wicket/version/
wicket/trunk/wicket/src/test/java/org/apache/wicket/protocol/http/request/urlcompressing/
wicket/trunk/wicket/src/test/java/org/apache/wicket/request/target/coding/
wicket/trunk/wicket/src/test/java/org/apache/wicket/response/
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/parse/metapattern/parsers/
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IApplicationSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/ApplicationSettingsTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/LocalizerTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/model/StringResourceModelTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/resource/loader/ClassStringResourceLoaderTest.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java?rev=1037272&r1=1037271&r2=1037272&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java Sat Nov 20 17:12:11 2010
@@ -20,9 +20,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -39,7 +37,6 @@ import org.apache.wicket.event.IEvent;
import org.apache.wicket.event.IEventSink;
import org.apache.wicket.javascript.DefaultJavascriptCompressor;
import org.apache.wicket.markup.MarkupFactory;
-import org.apache.wicket.markup.MarkupParser;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.markup.html.IHeaderResponseDecorator;
import org.apache.wicket.markup.html.image.resource.DefaultButtonImageResourceFactory;
@@ -66,7 +63,6 @@ import org.apache.wicket.request.IReques
import org.apache.wicket.request.IRequestMapper;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
-import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
import org.apache.wicket.request.cycle.IRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
@@ -75,7 +71,6 @@ import org.apache.wicket.request.cycle.R
import org.apache.wicket.request.mapper.CompoundRequestMapper;
import org.apache.wicket.request.mapper.ICompoundRequestMapper;
import org.apache.wicket.request.mapper.IMapperContext;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.ResourceReferenceRegistry;
import org.apache.wicket.response.filter.EmptySrcAttributeCheckFilter;
import org.apache.wicket.session.DefaultPageFactory;
@@ -92,9 +87,20 @@ import org.apache.wicket.settings.IReque
import org.apache.wicket.settings.IResourceSettings;
import org.apache.wicket.settings.ISecuritySettings;
import org.apache.wicket.settings.ISessionSettings;
-import org.apache.wicket.settings.Settings;
+import org.apache.wicket.settings.def.DefaultApplicationSettings;
+import org.apache.wicket.settings.def.DefaultDebugSettings;
+import org.apache.wicket.settings.def.DefaultExceptionSettings;
+import org.apache.wicket.settings.def.DefaultFrameworkSettings;
+import org.apache.wicket.settings.def.DefaultMarkupSettings;
+import org.apache.wicket.settings.def.DefaultPageSettings;
+import org.apache.wicket.settings.def.DefaultRequestCycleSettings;
+import org.apache.wicket.settings.def.DefaultRequestLoggerSettings;
+import org.apache.wicket.settings.def.DefaultResourceSettings;
+import org.apache.wicket.settings.def.DefaultSecuritySettings;
+import org.apache.wicket.settings.def.DefaultSessionSettings;
import org.apache.wicket.util.IProvider;
import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.lang.PropertyResolver;
import org.apache.wicket.util.lang.WicketObjects;
import org.apache.wicket.util.time.Duration;
@@ -145,10 +151,6 @@ public abstract class Application implem
/** Configuration constant for the 2 types */
public static final String CONFIGURATION = "configuration";
- /** Configuration type constant for getting the context path out of the web.xml */
- // TODO this seems to be used nowhere ... either remove it or re-implement it
- public static final String CONTEXTPATH = "contextpath";
-
/** Configuration type constant for deployment */
public static final String DEPLOYMENT = "deployment";
@@ -160,37 +162,19 @@ public abstract class Application implem
* without being in a request/ being set in the thread local (we need that e.g. for when we are
* in a destruction thread).
*/
- private static final Map<String, Application> applicationKeyToApplication = new HashMap<String, Application>(
- 1);
+ private static final Map<String, Application> applicationKeyToApplication = Generics.newHashMap(1);
/** Log. */
private static final Logger log = LoggerFactory.getLogger(Application.class);
- /** */
- private final ComponentOnBeforeRenderListenerCollection componentPreOnBeforeRenderListeners = new ComponentOnBeforeRenderListenerCollection();
-
- /** */
- private final ComponentOnBeforeRenderListenerCollection componentPostOnBeforeRenderListeners = new ComponentOnBeforeRenderListenerCollection();
-
- /** */
- private ComponentOnAfterRenderListenerCollection componentOnAfterRenderListeners = new ComponentOnAfterRenderListenerCollection();
-
- private final RequestCycleListenerCollection requestCycleListeners = new RequestCycleListenerCollection();
-
/** root mapper */
private IRequestMapper rootRequestMapper;
- /** list of {@link IComponentInstantiationListener}s. */
- private final ComponentInstantiationListenerCollection componentInstantiationListeners = new ComponentInstantiationListenerCollection();
-
- /** list of {@link IComponentInitializationListener}s. */
- private final ComponentInitializationListenerCollection componentInitializationListeners = new ComponentInitializationListenerCollection();
-
/** The converter locator instance. */
private IConverterLocator converterLocator;
/** list of initializers. */
- private final List<IInitializer> initializers = new ArrayList<IInitializer>();
+ private final List<IInitializer> initializers = Generics.newArrayList();
/** Application level meta data. */
private MetaDataEntry<?>[] metaData;
@@ -204,15 +188,10 @@ public abstract class Application implem
/** The session facade. */
private volatile ISessionStore sessionStore;
- /** Settings for this application. */
- private Settings settings;
-
- /** can the settings object be set/used. */
- private boolean settingsAccessible;
-
/** page renderer provider */
private IPageRendererProvider pageRendererProvider;
+ /** */
private PageAccessSynchronizer pageAccessSynchronizer;
/** request cycle provider */
@@ -262,7 +241,7 @@ public abstract class Application implem
* application)
* @return The application or <code>null</code> if application has not been found
*/
- public static Application get(String applicationKey)
+ public static Application get(final String applicationKey)
{
return applicationKeyToApplication.get(applicationKey);
}
@@ -307,17 +286,6 @@ public abstract class Application implem
});
}
-
- public final ComponentInstantiationListenerCollection getComponentInstantiationListeners()
- {
- return componentInstantiationListeners;
- }
-
- public final ComponentInitializationListenerCollection getComponentInitializationListeners()
- {
- return componentInitializationListeners;
- }
-
/**
* Configures application settings to good defaults.
*/
@@ -367,16 +335,6 @@ public abstract class Application implem
public abstract String getApplicationKey();
/**
- * @return Application's application-wide settings
- * @see IApplicationSettings
- * @since 1.2
- */
- public IApplicationSettings getApplicationSettings()
- {
- return getSettings();
- }
-
- /**
* Gets the configuration mode to use for configuring the app, either {@link #DEVELOPMENT} or
* {@link #DEPLOYMENT}.
* <p>
@@ -431,44 +389,6 @@ public abstract class Application implem
public abstract String getConfigurationType();
/**
- * @return The converter locator for this application
- */
- public final IConverterLocator getConverterLocator()
- {
- return converterLocator;
- }
-
- /**
- * @return Application's debug related settings
- * @see IDebugSettings
- * @since 1.2
- */
- public IDebugSettings getDebugSettings()
- {
- return getSettings();
- }
-
- /**
- * @return Application's exception handling settings
- * @see IExceptionSettings
- * @since 1.2
- */
- public IExceptionSettings getExceptionSettings()
- {
- return getSettings();
- }
-
- /**
- * @return Wicket framework settings
- * @see IFrameworkSettings
- * @since 1.2
- */
- public IFrameworkSettings getFrameworkSettings()
- {
- return getSettings();
- }
-
- /**
* Application subclasses must specify a home page class by implementing this abstract method.
*
* @return Home page class for this application
@@ -476,13 +396,11 @@ public abstract class Application implem
public abstract Class<? extends Page> getHomePage();
/**
- * @return Application's markup related settings
- * @see IMarkupSettings
- * @since 1.2
+ * @return The converter locator for this application
*/
- public IMarkupSettings getMarkupSettings()
+ public final IConverterLocator getConverterLocator()
{
- return getSettings();
+ return converterLocator;
}
/**
@@ -510,26 +428,6 @@ public abstract class Application implem
}
/**
- * @return Application's page related settings
- * @see IPageSettings
- * @since 1.2
- */
- public IPageSettings getPageSettings()
- {
- return getSettings();
- }
-
- /**
- * @return Application's request cycle related settings
- * @see IDebugSettings
- * @since 1.2
- */
- public IRequestCycleSettings getRequestCycleSettings()
- {
- return getSettings();
- }
-
- /**
* Gets the {@link IRequestLogger}.
*
* @return The RequestLogger
@@ -551,46 +449,6 @@ public abstract class Application implem
}
/**
- * @return Application's resources related settings
- * @see IResourceSettings
- * @since 1.3
- */
- public IRequestLoggerSettings getRequestLoggerSettings()
- {
- return getSettings();
- }
-
- /**
- * @return Application's resources related settings
- * @see IResourceSettings
- * @since 1.2
- */
- public IResourceSettings getResourceSettings()
- {
- return getSettings();
- }
-
- /**
- * @return Application's security related settings
- * @see ISecuritySettings
- * @since 1.2
- */
- public ISecuritySettings getSecuritySettings()
- {
- return getSettings();
- }
-
- /**
- * @return Application's session related settings
- * @see ISessionSettings
- * @since 1.2
- */
- public ISessionSettings getSessionSettings()
- {
- return getSettings();
- }
-
- /**
* Gets the facade object for working getting/ storing session instances.
*
* @return The session facade
@@ -611,7 +469,10 @@ public abstract class Application implem
return sessionStore;
}
- public void sessionUnbound(String sessionId)
+ /**
+ * @see org.apache.wicket.session.ISessionStore.UnboundListener#sessionUnbound(java.lang.String)
+ */
+ public void sessionUnbound(final String sessionId)
{
getPageManager().sessionExpired(sessionId);
}
@@ -665,7 +526,7 @@ public abstract class Application implem
*
* @param target
*/
- public void logEventTarget(IRequestHandler target)
+ public void logEventTarget(final IRequestHandler target)
{
}
@@ -674,7 +535,7 @@ public abstract class Application implem
*
* @param requestTarget
*/
- public void logResponseTarget(IRequestHandler requestTarget)
+ public void logResponseTarget(final IRequestHandler requestTarget)
{
}
@@ -718,7 +579,7 @@ public abstract class Application implem
*
* @param className
*/
- private void addInitializer(String className)
+ private void addInitializer(final String className)
{
IInitializer initializer = (IInitializer)WicketObjects.newInstance(className);
if (initializer != null)
@@ -756,37 +617,6 @@ public abstract class Application implem
}
/**
- * 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.
- *
- * @return Application settings
- *
- * @see Application#getApplicationSettings()
- * @see Application#getDebugSettings()
- * @see Application#getExceptionSettings()
- * @see Application#getMarkupSettings()
- * @see Application#getPageSettings()
- * @see Application#getRequestCycleSettings()
- * @see Application#getResourceSettings()
- * @see Application#getSecuritySettings()
- * @see Application#getSessionSettings()
- */
- private Settings getSettings()
- {
- if (!settingsAccessible)
- {
- throw new WicketRuntimeException(
- "Use Application.init() method for configuring your application object");
- }
-
- if (settings == null)
- {
- settings = new Settings(this);
- }
- return settings;
- }
-
- /**
* @param properties
* Properties map with names of any library initializers in it
*/
@@ -829,7 +659,9 @@ public abstract class Application implem
MarkupFactory markupFactory = getMarkupSettings().getMarkupFactory();
if (markupFactory.hasMarkupCache())
+ {
markupFactory.getMarkupCache().shutdown();
+ }
onDestroy();
@@ -886,13 +718,20 @@ public abstract class Application implem
requestCycleProvider = new DefaultRequestCycleProvider();
}
-
+ /**
+ *
+ * @return Session state provider
+ */
public final IProvider<ISessionStore> getSessionStoreProvider()
{
return sessionStoreProvider;
}
- public final void setSessionStoreProvider(IProvider<ISessionStore> sessionStoreProvider)
+ /**
+ *
+ * @param sessionStoreProvider
+ */
+ public final void setSessionStoreProvider(final IProvider<ISessionStore> sessionStoreProvider)
{
this.sessionStoreProvider = sessionStoreProvider;
}
@@ -918,32 +757,6 @@ public abstract class Application implem
return new DummyRequestLogger();
}
- public final ComponentOnBeforeRenderListenerCollection getComponentPreOnBeforeRenderListeners()
- {
- return componentPreOnBeforeRenderListeners;
- }
-
- public final ComponentOnBeforeRenderListenerCollection getComponentPostOnBeforeRenderListeners()
- {
- return componentPostOnBeforeRenderListeners;
- }
-
- /**
- * @return on after render listeners collection
- */
- public final ComponentOnAfterRenderListenerCollection getComponentOnAfterRenderListeners()
- {
- return componentOnAfterRenderListeners;
- }
-
- /**
- * @return the unmodifiable request list of {@link IRequestCycleListener}s in this application
- */
- public RequestCycleListenerCollection getRequestCycleListeners()
- {
- return requestCycleListeners;
- }
-
/**
* Converts the root mapper to a {@link ICompoundRequestMapper} if necessary and returns the
* converted instance.
@@ -961,7 +774,6 @@ public abstract class Application implem
return (ICompoundRequestMapper)root;
}
-
/**
* @return The root request mapper
*/
@@ -980,213 +792,640 @@ public abstract class Application implem
this.rootRequestMapper = rootRequestMapper;
}
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Page Manager
- //
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- private volatile IPageManager pageManager;
- private IPageManagerProvider pageManagerProvider;
-
- public final IPageManagerProvider getPageManagerProvider()
+ /**
+ * Initialize the application
+ */
+ public final void initApplication()
{
- return pageManagerProvider;
- }
-
+ if (name == null)
+ {
+ throw new IllegalStateException("setName must be called before initApplication");
+ }
+ internalInit();
+ init();
+ initializeComponents();
- public synchronized final void setPageManagerProvider(final IPageManagerProvider provider)
- {
- pageManagerProvider = provider;
+ validateInit();
}
/**
- * Context for PageManager to interact with rest of Wicket
+ * Gives the Application object a chance to validate if it has been properly initialized
*/
- private final IPageManagerContext pageManagerContext = new DefaultPageManagerContext();
+ protected void validateInit()
+ {
+ if (getPageRendererProvider() == null)
+ {
+ throw new IllegalStateException(
+ "An instance of IPageRendererProvider has not yet been set on this Application. @see Application#setPageRendererProvider");
+ }
+ if (getSessionStoreProvider() == null)
+ {
+ throw new IllegalStateException(
+ "An instance of ISessionStoreProvider has not yet been set on this Application. @see Application#setSessionStoreProvider");
+ }
+ if (getPageManagerProvider() == null)
+ {
+ throw new IllegalStateException(
+ "An instance of IPageManagerProvider has not yet been set on this Application. @see Application#setPageManagerProvider");
+ }
+ }
/**
+ * Sets application name. This method must be called before any other methods are invoked and
+ * can only be called once per application instance.
*
- * @return the page manager
+ * @param name
+ * unique application name
*/
- public final IPageManager getPageManager()
+ public final void setName(final String name)
{
- if (pageManager == null)
+ Args.notEmpty(name, "name");
+
+ if (this.name != null)
{
- synchronized (this)
- {
- if (pageManager == null)
- {
- pageManager = pageAccessSynchronizer.adapt(pageManagerProvider.get(getPageManagerContext()));
- }
- }
+ throw new IllegalStateException("Application name can only be set once.");
}
- return pageManager;
+
+ if (applicationKeyToApplication.get(name) != null)
+ {
+ throw new IllegalStateException("Application with name '" + name + "' already exists.'");
+ }
+
+ this.name = name;
+ applicationKeyToApplication.put(name, this);
}
/**
+ * Returns the mime type for given filename.
*
- * @return the page manager context
+ * @param fileName
+ * @return mime type
*/
- protected IPageManagerContext getPageManagerContext()
+ public String getMimeType(final String fileName)
+ {
+ return URLConnection.getFileNameMap().getContentTypeFor(fileName);
+ }
+
+ /** {@inheritDoc} */
+ public void onEvent(final IEvent<?> event)
{
- return pageManagerContext;
}
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
- // Page Rendering
+ // Listeners
//
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public final IPageRendererProvider getPageRendererProvider()
+ /** */
+ private final ComponentOnBeforeRenderListenerCollection componentPreOnBeforeRenderListeners = new ComponentOnBeforeRenderListenerCollection();
+
+ /** */
+ private final ComponentOnBeforeRenderListenerCollection componentPostOnBeforeRenderListeners = new ComponentOnBeforeRenderListenerCollection();
+
+ /** */
+ private final ComponentOnAfterRenderListenerCollection componentOnAfterRenderListeners = new ComponentOnAfterRenderListenerCollection();
+
+ /** */
+ private final RequestCycleListenerCollection requestCycleListeners = new RequestCycleListenerCollection();
+
+ /** list of {@link IComponentInstantiationListener}s. */
+ private final ComponentInstantiationListenerCollection componentInstantiationListeners = new ComponentInstantiationListenerCollection();
+
+ /** list of {@link IComponentInitializationListener}s. */
+ private final ComponentInitializationListenerCollection componentInitializationListeners = new ComponentInitializationListenerCollection();
+
+ /**
+ * @return Gets the application's ComponentInstantiationListenerCollection
+ */
+ public final ComponentInstantiationListenerCollection getComponentInstantiationListeners()
{
- return pageRendererProvider;
+ return componentInstantiationListeners;
}
- public final void setPageRendererProvider(IPageRendererProvider pageRendererProvider)
+ /**
+ * @return Gets the application's ComponentInitializationListeners
+ */
+ public final ComponentInitializationListenerCollection getComponentInitializationListeners()
{
- Args.notNull(pageRendererProvider, "pageRendererProvider");
- this.pageRendererProvider = pageRendererProvider;
+ return componentInitializationListeners;
}
+ /**
+ *
+ * @return ComponentOnBeforeRenderListenerCollection
+ */
+ public final ComponentOnBeforeRenderListenerCollection getComponentPreOnBeforeRenderListeners()
+ {
+ return componentPreOnBeforeRenderListeners;
+ }
+
+ /**
+ *
+ * @return ComponentOnBeforeRenderListenerCollection
+ */
+ public final ComponentOnBeforeRenderListenerCollection getComponentPostOnBeforeRenderListeners()
+ {
+ return componentPostOnBeforeRenderListeners;
+ }
+
+ /**
+ * @return on after render listeners collection
+ */
+ public final ComponentOnAfterRenderListenerCollection getComponentOnAfterRenderListeners()
+ {
+ return componentOnAfterRenderListeners;
+ }
+
+ /**
+ * @return the unmodifiable request list of {@link IRequestCycleListener}s in this application
+ */
+ public RequestCycleListenerCollection getRequestCycleListeners()
+ {
+ return requestCycleListeners;
+ }
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
- // Request Handler encoding
+ // Settings
//
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /** Application settings */
+ private IApplicationSettings applicationSettings;
- private ResourceReferenceRegistry resourceReferenceRegistry;
+ /** Debug Settings */
+ private IDebugSettings debugSettings;
+
+ /** Exception Settings */
+ private IExceptionSettings exceptionSettings;
+
+ /** Framework Settings */
+ private IFrameworkSettings frameworkSettings;
+
+ /** The Markup Settings */
+ private IMarkupSettings markupSettings;
+
+ /** The Page Settings */
+ private IPageSettings pageSettings;
+
+ /** The Request Cycle Settings */
+ private IRequestCycleSettings requestCycleSettings;
+
+ /** The Request Logger Settings */
+ private IRequestLoggerSettings requestLoggerSettings;
+
+ /** The Resource Settings */
+ private IResourceSettings resourceSettings;
+
+ /** The Security Settings */
+ private ISecuritySettings securitySettings;
+
+ /** The Session Settings */
+ private ISessionSettings sessionSettings;
+
+ /** can the settings object be set/used. */
+ private boolean settingsAccessible;
/**
- * Override to create custom {@link ResourceReferenceRegistry}.
- *
- * @return new {@link ResourceReferenceRegistry} instance.
+ * @return Application's application-wide settings
+ * @since 1.2
*/
- protected ResourceReferenceRegistry newResourceReferenceRegistry()
+ public final IApplicationSettings getApplicationSettings()
{
- return new ResourceReferenceRegistry();
+ checkSettingsAvailable();
+ if (applicationSettings == null)
+ {
+ applicationSettings = new DefaultApplicationSettings();
+ }
+ return applicationSettings;
}
/**
- * Returns {@link ResourceReferenceRegistry} for this application.
*
- * @return
+ * @param applicationSettings
*/
- public final ResourceReferenceRegistry getResourceReferenceRegistry()
+ public final void setApplicationSettings(final IApplicationSettings applicationSettings)
{
- return resourceReferenceRegistry;
+ this.applicationSettings = applicationSettings;
}
- private SharedResources sharedResources;
+ /**
+ * @return Application's debug related settings
+ */
+ public final IDebugSettings getDebugSettings()
+ {
+ checkSettingsAvailable();
+ if (debugSettings == null)
+ {
+ debugSettings = new DefaultDebugSettings();
+ }
+ return debugSettings;
+ }
- protected SharedResources newSharedResources(ResourceReferenceRegistry registry)
+ /**
+ *
+ * @param debugSettings
+ */
+ public final void setDebugSettings(final IDebugSettings debugSettings)
{
- return new SharedResources(registry);
+ this.debugSettings = debugSettings;
}
- public SharedResources getSharedResources()
+ /**
+ * @return Application's exception handling settings
+ */
+ public final IExceptionSettings getExceptionSettings()
{
- return sharedResources;
+ checkSettingsAvailable();
+ if (exceptionSettings == null)
+ {
+ exceptionSettings = new DefaultExceptionSettings();
+ }
+ return exceptionSettings;
}
- private IPageFactory pageFactory;
+ /**
+ *
+ * @param exceptionSettings
+ */
+ public final void setExceptionSettings(final IExceptionSettings exceptionSettings)
+ {
+ this.exceptionSettings = exceptionSettings;
+ }
+
+ /**
+ * @return Wicket framework settings
+ */
+ public final IFrameworkSettings getFrameworkSettings()
+ {
+ checkSettingsAvailable();
+ if (frameworkSettings == null)
+ {
+ frameworkSettings = new DefaultFrameworkSettings();
+ }
+ return frameworkSettings;
+ }
/**
- * Override to create custom {@link IPageFactory}
*
- * @return new {@link IPageFactory} instance.
+ * @param frameworkSettings
*/
- protected IPageFactory newPageFactory()
+ public final void setFrameworkSettings(final IFrameworkSettings frameworkSettings)
{
- return new DefaultPageFactory();
+ this.frameworkSettings = frameworkSettings;
+ }
+
+ /**
+ * @return Application's page related settings
+ */
+ public final IPageSettings getPageSettings()
+ {
+ checkSettingsAvailable();
+ if (pageSettings == null)
+ {
+ pageSettings = new DefaultPageSettings();
+ }
+ return pageSettings;
}
/**
- * Returns {@link IPageFactory} for this application.
*
- * @return
+ * @param pageSettings
*/
- public final IPageFactory getPageFactory()
+ public final void setPageSettings(final IPageSettings pageSettings)
{
- return pageFactory;
+ this.pageSettings = pageSettings;
}
- private final IMapperContext encoderContext = new IMapperContext()
+ /**
+ * @return Application's request cycle related settings
+ */
+ public final IRequestCycleSettings getRequestCycleSettings()
{
- public String getBookmarkableIdentifier()
+ checkSettingsAvailable();
+ if (requestCycleSettings == null)
{
- return "bookmarkable";
+ requestCycleSettings = new DefaultRequestCycleSettings();
}
+ return requestCycleSettings;
+ }
- public String getNamespace()
+ /**
+ *
+ * @param requestCycleSettings
+ */
+ public final void setRequestCycleSettings(final IRequestCycleSettings requestCycleSettings)
+ {
+ this.requestCycleSettings = requestCycleSettings;
+ }
+
+ /**
+ * @return Application's markup related settings
+ */
+ public IMarkupSettings getMarkupSettings()
+ {
+ checkSettingsAvailable();
+ if (markupSettings == null)
{
- return MarkupParser.WICKET;
+ markupSettings = new DefaultMarkupSettings(this);
}
+ return markupSettings;
+ }
+
+ /**
+ *
+ * @param markupSettings
+ */
+ public final void setMarkupSettings(final IMarkupSettings markupSettings)
+ {
+ this.markupSettings = markupSettings;
+ }
- public String getPageIdentifier()
+ /**
+ * @return Application's request logger related settings
+ */
+ public final IRequestLoggerSettings getRequestLoggerSettings()
+ {
+ checkSettingsAvailable();
+ if (requestLoggerSettings == null)
{
- return "page";
+ requestLoggerSettings = new DefaultRequestLoggerSettings();
}
+ return requestLoggerSettings;
+ }
+
+ /**
+ *
+ * @param requestLoggerSettings
+ */
+ public final void setRequestLoggerSettings(final IRequestLoggerSettings requestLoggerSettings)
+ {
+ this.requestLoggerSettings = requestLoggerSettings;
+ }
- public String getResourceIdentifier()
+ /**
+ * @return Application's resources related settings
+ */
+ public final IResourceSettings getResourceSettings()
+ {
+ checkSettingsAvailable();
+ if (resourceSettings == null)
{
- return "resource";
+ resourceSettings = new DefaultResourceSettings(this);
}
+ return resourceSettings;
+ }
+
+ /**
+ *
+ * @param resourceSettings
+ */
+ public final void setResourceSettings(final IResourceSettings resourceSettings)
+ {
+ this.resourceSettings = resourceSettings;
+ }
- public ResourceReferenceRegistry getResourceReferenceRegistry()
+ /**
+ * @return Application's security related settings
+ */
+ public final ISecuritySettings getSecuritySettings()
+ {
+ checkSettingsAvailable();
+ if (securitySettings == null)
{
- return Application.this.getResourceReferenceRegistry();
+ securitySettings = new DefaultSecuritySettings();
}
+ return securitySettings;
+ }
- public RequestListenerInterface requestListenerInterfaceFromString(String interfaceName)
+ /**
+ *
+ * @param securitySettings
+ */
+ public final void setSecuritySettings(final ISecuritySettings securitySettings)
+ {
+ this.securitySettings = securitySettings;
+ }
+
+ /**
+ * @return Application's session related settings
+ */
+ public final ISessionSettings getSessionSettings()
+ {
+ checkSettingsAvailable();
+ if (sessionSettings == null)
{
- return RequestListenerInterface.forName(interfaceName);
+ sessionSettings = new DefaultSessionSettings();
}
+ return sessionSettings;
+ }
+
+ /**
+ *
+ * @param sessionSettings
+ */
+ public final void setSessionSettings(final ISessionSettings sessionSettings)
+ {
+ this.sessionSettings = sessionSettings;
+ }
- public String requestListenerInterfaceToString(RequestListenerInterface listenerInterface)
+ /**
+ *
+ */
+ private void checkSettingsAvailable()
+ {
+ if (!settingsAccessible)
{
- return listenerInterface.getName();
+ throw new WicketRuntimeException(
+ "Use Application.init() method for configuring your application object");
}
+ }
- public IRequestablePage newPageInstance(Class<? extends IRequestablePage> pageClass,
- PageParameters pageParameters)
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Page Manager
+ //
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ private volatile IPageManager pageManager;
+ private IPageManagerProvider pageManagerProvider;
+
+ /**
+ *
+ * @return PageManagerProvider
+ */
+ public final IPageManagerProvider getPageManagerProvider()
+ {
+ return pageManagerProvider;
+ }
+
+ /**
+ *
+ * @param provider
+ */
+ public synchronized final void setPageManagerProvider(final IPageManagerProvider provider)
+ {
+ pageManagerProvider = provider;
+ }
+
+ /**
+ * Context for PageManager to interact with rest of Wicket
+ */
+ private final IPageManagerContext pageManagerContext = new DefaultPageManagerContext();
+
+ /**
+ *
+ * @return the page manager
+ */
+ public final IPageManager getPageManager()
+ {
+ if (pageManager == null)
{
- if (pageParameters == null)
- {
- return getPageFactory().newPage(pageClass);
- }
- else
+ synchronized (this)
{
- return getPageFactory().newPage(pageClass, pageParameters);
+ if (pageManager == null)
+ {
+ pageManager = pageAccessSynchronizer.adapt(pageManagerProvider.get(getPageManagerContext()));
+ }
}
}
+ return pageManager;
+ }
- public IRequestablePage getPageInstance(int pageId)
- {
- return Page.getPage(pageId);
- }
+ /**
+ *
+ * @return the page manager context
+ */
+ protected IPageManagerContext getPageManagerContext()
+ {
+ return pageManagerContext;
+ }
- public Class<? extends IRequestablePage> getHomePageClass()
- {
- return Application.this.getHomePage();
- }
- };
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Page Rendering
+ //
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ *
+ * @return PageRendererProvider
+ */
+ public final IPageRendererProvider getPageRendererProvider()
+ {
+ return pageRendererProvider;
+ }
+ /**
+ *
+ * @param pageRendererProvider
+ */
+ public final void setPageRendererProvider(final IPageRendererProvider pageRendererProvider)
+ {
+ Args.notNull(pageRendererProvider, "pageRendererProvider");
+ this.pageRendererProvider = pageRendererProvider;
+ }
+
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Request Handler encoding
+ //
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ private ResourceReferenceRegistry resourceReferenceRegistry;
+
+ private SharedResources sharedResources;
+
+ private IPageFactory pageFactory;
+
+ private final IMapperContext encoderContext = new DefaultMapperContext();
+
+ /**
+ * Override to create custom {@link ResourceReferenceRegistry}.
+ *
+ * @return new {@link ResourceReferenceRegistry} instance.
+ */
+ protected ResourceReferenceRegistry newResourceReferenceRegistry()
+ {
+ return new ResourceReferenceRegistry();
+ }
+
+ /**
+ * Returns {@link ResourceReferenceRegistry} for this application.
+ *
+ * @return ResourceReferenceRegistry
+ */
+ public final ResourceReferenceRegistry getResourceReferenceRegistry()
+ {
+ return resourceReferenceRegistry;
+ }
+
+ /**
+ *
+ * @param registry
+ * @return SharedResources
+ */
+ protected SharedResources newSharedResources(final ResourceReferenceRegistry registry)
+ {
+ return new SharedResources(registry);
+ }
+
+ /**
+ *
+ * @return SharedResources
+ */
+ public SharedResources getSharedResources()
+ {
+ return sharedResources;
+ }
+
+ /**
+ * Override to create custom {@link IPageFactory}
+ *
+ * @return new {@link IPageFactory} instance.
+ */
+ protected IPageFactory newPageFactory()
+ {
+ return new DefaultPageFactory();
+ }
+
+ /**
+ * Returns {@link IPageFactory} for this application.
+ *
+ * @return page factory
+ */
+ public final IPageFactory getPageFactory()
+ {
+ return pageFactory;
+ }
+
+ /**
+ *
+ * @return mapper context
+ */
public final IMapperContext getEncoderContext()
{
return encoderContext;
}
- public Session fetchCreateAndSetSession(RequestCycle requestCycle)
+ /**
+ *
+ * @param requestCycle
+ * @return Session
+ */
+ public Session fetchCreateAndSetSession(final RequestCycle requestCycle)
{
Args.notNull(requestCycle, "requestCycle");
@@ -1204,29 +1443,42 @@ public abstract class Application implem
return session;
}
-
+ /**
+ *
+ * @return RequestCycleProvider
+ */
public IRequestCycleProvider getRequestCycleProvider()
{
return requestCycleProvider;
}
- public void setRequestCycleProvider(IRequestCycleProvider requestCycleProvider)
+ /**
+ *
+ * @param requestCycleProvider
+ */
+ public void setRequestCycleProvider(final IRequestCycleProvider requestCycleProvider)
{
this.requestCycleProvider = requestCycleProvider;
}
+ /**
+ *
+ */
private static class DefaultRequestCycleProvider implements IRequestCycleProvider
{
-
- public RequestCycle get(RequestCycleContext context)
+ public RequestCycle get(final RequestCycleContext context)
{
return new RequestCycle(context);
}
-
}
-
- public final RequestCycle createRequestCycle(Request request, Response response)
+ /**
+ *
+ * @param request
+ * @param response
+ * @return request cycle
+ */
+ public final RequestCycle createRequestCycle(final Request request, final Response response)
{
RequestCycleContext context = new RequestCycleContext(request, response,
getRootRequestMapper(), newExceptionMapper());
@@ -1236,7 +1488,7 @@ public abstract class Application implem
requestCycle.getListeners().add(new AbstractRequestCycleListener()
{
@Override
- public void onDetach(RequestCycle requestCycle)
+ public void onDetach(final RequestCycle requestCycle)
{
getPageManager().commitRequest();
}
@@ -1254,92 +1506,13 @@ public abstract class Application implem
}
/**
- * Initialize the application
- */
- public final void initApplication()
- {
- if (name == null)
- {
- throw new IllegalStateException("setName must be called before initApplication");
- }
- internalInit();
- init();
- initializeComponents();
-
- validateInit();
- }
-
- /**
- * Gives the Application object a chance to validate if it has been properly initialized
- */
- protected void validateInit()
- {
- if (getPageRendererProvider() == null)
- {
- throw new IllegalStateException(
- "An instance of IPageRendererProvider has not yet been set on this Application. @see Application#setPageRendererProvider");
- }
- if (getSessionStoreProvider() == null)
- {
- throw new IllegalStateException(
- "An instance of ISessionStoreProvider has not yet been set on this Application. @see Application#setSessionStoreProvider");
- }
- if (getPageManagerProvider() == null)
- {
- throw new IllegalStateException(
- "An instance of IPageManagerProvider has not yet been set on this Application. @see Application#setPageManagerProvider");
- }
- }
-
- /**
- * Sets application name. This method must be called before any other methods are invoked and
- * can only be called once per application instance.
- *
- * @param name
- * unique application name
- */
- public final void setName(String name)
- {
- Args.notEmpty(name, "name");
-
- if (this.name != null)
- {
- throw new IllegalStateException("Application name can only be set once.");
- }
-
- if (applicationKeyToApplication.get(name) != null)
- {
- throw new IllegalStateException("Application with name '" + name + "' already exists.'");
- }
-
- this.name = name;
- applicationKeyToApplication.put(name, this);
- }
-
- /**
- * Returns the mime type for given filename.
- *
- * @param fileName
- * @return mime type
- */
- public String getMimeType(String fileName)
- {
- return URLConnection.getFileNameMap().getContentTypeFor(fileName);
- }
-
- /** {@inheritDoc} */
- public void onEvent(IEvent<?> event)
- {
- }
-
- /**
* Sets an {@link IHeaderResponseDecorator} that you want your application to use to decorate
* header responses.
*
* @param headerResponseDecorator
* your custom decorator
*/
- public void setHeaderResponseDecorator(IHeaderResponseDecorator headerResponseDecorator)
+ public void setHeaderResponseDecorator(final IHeaderResponseDecorator headerResponseDecorator)
{
this.headerResponseDecorator = headerResponseDecorator;
}
@@ -1357,10 +1530,12 @@ public abstract class Application implem
* the response Wicket created
* @return the response Wicket should use in IHeaderContributor traversal
*/
- public final IHeaderResponse decorateHeaderResponse(IHeaderResponse response)
+ public final IHeaderResponse decorateHeaderResponse(final IHeaderResponse response)
{
- IHeaderResponse hr = headerResponseDecorator == null ? response
- : headerResponseDecorator.decorate(response);
- return hr;
+ if (headerResponseDecorator == null)
+ {
+ return response;
+ }
+ return headerResponseDecorator.decorate(response);
}
}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultMapperContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultMapperContext.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultMapperContext.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/DefaultMapperContext.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket;
+
+import org.apache.wicket.markup.MarkupParser;
+import org.apache.wicket.request.component.IRequestablePage;
+import org.apache.wicket.request.mapper.IMapperContext;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.request.resource.ResourceReferenceRegistry;
+
+/**
+ * Wicket's default implementation for the mapper context
+ */
+public class DefaultMapperContext implements IMapperContext
+{
+ /**
+ * @see org.apache.wicket.request.mapper.IMapperContext#getBookmarkableIdentifier()
+ */
+ public String getBookmarkableIdentifier()
+ {
+ return "bookmarkable";
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#getNamespace()
+ */
+ public String getNamespace()
+ {
+ return MarkupParser.WICKET;
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#getPageIdentifier()
+ */
+ public String getPageIdentifier()
+ {
+ return "page";
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#getResourceIdentifier()
+ */
+ public String getResourceIdentifier()
+ {
+ return "resource";
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#getResourceReferenceRegistry()
+ */
+ public ResourceReferenceRegistry getResourceReferenceRegistry()
+ {
+ return Application.get().getResourceReferenceRegistry();
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#requestListenerInterfaceFromString(java.lang.String)
+ */
+ public RequestListenerInterface requestListenerInterfaceFromString(final String interfaceName)
+ {
+ return RequestListenerInterface.forName(interfaceName);
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#requestListenerInterfaceToString(org.apache.wicket.RequestListenerInterface)
+ */
+ public String requestListenerInterfaceToString(final RequestListenerInterface listenerInterface)
+ {
+ return listenerInterface.getName();
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IPageSource#newPageInstance(java.lang.Class,
+ * org.apache.wicket.request.mapper.parameter.PageParameters)
+ */
+ public IRequestablePage newPageInstance(final Class<? extends IRequestablePage> pageClass,
+ final PageParameters pageParameters)
+ {
+ if (pageParameters == null)
+ {
+ return Application.get().getPageFactory().newPage(pageClass);
+ }
+ else
+ {
+ return Application.get().getPageFactory().newPage(pageClass, pageParameters);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IPageSource#getPageInstance(int)
+ */
+ public IRequestablePage getPageInstance(final int pageId)
+ {
+ return Page.getPage(pageId);
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.request.mapper.IMapperContext#getHomePageClass()
+ */
+ public Class<? extends IRequestablePage> getHomePageClass()
+ {
+ return Application.get().getHomePage();
+ }
+}
\ No newline at end of file
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IApplicationSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IApplicationSettings.java?rev=1037272&r1=1037271&r2=1037272&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IApplicationSettings.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IApplicationSettings.java Sat Nov 20 17:12:11 2010
@@ -80,12 +80,10 @@ public interface IApplicationSettings
/**
* Sets the access denied page class. The class must be bookmarkable and must extend Page.
*
- * @param <C>
- *
* @param accessDeniedPage
* The accessDeniedPage to set.
*/
- <C extends Page> void setAccessDeniedPage(final Class<C> accessDeniedPage);
+ void setAccessDeniedPage(final Class<? extends Page> accessDeniedPage);
/**
* Sets the default class resolver to use when finding classes and resources
@@ -107,20 +105,16 @@ public interface IApplicationSettings
/**
* Sets internal error page class. The class must be bookmarkable and must extend Page.
*
- * @param <C>
- *
* @param internalErrorPage
* The internalErrorPage to set.
*/
- <C extends Page> void setInternalErrorPage(final Class<C> internalErrorPage);
+ void setInternalErrorPage(final Class<? extends Page> internalErrorPage);
/**
* Sets the page expired page class. The class must be bookmarkable and must extend Page.
*
- * @param <C>
- *
* @param pageExpiredErrorPage
* The pageExpiredErrorPage to set.
*/
- <C extends Page> void setPageExpiredErrorPage(final Class<C> pageExpiredErrorPage);
+ void setPageExpiredErrorPage(final Class<? extends Page> pageExpiredErrorPage);
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java?rev=1037272&r1=1037271&r2=1037272&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IResourceSettings.java Sat Nov 20 17:12:11 2010
@@ -94,35 +94,11 @@ public interface IResourceSettings
void addResourceFolder(final String resourceFolder);
/**
- * Add a string resource loader to the chain of loaders.
- *
- * @see #addStringResourceLoader(int, IStringResourceLoader)
- * @see #getStringResourceLoaders()
- *
- * @param loader
- * The loader to be added
- */
- void addStringResourceLoader(final IStringResourceLoader loader);
-
- /**
- * Add a string resource loader to the chain of loaders.
- *
- * @see #addStringResourceLoader(IStringResourceLoader)
- * @see #getStringResourceLoaders()
- *
- * @param index
- * The position within the array to insert the loader
- * @param loader
- * The loader to be added
- */
- void addStringResourceLoader(final int index, final IStringResourceLoader loader);
-
- /**
* Get the the default cache duration for resources.
* <p/>
- *
+ *
* @return cache duration (Duration.NONE will be returned if caching is disabled)
- *
+ *
* @see org.apache.wicket.util.time.Duration#NONE
*/
Duration getDefaultCacheDuration();
@@ -199,7 +175,7 @@ public interface IResourceSettings
* @see #addStringResourceLoader(IStringResourceLoader)
* @see #addStringResourceLoader(int, IStringResourceLoader)
*
- * @return an unmodifiable list of all available string resource loaders
+ * @return list of all available string resource loaders
*/
List<IStringResourceLoader> getStringResourceLoaders();
@@ -216,11 +192,12 @@ public interface IResourceSettings
/**
* Set the the default cache duration for resources.
* <p/>
- * Based on RFC-2616 this should not exceed one year. If you set Duration.NONE caching will be disabled.
- *
+ * Based on RFC-2616 this should not exceed one year. If you set Duration.NONE caching will be
+ * disabled.
+ *
* @param defaultDuration
* default cache duration in seconds
- *
+ *
* @see org.apache.wicket.util.time.Duration#NONE
* @see org.apache.wicket.request.http.WebResponse#MAX_CACHE_DURATION
*/
@@ -345,8 +322,8 @@ public interface IResourceSettings
* Wicket-1992). In case you really need it, a good value for placeholder would e.g. be "$up$".
* Resources additionally are protected by a
* {@link org.apache.wicket.markup.html.IPackageResourceGuard IPackageResourceGuard}
- * implementation such as {@link org.apache.wicket.markup.html.PackageResourceGuard}
- * which you may use or extend based on your needs.
+ * implementation such as {@link org.apache.wicket.markup.html.PackageResourceGuard} which you
+ * may use or extend based on your needs.
*
* @see #getParentFolderPlaceholder()
*
@@ -358,23 +335,24 @@ public interface IResourceSettings
/**
* Control the usage of timestamps on resources
* <p/>
- * Normally the resource names won't change when the resource ifself changes, for example when you add a new
- * style to your CSS sheet. This can be very annoying as browsers (and proxies) usally cache resources
- * in their cache based on the filename and therefore won't update. Unless you change the file name of the
- * resource, force a reload or clear the browser's cache the page will still render with your old CSS.
+ * Normally the resource names won't change when the resource ifself changes, for example when
+ * you add a new style to your CSS sheet. This can be very annoying as browsers (and proxies)
+ * usally cache resources in their cache based on the filename and therefore won't update.
+ * Unless you change the file name of the resource, force a reload or clear the browser's cache
+ * the page will still render with your old CSS.
* <p/>
* Depending on HTTP response headers like 'Last-Modified' and 'Cache' automatic cache
* invalidation can take very, very long or neven happen at all.
* <p/>
* Enabling timestamps on resources will inject the last modification time of the resource into
- * the filename (the name will look something like 'style-ts1282915831000.css' where the large number is
- * the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts with
- * filenames that already contain a number before their extension.
- * *
+ * the filename (the name will look something like 'style-ts1282915831000.css' where the large
+ * number is the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts
+ * with filenames that already contain a number before their extension. *
* <p/>
- * Since browsers and proxies use the filename of the resource as a cache key the changed filename will
- * not hit the cache and the page gets rendered with the changed file.
+ * Since browsers and proxies use the filename of the resource as a cache key the changed
+ * filename will not hit the cache and the page gets rendered with the changed file.
* <p/>
+ *
* @return <code>true</code> if timestamps are enabled
*/
boolean getUseTimestampOnResources();
@@ -382,25 +360,26 @@ public interface IResourceSettings
/**
* Control the usage of timestamps on resources
* <p/>
- * Normally the resource names won't change when the resource ifself changes, for example when you add a new
- * style to your CSS sheet. This can be very annoying as browsers (and proxies) usally cache resources
- * in their cache based on the filename and therefore won't update. Unless you change the file name of the
- * resource, force a reload or clear the browser's cache the page will still render with your old CSS.
+ * Normally the resource names won't change when the resource ifself changes, for example when
+ * you add a new style to your CSS sheet. This can be very annoying as browsers (and proxies)
+ * usally cache resources in their cache based on the filename and therefore won't update.
+ * Unless you change the file name of the resource, force a reload or clear the browser's cache
+ * the page will still render with your old CSS.
* <p/>
* Depending on HTTP response headers like 'Last-Modified' and 'Cache' automatic cache
* invalidation can take very, very long or neven happen at all.
* <p/>
* Enabling timestamps on resources will inject the last modification time of the resource into
- * the filename (the name will look something like 'style-ts1282915831000.css' where the large number is
- * the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts with
- * filenames that already contain a number before their extension.
- * *
+ * the filename (the name will look something like 'style-ts1282915831000.css' where the large
+ * number is the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts
+ * with filenames that already contain a number before their extension. *
* <p/>
- * Since browsers and proxies use the filename of the resource as a cache key the changed filename will
- * not hit the cache and the page gets rendered with the changed file.
+ * Since browsers and proxies use the filename of the resource as a cache key the changed
+ * filename will not hit the cache and the page gets rendered with the changed file.
* <p/>
- *
- * @param enable <code>true</code> for using timestamps on resource names
+ *
+ * @param enable
+ * <code>true</code> for using timestamps on resource names
*/
void setUseTimestampOnResources(boolean enable);
}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultApplicationSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultApplicationSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultApplicationSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultApplicationSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.application.DefaultClassResolver;
+import org.apache.wicket.application.IClassResolver;
+import org.apache.wicket.settings.IApplicationSettings;
+import org.apache.wicket.util.lang.Bytes;
+
+/**
+ *
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultApplicationSettings implements IApplicationSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ private WeakReference<Class<? extends Page>> accessDeniedPage;
+
+ private IClassResolver classResolver = new DefaultClassResolver();
+
+ private WeakReference<Class<? extends Page>> internalErrorPage;
+
+ private WeakReference<Class<? extends Page>> pageExpiredErrorPage;
+
+ private Bytes defaultMaximumUploadSize = Bytes.MAX;
+
+// ****************************************************************************
+// IApplicationSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#getAccessDeniedPage()
+ */
+ public Class<? extends Page> getAccessDeniedPage()
+ {
+ return accessDeniedPage.get();
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#getClassResolver()
+ */
+ public IClassResolver getClassResolver()
+ {
+ return classResolver;
+ }
+
+ public Bytes getDefaultMaximumUploadSize()
+ {
+ return defaultMaximumUploadSize;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#getInternalErrorPage()
+ */
+ public Class<? extends Page> getInternalErrorPage()
+ {
+ return internalErrorPage.get();
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#getPageExpiredErrorPage()
+ */
+ public Class<? extends Page> getPageExpiredErrorPage()
+ {
+ return pageExpiredErrorPage.get();
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#setAccessDeniedPage(java.lang.Class)
+ */
+ public void setAccessDeniedPage(Class<? extends Page> accessDeniedPage)
+ {
+ if (accessDeniedPage == null)
+ {
+ throw new IllegalArgumentException("Argument accessDeniedPage may not be null");
+ }
+ checkPageClass(accessDeniedPage);
+
+ this.accessDeniedPage = new WeakReference<Class<? extends Page>>(accessDeniedPage);
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#setClassResolver(org.apache.wicket.application.IClassResolver)
+ */
+ public void setClassResolver(final IClassResolver defaultClassResolver)
+ {
+ classResolver = defaultClassResolver;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#setDefaultMaximumUploadSize(org.apache.wicket.util.lang.Bytes)
+ */
+ public void setDefaultMaximumUploadSize(Bytes defaultMaximumUploadSize)
+ {
+ this.defaultMaximumUploadSize = defaultMaximumUploadSize;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#setInternalErrorPage(java.lang.Class)
+ */
+ public void setInternalErrorPage(final Class<? extends Page> internalErrorPage)
+ {
+ if (internalErrorPage == null)
+ {
+ throw new IllegalArgumentException("Argument internalErrorPage may not be null");
+ }
+ checkPageClass(internalErrorPage);
+
+ this.internalErrorPage = new WeakReference<Class<? extends Page>>(internalErrorPage);
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IApplicationSettings#setPageExpiredErrorPage(java.lang.Class)
+ */
+ public void setPageExpiredErrorPage(final Class<? extends Page> pageExpiredErrorPage)
+ {
+ if (pageExpiredErrorPage == null)
+ {
+ throw new IllegalArgumentException("Argument pageExpiredErrorPage may not be null");
+ }
+ checkPageClass(pageExpiredErrorPage);
+
+ this.pageExpiredErrorPage = new WeakReference<Class<? extends Page>>(pageExpiredErrorPage);
+ }
+
+// ****************************************************************************
+// Other Methods
+// ****************************************************************************
+
+ /**
+ * Throws an IllegalArgumentException if the given class is not a subclass of Page.
+ *
+ * @param <C>
+ * @param pageClass
+ * the page class to check
+ */
+ private <C extends Page> void checkPageClass(final Class<C> pageClass)
+ {
+ // NOTE: we can't really check on whether it is a bookmarkable page
+ // here, as - though the default is that a bookmarkable page must
+ // either have a default constructor and/or a constructor with a
+ // PageParameters object, this could be different for another
+ // IPageFactory implementation
+ if (!Page.class.isAssignableFrom(pageClass))
+ {
+ throw new IllegalArgumentException("argument " + pageClass +
+ " must be a subclass of Page");
+ }
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultDebugSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultDebugSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultDebugSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultDebugSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import org.apache.wicket.settings.IDebugSettings;
+
+/**
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultDebugSettings implements IDebugSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ /** ajax debug mode status */
+ private boolean ajaxDebugModeEnabled = false;
+
+ /** True to check that each component on a page is used */
+ private boolean componentUseCheck = true;
+
+ /**
+ * whether wicket should track line precise additions of components for error reporting.
+ */
+ private boolean linePreciseReportingOnAddComponentEnabled = false;
+
+ /**
+ * whether wicket should track line precise instantiations of components for error reporting.
+ */
+ private boolean linePreciseReportingOnNewComponentEnabled = false;
+
+ /**
+ * Whether the container's class name should be printed to response (in a html comment).
+ */
+ private boolean outputMarkupContainerClassName = false;
+
+ /** @see IDebugSettings#setOutputComponentPath(boolean) */
+ private boolean outputComponentPath = false;
+
+ /** @see IDebugSettings#setDevelopmentUtilitiesEnabled(boolean) */
+ private boolean developmentUtilitiesEnabled = false;
+
+// ****************************************************************************
+// IDebugSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#getComponentUseCheck()
+ */
+ public boolean getComponentUseCheck()
+ {
+ return componentUseCheck;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#isAjaxDebugModeEnabled()
+ */
+ public boolean isAjaxDebugModeEnabled()
+ {
+ return ajaxDebugModeEnabled;
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.settings.IDebugSettings#isLinePreciseReportingOnAddComponentEnabled()
+ */
+ public boolean isLinePreciseReportingOnAddComponentEnabled()
+ {
+ return linePreciseReportingOnAddComponentEnabled;
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.settings.IDebugSettings#isLinePreciseReportingOnNewComponentEnabled()
+ */
+ public boolean isLinePreciseReportingOnNewComponentEnabled()
+ {
+ return linePreciseReportingOnNewComponentEnabled;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#isOutputMarkupContainerClassName()
+ */
+ public boolean isOutputMarkupContainerClassName()
+ {
+ return outputMarkupContainerClassName;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#setAjaxDebugModeEnabled(boolean)
+ */
+ public void setAjaxDebugModeEnabled(boolean enable)
+ {
+ ajaxDebugModeEnabled = enable;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#setComponentUseCheck(boolean)
+ */
+ public void setComponentUseCheck(final boolean componentUseCheck)
+ {
+ this.componentUseCheck = componentUseCheck;
+ }
+
+ public void setLinePreciseReportingOnAddComponentEnabled(boolean enable)
+ {
+ linePreciseReportingOnAddComponentEnabled = enable;
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.settings.IDebugSettings#setLinePreciseReportingOnNewComponentEnabled(boolean)
+ */
+ public void setLinePreciseReportingOnNewComponentEnabled(boolean enable)
+ {
+ linePreciseReportingOnNewComponentEnabled = enable;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#setOutputMarkupContainerClassName(boolean)
+ */
+ public void setOutputMarkupContainerClassName(boolean enable)
+ {
+ outputMarkupContainerClassName = enable;
+ }
+
+ /** @see IDebugSettings#isOutputComponentPath() */
+ public boolean isOutputComponentPath()
+ {
+ return outputComponentPath;
+ }
+
+ /** @see IDebugSettings#setOutputComponentPath(boolean) */
+ public void setOutputComponentPath(boolean outputComponentPath)
+ {
+ this.outputComponentPath = outputComponentPath;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#setDevelopmentUtilitiesEnabled(boolean)
+ */
+ public void setDevelopmentUtilitiesEnabled(boolean enable)
+ {
+ developmentUtilitiesEnabled = enable;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IDebugSettings#isDevelopmentUtilitiesEnabled()
+ */
+ public boolean isDevelopmentUtilitiesEnabled()
+ {
+ return developmentUtilitiesEnabled;
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultExceptionSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultExceptionSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultExceptionSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultExceptionSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import org.apache.wicket.settings.IExceptionSettings;
+
+/**
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultExceptionSettings implements IExceptionSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ /** Type of handling for unexpected exceptions */
+ private UnexpectedExceptionDisplay unexpectedExceptionDisplay = SHOW_EXCEPTION_PAGE;
+
+ private AjaxErrorStrategy errorHandlingStrategyDuringAjaxRequests = AjaxErrorStrategy.REDIRECT_TO_ERROR_PAGE;
+
+// ****************************************************************************
+// IExceptionSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IRequestCycleSettings#getUnexpectedExceptionDisplay()
+ */
+ public UnexpectedExceptionDisplay getUnexpectedExceptionDisplay()
+ {
+ return unexpectedExceptionDisplay;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IRequestCycleSettings#setUnexpectedExceptionDisplay(org.apache.wicket.settings.Settings.UnexpectedExceptionDisplay)
+ */
+ public void setUnexpectedExceptionDisplay(UnexpectedExceptionDisplay unexpectedExceptionDisplay)
+ {
+ this.unexpectedExceptionDisplay = unexpectedExceptionDisplay;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IExceptionSettings#getAjaxErrorHandlingStrategy()
+ */
+ public AjaxErrorStrategy getAjaxErrorHandlingStrategy()
+ {
+ return errorHandlingStrategyDuringAjaxRequests;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IExceptionSettings#setAjaxErrorHandlingStrategy(org.apache.wicket.settings.IExceptionSettings.AjaxErrorStrategy)
+ */
+ public void setAjaxErrorHandlingStrategy(
+ AjaxErrorStrategy errorHandlingStrategyDuringAjaxRequests)
+ {
+ this.errorHandlingStrategyDuringAjaxRequests = errorHandlingStrategyDuringAjaxRequests;
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultFrameworkSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultFrameworkSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultFrameworkSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultFrameworkSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import org.apache.wicket.IDetachListener;
+import org.apache.wicket.settings.IFrameworkSettings;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultFrameworkSettings implements IFrameworkSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ private IDetachListener detachListener;
+
+// ****************************************************************************
+// IFrameworkSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IFrameworkSettings#getVersion()
+ */
+ public String getVersion()
+ {
+ String implVersion = null;
+ Package pkg = getClass().getPackage();
+ if (pkg != null)
+ {
+ implVersion = pkg.getImplementationVersion();
+ }
+ return Strings.isEmpty(implVersion) ? "n/a" : implVersion;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IFrameworkSettings#getDetachListener()
+ */
+ public IDetachListener getDetachListener()
+ {
+ return detachListener;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IFrameworkSettings#setDetachListener(org.apache.wicket.IDetachListener)
+ */
+ public void setDetachListener(IDetachListener detachListener)
+ {
+ this.detachListener = detachListener;
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultMarkupSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultMarkupSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultMarkupSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultMarkupSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.markup.MarkupFactory;
+import org.apache.wicket.settings.IMarkupSettings;
+import org.apache.wicket.util.lang.Args;
+
+/**
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultMarkupSettings implements IMarkupSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ /** The application */
+ private final Application application;
+
+ /** Application default for automatically resolving hrefs */
+ private boolean automaticLinking = false;
+
+ /** True if multiple tabs/spaces should be compressed to a single space */
+ private boolean compressWhitespace = false;
+
+ /** Default markup for after a disabled link */
+ private String defaultAfterDisabledLink = "</em>";
+
+ /** Default markup for before a disabled link */
+ private String defaultBeforeDisabledLink = "<em>";
+
+ /** Default markup encoding. If null, the OS default will be used */
+ private String defaultMarkupEncoding;
+
+ /** Factory for creating markup parsers */
+ private MarkupFactory markupFactory;
+
+ /** if true than throw an exception if the xml declaration is missing from the markup file */
+ private boolean throwExceptionOnMissingXmlDeclaration = false;
+
+ /** Should HTML comments be stripped during rendering? */
+ private boolean stripComments = false;
+
+ /**
+ * If true, wicket tags ( <wicket: ..>) and wicket:id attributes we be removed from output
+ */
+ private boolean stripWicketTags = false;
+
+ /** In order to remove <?xml?> from output as required by IE quirks mode */
+ private boolean stripXmlDeclarationFromOutput;
+
+// ****************************************************************************
+// Constructors
+// ****************************************************************************
+
+ /**
+ * Construct
+ *
+ * @param application
+ */
+ public DefaultMarkupSettings(Application application)
+ {
+ this.application = application;
+ }
+
+// ****************************************************************************
+// IMarkupSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getAutomaticLinking()
+ */
+ public boolean getAutomaticLinking()
+ {
+ return automaticLinking;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getCompressWhitespace()
+ */
+ public boolean getCompressWhitespace()
+ {
+ return compressWhitespace;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getDefaultAfterDisabledLink()
+ */
+ public String getDefaultAfterDisabledLink()
+ {
+ return defaultAfterDisabledLink;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getDefaultBeforeDisabledLink()
+ */
+ public String getDefaultBeforeDisabledLink()
+ {
+ return defaultBeforeDisabledLink;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getDefaultMarkupEncoding()
+ */
+ public String getDefaultMarkupEncoding()
+ {
+ return defaultMarkupEncoding;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getMarkupFactory()
+ */
+ public MarkupFactory getMarkupFactory()
+ {
+ if (markupFactory == null)
+ {
+ markupFactory = new MarkupFactory();
+ }
+ return markupFactory;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getStripComments()
+ */
+ public boolean getStripComments()
+ {
+ return stripComments;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getStripWicketTags()
+ */
+ public boolean getStripWicketTags()
+ {
+ return stripWicketTags;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getStripXmlDeclarationFromOutput()
+ */
+ public boolean getStripXmlDeclarationFromOutput()
+ {
+ return stripXmlDeclarationFromOutput;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getThrowExceptionOnMissingXmlDeclaration()
+ */
+ public boolean getThrowExceptionOnMissingXmlDeclaration()
+ {
+ return throwExceptionOnMissingXmlDeclaration;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setAutomaticLinking(boolean)
+ */
+ public void setAutomaticLinking(boolean automaticLinking)
+ {
+ this.automaticLinking = automaticLinking;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setCompressWhitespace(boolean)
+ */
+ public void setCompressWhitespace(final boolean compressWhitespace)
+ {
+ this.compressWhitespace = compressWhitespace;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setDefaultAfterDisabledLink(java.lang.String)
+ */
+ public void setDefaultAfterDisabledLink(final String defaultAfterDisabledLink)
+ {
+ this.defaultAfterDisabledLink = defaultAfterDisabledLink;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setDefaultBeforeDisabledLink(java.lang.String)
+ */
+ public void setDefaultBeforeDisabledLink(String defaultBeforeDisabledLink)
+ {
+ this.defaultBeforeDisabledLink = defaultBeforeDisabledLink;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setDefaultMarkupEncoding(java.lang.String)
+ */
+ public void setDefaultMarkupEncoding(final String encoding)
+ {
+ defaultMarkupEncoding = encoding;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setMarkupFactory(org.apache.wicket.markup.MarkupFactory)
+ */
+ public void setMarkupFactory(final MarkupFactory factory)
+ {
+ Args.notNull(factory, "markup factory");
+ markupFactory = factory;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setStripComments(boolean)
+ */
+ public void setStripComments(boolean stripComments)
+ {
+ this.stripComments = stripComments;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setStripWicketTags(boolean)
+ */
+ public void setStripWicketTags(boolean stripWicketTags)
+ {
+ this.stripWicketTags = stripWicketTags;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setStripXmlDeclarationFromOutput(boolean)
+ */
+ public void setStripXmlDeclarationFromOutput(final boolean strip)
+ {
+ stripXmlDeclarationFromOutput = strip;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#setThrowExceptionOnMissingXmlDeclaration(boolean)
+ */
+ public void setThrowExceptionOnMissingXmlDeclaration(boolean throwException)
+ {
+ throwExceptionOnMissingXmlDeclaration = throwException;
+ }
+}
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultPageSettings.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultPageSettings.java?rev=1037272&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultPageSettings.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/def/DefaultPageSettings.java Sat Nov 20 17:12:11 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.settings.def;
+
+import java.util.List;
+
+import org.apache.wicket.markup.resolver.IComponentResolver;
+import org.apache.wicket.settings.IPageSettings;
+import org.apache.wicket.util.lang.Generics;
+
+/**
+ * @author Jonathan Locke
+ * @author Chris Turner
+ * @author Eelco Hillenius
+ * @author Juergen Donnerstag
+ * @author Johan Compagner
+ * @author Igor Vaynberg (ivaynberg)
+ * @author Martijn Dashorst
+ * @author James Carman
+ */
+public class DefaultPageSettings implements IPageSettings
+{
+// ****************************************************************************
+// Fields
+// ****************************************************************************
+
+ /** List of (static) ComponentResolvers */
+ private final List<IComponentResolver> componentResolvers = Generics.newArrayList();
+
+ /** Determines if pages should be managed by a version manager by default */
+ private boolean versionPagesByDefault = true;
+
+// ****************************************************************************
+// IPageSettings Implementation
+// ****************************************************************************
+
+ /**
+ * @see org.apache.wicket.settings.IPageSettings#addComponentResolver(org.apache.wicket.markup.resolver.IComponentResolver)
+ */
+ public void addComponentResolver(IComponentResolver resolver)
+ {
+ componentResolvers.add(resolver);
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IPageSettings#getComponentResolvers()
+ */
+ public List<IComponentResolver> getComponentResolvers()
+ {
+ return componentResolvers;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IPageSettings#getVersionPagesByDefault()
+ */
+ public boolean getVersionPagesByDefault()
+ {
+ return versionPagesByDefault;
+ }
+
+ /**
+ * @see org.apache.wicket.settings.IPageSettings#setVersionPagesByDefault(boolean)
+ */
+ public void setVersionPagesByDefault(boolean pagesVersionedByDefault)
+ {
+ versionPagesByDefault = pagesVersionedByDefault;
+ }
+}