Author: jdonnerstag
Date: Fri Feb 12 20:48:01 2010
New Revision: 909601
URL: http://svn.apache.org/viewvc?rev=909601&view=rev
Log:
wip MarkupFactory
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFactory.java
Removed:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupParserFactory.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParserFactory.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/IMarkupLoader.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/SimpleMarkupLoader.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IMarkupSettings.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.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=909601&r1=909600&r2=909601&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 Fri
Feb 12 20:48:01 2010
@@ -33,6 +33,7 @@
import org.apache.wicket.application.IComponentOnAfterRenderListener;
import org.apache.wicket.application.IComponentOnBeforeRenderListener;
import org.apache.wicket.javascript.DefaultJavascriptCompressor;
+import org.apache.wicket.markup.MarkupCache;
import org.apache.wicket.markup.html.EmptySrcAttributeCheckFilter;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.IHeaderResponse;
@@ -431,8 +432,6 @@
* PROCESS, THEREFORE THE IMPLEMENTATION SHOULD BE FAST - PREFERRABLY
USING A FAST-TO-RETRIEVE
* CACHED VALUE
*
- *
- *
* @return configuration
* @since 1.2.3 (function existed as a property getter)
* @since 1.3.0 (abstract, used to configure things)
@@ -862,7 +861,7 @@
// Clear caches of Class keys so the classloader can be garbage
// collected (WICKET-625)
PropertyResolver.destroy(this);
- getMarkupSettings().getMarkupCache().shutdown();
+ MarkupCache.get().shutdown();
onDestroy();
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
Fri Feb 12 20:48:01 2010
@@ -28,12 +28,12 @@
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupElement;
import org.apache.wicket.markup.MarkupException;
+import org.apache.wicket.markup.MarkupFactory;
import org.apache.wicket.markup.MarkupNotFoundException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.MarkupType;
import org.apache.wicket.markup.RawMarkup;
import org.apache.wicket.markup.WicketTag;
-import org.apache.wicket.markup.html.HeaderPartContainer;
import org.apache.wicket.markup.resolver.ComponentResolvers;
import org.apache.wicket.model.IComponentInheritedModel;
import org.apache.wicket.model.IModel;
@@ -43,7 +43,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* A MarkupContainer holds a map of child components.
* <ul>
@@ -387,9 +386,7 @@
{
try
{
- IMarkupFragment markup =
getApplication().getMarkupSettings()
- .getMarkupCache()
- .getMarkup(this, false);
+ IMarkupFragment markup =
MarkupFactory.get().getMarkup(this, false);
// If we found markup for this container
if ((markup != null) && (markup != Markup.NO_MARKUP))
@@ -1806,7 +1803,7 @@
*/
public boolean hasAssociatedMarkup()
{
- return
getApplication().getMarkupSettings().getMarkupCache().hasAssociatedMarkup(this);
+ return MarkupFactory.get().hasAssociatedMarkup(this);
}
/**
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
Fri Feb 12 20:48:01 2010
@@ -51,29 +51,6 @@
final boolean enforceReload);
/**
- * Gets a fresh markup stream that contains the (immutable) markup
resource for this class.
- *
- * @param container
- * The container the markup should be associated with
- * @param enforceReload
- * The cache will be ignored and all, including inherited
markup files, will be
- * reloaded. Whatever is in the cache, it will be ignored
- * @param throwException
- * If true, throw an exception, if markup could not be found
- * @return A stream of MarkupElement elements
- */
- IMarkupFragment getMarkup(final MarkupContainer container, final
boolean enforceReload);
-
- /**
- * Check if container has associated markup
- *
- * @param container
- * The container the markup should be associated with
- * @return True if this markup container has associated markup
- */
- boolean hasAssociatedMarkup(final MarkupContainer container);
-
- /**
* Remove the markup associated with the cache key from the cache
including all dependent
* markups (markup inheritance)
*
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
Fri Feb 12 20:48:01 2010
@@ -16,7 +16,6 @@
*/
package org.apache.wicket.markup;
-import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
@@ -24,12 +23,8 @@
import org.apache.wicket.Application;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.markup.loader.DefaultMarkupLoader;
-import org.apache.wicket.markup.loader.IMarkupLoader;
import org.apache.wicket.settings.IMarkupSettings;
import org.apache.wicket.util.listener.IChangeListener;
-import org.apache.wicket.util.resource.IResourceStream;
-import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.watch.IModifiable;
import org.apache.wicket.util.watch.IModificationWatcher;
import org.apache.wicket.util.watch.ModificationWatcher;
@@ -65,18 +60,20 @@
/** The markup cache key provider used by MarkupCache */
private IMarkupCacheKeyProvider markupCacheKeyProvider;
- /** The markup resource stream provider used by MarkupCache */
- private IMarkupResourceStreamProvider markupResourceStreamProvider;
-
- /** The markup loader used by MarkupCache */
- private IMarkupLoader markupLoader;
+ /**
+ * @return The markup cache associated with the application
+ */
+ public final static IMarkupCache get()
+ {
+ return
Application.get().getMarkupSettings().getMarkupFactory().getMarkupCache();
+ }
/**
* Constructor.
*
* @param application
*/
- public MarkupCache()
+ protected MarkupCache()
{
markupCache = newCacheImplementation();
markupKeyCache = newCacheImplementation();
@@ -197,30 +194,6 @@
}
/**
- * @see
org.apache.wicket.markup.IMarkupCache#getMarkup(org.apache.wicket.MarkupContainer,
- * boolean)
- */
- public final IMarkupFragment getMarkup(final MarkupContainer container,
- final boolean enforceReload)
- {
- if (container == null)
- {
- throw new IllegalArgumentException("Parameter
'container' must not be 'null'.");
- }
-
- // Look for associated markup
- return getMarkup(container, container.getClass(),
enforceReload);
- }
-
- /**
- * @see
org.apache.wicket.markup.IMarkupCache#hasAssociatedMarkup(org.apache.wicket.MarkupContainer)
- */
- public final boolean hasAssociatedMarkup(final MarkupContainer
container)
- {
- return getMarkup(container, container.getClass(), false) !=
Markup.NO_MARKUP;
- }
-
- /**
* @see org.apache.wicket.markup.IMarkupCache#size()
*/
public final int size()
@@ -277,28 +250,16 @@
// Who is going to provide the markup resource stream?
// And ask the provider to locate the markup resource
stream
- final IResourceStream resourceStream =
getMarkupResourceStreamProvider(container).getMarkupResourceStream(
- container, containerClass);
+ final MarkupResourceStream resourceStream =
MarkupFactory.get()
+ .getMarkupResourceStream(container,
containerClass);
// Found markup?
if (resourceStream != null)
{
- final MarkupResourceStream markupResourceStream;
- if (resourceStream instanceof
MarkupResourceStream)
- {
- markupResourceStream =
(MarkupResourceStream)resourceStream;
- }
- else
- {
- markupResourceStream = new
MarkupResourceStream(resourceStream,
- new ContainerInfo(container),
containerClass);
- }
-
- markupResourceStream.setCacheKey(cacheKey);
+ resourceStream.setCacheKey(cacheKey);
// load the markup and watch for changes
- markup =
loadMarkupAndWatchForChanges(container, markupResourceStream,
- enforceReload);
+ markup =
loadMarkupAndWatchForChanges(container, resourceStream, enforceReload);
}
else
{
@@ -416,31 +377,24 @@
// couldn't be resolved.
locationString = cacheKey;
}
- try
- {
- Markup markup = getMarkupLoader().loadMarkup(container,
markupResourceStream, null,
- enforceReload);
+ Markup markup = MarkupFactory.get().loadMarkup(container,
markupResourceStream,
+ enforceReload);
+ if (markup != null)
+ {
if (cacheKey != null)
{
if (markup.locationAsString() != null)
{
locationString =
markup.locationAsString();
}
+
// add the markup to the cache.
markupKeyCache.put(cacheKey, locationString);
return putIntoCache(locationString, container,
markup);
}
return markup;
}
- catch (ResourceStreamNotFoundException e)
- {
- log.error("Unable to find markup from " +
markupResourceStream, e);
- }
- catch (IOException e)
- {
- log.error("Unable to read markup from " +
markupResourceStream, e);
- }
// In case of an error, remove the cache entry
if (cacheKey != null)
@@ -538,42 +492,6 @@
}
/**
- * Get the markup resource stream provider to be used
- *
- * @param container
- * The MarkupContainer requesting the markup resource stream
- * @return IMarkupResourceStreamProvider
- */
- protected IMarkupResourceStreamProvider getMarkupResourceStreamProvider(
- final MarkupContainer container)
- {
- if (container instanceof IMarkupResourceStreamProvider)
- {
- return (IMarkupResourceStreamProvider)container;
- }
-
- if (markupResourceStreamProvider == null)
- {
- markupResourceStreamProvider = new
DefaultMarkupResourceStreamProvider();
- }
- return markupResourceStreamProvider;
- }
-
- /**
- * In case there is a need to extend the default chain of MarkupLoaders
- *
- * @return MarkupLoader
- */
- protected IMarkupLoader getMarkupLoader()
- {
- if (markupLoader == null)
- {
- markupLoader = new DefaultMarkupLoader();
- }
- return markupLoader;
- }
-
- /**
* Allows you to change the map implementation which will hold the
cache data. By default it is
* a ConcurrentHashMap() in order to allow multiple thread to access
the data in a secure way.
*
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFactory.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFactory.java?rev=909601&view=auto
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFactory.java
(added)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFactory.java
Fri Feb 12 20:48:01 2010
@@ -0,0 +1,261 @@
+/*
+ * 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.markup;
+
+import java.io.IOException;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.markup.loader.DefaultMarkupLoader;
+import org.apache.wicket.markup.loader.IMarkupLoader;
+import org.apache.wicket.markup.parser.XmlPullParser;
+import org.apache.wicket.util.lang.Checks;
+import org.apache.wicket.util.resource.IResourceStream;
+import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Markup loading essentially is an autark modul of Wicket. MarkupFactory
provides all the means to
+ * change defaults.
+ *
+ * @author Juergen Donnerstag
+ */
+public class MarkupFactory
+{
+ /** Log for reporting. */
+ private static final Logger log =
LoggerFactory.getLogger(MarkupFactory.class);
+
+ /** The markup loader instance */
+ private IMarkupLoader markupLoader;
+
+ /** A markup cache which will load the markup if required. */
+ private IMarkupCache markupCache;
+
+ /** The markup resource stream provider used by MarkupCache */
+ private IMarkupResourceStreamProvider markupResourceStreamProvider;
+
+ /**
+ * @return The markup factory associated with the application
+ */
+ public final static MarkupFactory get()
+ {
+ return Application.get().getMarkupSettings().getMarkupFactory();
+ }
+
+ /**
+ * Construct.
+ */
+ public MarkupFactory()
+ {
+ }
+
+ /**
+ * In case there is a need to extend the default chain of MarkupLoaders
+ *
+ * @return MarkupLoader
+ */
+ public IMarkupLoader getMarkupLoader()
+ {
+ if (markupLoader == null)
+ {
+ markupLoader = new DefaultMarkupLoader();
+ }
+ return markupLoader;
+ }
+
+ /**
+ * @param resource
+ * @return A new markup parser
+ */
+ public MarkupParser newMarkupParser(final MarkupResourceStream resource)
+ {
+ // Markup parsers can not be re-used
+ return new MarkupParser(new XmlPullParser(), resource);
+ }
+
+ /**
+ * The markup cache also loads the markup if not yet available in the
cache.
+ *
+ * @return Null, to disable caching.
+ */
+ public IMarkupCache getMarkupCache()
+ {
+ if (markupCache == null)
+ {
+ markupCache = new MarkupCache();
+ }
+
+ return markupCache;
+ }
+
+ /**
+ * Gets a fresh markup stream that contains the (immutable) markup
resource for this class.
+ *
+ * @param container
+ * The container the markup should be associated with
+ * @param enforceReload
+ * The cache will be ignored and all, including inherited
markup files, will be
+ * reloaded. Whatever is in the cache, it will be ignored
+ * @return A stream of MarkupElement elements
+ */
+ public final IMarkupFragment getMarkup(final MarkupContainer container,
+ final boolean enforceReload)
+ {
+ return getMarkup(container, container.getClass(),
enforceReload);
+ }
+
+ /**
+ * Gets a fresh markup stream that contains the (immutable) markup
resource for this class.
+ *
+ * @param container
+ * The container the markup should be associated with
+ * @param clazz
+ * Must be the container class or any of its super classes.
+ * @param enforceReload
+ * The cache will be ignored and all, including inherited
markup files, will be
+ * reloaded. Whatever is in the cache, it will be ignored
+ * @return A stream of MarkupElement elements
+ */
+ public final Markup getMarkup(final MarkupContainer container, final
Class<?> clazz,
+ final boolean enforceReload)
+ {
+ Checks.argumentNotNull(container, "container");
+ Checks.argumentNotNull(clazz, "clazz");
+ IMarkupCache cache = getMarkupCache();
+ if (cache != null)
+ {
+ return cache.getMarkup(container, clazz, enforceReload);
+ }
+
+ return loadMarkup(container, null, enforceReload);
+ }
+
+ /**
+ * Check if container has associated markup
+ *
+ * @param container
+ * The container the markup should be associated with
+ * @return True if this markup container has associated markup
+ */
+ public final boolean hasAssociatedMarkup(final MarkupContainer
container)
+ {
+ return getMarkup(container, false) != Markup.NO_MARKUP;
+ }
+
+ /**
+ * Get the markup resource stream provider to be used
+ *
+ * @param container
+ * The MarkupContainer requesting the markup resource stream
+ * @return IMarkupResourceStreamProvider
+ */
+ protected final IMarkupResourceStreamProvider
getMarkupResourceStreamProvider(
+ final MarkupContainer container)
+ {
+ if (container instanceof IMarkupResourceStreamProvider)
+ {
+ return (IMarkupResourceStreamProvider)container;
+ }
+
+ if (markupResourceStreamProvider == null)
+ {
+ markupResourceStreamProvider = new
DefaultMarkupResourceStreamProvider();
+ }
+ return markupResourceStreamProvider;
+ }
+
+ /**
+ * Create a new markup resource stream for the container.
+ * <p>
+ * Note: usually it will only called once, as the IResourceStream will
be cached by MarkupCache.
+ *
+ * @param container
+ * The MarkupContainer which requests to load the Markup
resource stream
+ * @param clazz
+ * Either the container class or any super class
+ * @return A IResourceStream if the resource was found
+ */
+ public final MarkupResourceStream getMarkupResourceStream(final
MarkupContainer container,
+ Class<?> clazz)
+ {
+ Class<?> containerClass = clazz;
+ if (clazz == null)
+ {
+ containerClass = container.getClass();
+ }
+ else if (!clazz.isAssignableFrom(container.getClass()))
+ {
+ throw new WicketRuntimeException("Parameter clazz must
be an instance of " +
+ container.getClass().getName() + ", but is a "
+ clazz.getName());
+ }
+
+ // Who is going to provide the markup resource stream?
+ // And ask the provider to locate the markup resource stream
+ final IResourceStream resourceStream =
getMarkupResourceStreamProvider(container).getMarkupResourceStream(
+ container, containerClass);
+
+ // Found markup?
+ if (resourceStream == null)
+ {
+ return null;
+ }
+ if (resourceStream instanceof MarkupResourceStream)
+ {
+ return (MarkupResourceStream)resourceStream;
+ }
+ return new MarkupResourceStream(resourceStream, new
ContainerInfo(container),
+ containerClass);
+ }
+
+ /**
+ * Loads markup from a resource stream.
+ *
+ * @param container
+ * The original requesting markup container
+ * @param markupResourceStream
+ * The markup resource stream to load. May be null.
+ * @param enforceReload
+ * The cache will be ignored and all, including inherited
markup files, will be
+ * reloaded. Whatever is in the cache, it will be ignored
+ * @return The markup
+ */
+ public final Markup loadMarkup(final MarkupContainer container,
+ MarkupResourceStream markupResourceStream, final boolean
enforceReload)
+ {
+ if (markupResourceStream == null)
+ {
+ markupResourceStream =
getMarkupResourceStream(container, null);
+ }
+
+ try
+ {
+ return getMarkupLoader().loadMarkup(container,
markupResourceStream, null,
+ enforceReload);
+ }
+ catch (ResourceStreamNotFoundException e)
+ {
+ log.error("Unable to find markup from " +
markupResourceStream, e);
+ }
+ catch (IOException e)
+ {
+ log.error("Unable to read markup from " +
markupResourceStream, e);
+ }
+ return null;
+ }
+}
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
Fri Feb 12 20:48:01 2010
@@ -28,6 +28,7 @@
import org.apache.wicket.markup.ContainerInfo;
import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupElement;
+import org.apache.wicket.markup.MarkupFactory;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.WicketTag;
@@ -218,11 +219,10 @@
try
{
- IMarkupFragment markup = Application.get()
- .getMarkupSettings()
- .getMarkupParserFactory()
+ IMarkupFragment markup = MarkupFactory.get()
.newMarkupParser(markupResourceStream)
.parse();
+
return new MarkupStream(markup);
}
catch (Exception e)
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/IMarkupLoader.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/IMarkupLoader.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/IMarkupLoader.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/IMarkupLoader.java
Fri Feb 12 20:48:01 2010
@@ -22,7 +22,6 @@
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupCache;
import org.apache.wicket.markup.MarkupParser;
-import org.apache.wicket.markup.MarkupParserFactory;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java
Fri Feb 12 20:48:01 2010
@@ -18,11 +18,11 @@
import java.io.IOException;
-import org.apache.wicket.Application;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupElement;
+import org.apache.wicket.markup.MarkupFactory;
import org.apache.wicket.markup.MarkupNotFoundException;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.markup.MergedMarkup;
@@ -119,9 +119,8 @@
final boolean enforceReload)
{
// get the base markup
- Markup baseMarkup =
Application.get().getMarkupSettings().getMarkupCache().getMarkup(
- container,
markup.getMarkupResourceStream().getMarkupClass().getSuperclass(),
- enforceReload);
+ Markup baseMarkup = MarkupFactory.get().getMarkup(container,
+
markup.getMarkupResourceStream().getMarkupClass().getSuperclass(),
enforceReload);
return baseMarkup;
}
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/SimpleMarkupLoader.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/SimpleMarkupLoader.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/SimpleMarkupLoader.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/SimpleMarkupLoader.java
Fri Feb 12 20:48:01 2010
@@ -18,9 +18,9 @@
import java.io.IOException;
-import org.apache.wicket.Application;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.Markup;
+import org.apache.wicket.markup.MarkupFactory;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
@@ -49,7 +49,6 @@
final MarkupResourceStream markupResourceStream, final
IMarkupLoader baseLoader,
final boolean enforceReload) throws IOException,
ResourceStreamNotFoundException
{
- return
Application.get().getMarkupSettings().getMarkupParserFactory().newMarkupParser(
- markupResourceStream).parse();
+ return
MarkupFactory.get().newMarkupParser(markupResourceStream).parse();
}
}
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IMarkupSettings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IMarkupSettings.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
---
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IMarkupSettings.java
(original)
+++
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IMarkupSettings.java
Fri Feb 12 20:48:01 2010
@@ -16,9 +16,7 @@
*/
package org.apache.wicket.settings;
-import org.apache.wicket.markup.IMarkupCache;
-import org.apache.wicket.markup.IMarkupParserFactory;
-import org.apache.wicket.markup.MarkupParserFactory;
+import org.apache.wicket.markup.MarkupFactory;
/**
* Interface for markup related settings.
@@ -67,18 +65,6 @@
String getDefaultMarkupEncoding();
/**
- * @return markup parser factory
- */
- IMarkupParserFactory getMarkupParserFactory();
-
- /**
- * The markup cache also loads the markup if not yet available in the
cache.
- *
- * @return markup cache
- */
- IMarkupCache getMarkupCache();
-
- /**
* @return Returns the stripComments.
* @see IMarkupSettings#setStripComments(boolean)
*/
@@ -155,24 +141,6 @@
void setDefaultMarkupEncoding(final String encoding);
/**
- * Sets the markup parser factory that will be used to generate parsers
for markup. By default
- * {...@link MarkupParserFactory} will be used.
- *
- * @param factory
- * new factory
- */
- void setMarkupParserFactory(IMarkupParserFactory factory);
-
- /**
- * Sets a new markup cache which will also be used to load markup if
not yet available in the
- * cache.
- *
- * @param markupCache
- * new markup cache
- */
- void setMarkupCache(IMarkupCache markupCache);
-
- /**
* Enables stripping of markup comments denoted in markup by HTML
comment tagging.
*
* @param stripComments
@@ -203,4 +171,18 @@
* @param throwException
*/
void setThrowExceptionOnMissingXmlDeclaration(final boolean
throwException);
+
+ /**
+ * Get the markup factory
+ *
+ * @return A new instance of MarkupFactory.
+ */
+ MarkupFactory getMarkupFactory();
+
+ /**
+ * Set a new markup factory
+ *
+ * @param factory
+ */
+ void setMarkupFactory(MarkupFactory factory);
}
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java?rev=909601&r1=909600&r2=909601&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/Settings.java
Fri Feb 12 20:48:01 2010
@@ -39,10 +39,7 @@
import
org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
import org.apache.wicket.authorization.UnauthorizedInstantiationException;
import org.apache.wicket.javascript.IJavascriptCompressor;
-import org.apache.wicket.markup.IMarkupCache;
-import org.apache.wicket.markup.IMarkupParserFactory;
-import org.apache.wicket.markup.MarkupCache;
-import org.apache.wicket.markup.MarkupParserFactory;
+import org.apache.wicket.markup.MarkupFactory;
import org.apache.wicket.markup.html.IPackageResourceGuard;
import org.apache.wicket.markup.html.PackageResourceGuard;
import org.apache.wicket.markup.html.pages.BrowserInfoPage;
@@ -185,12 +182,6 @@
/** I18N support */
private Localizer localizer;
- /** Factory for creating markup parsers */
- private IMarkupParserFactory markupParserFactory;
-
- /** A markup cache which will load the markup if required. */
- private IMarkupCache markupCache;
-
/** if true than throw an exception if the xml declaration is missing
from the markup file */
private boolean throwExceptionOnMissingXmlDeclaration = false;
@@ -328,6 +319,8 @@
/** Default cache duration */
private int defaultCacheDuration = 3600;
+ private MarkupFactory markupFactory;
+
/**
* Create the application settings, carrying out any necessary
initializations.
*
@@ -571,18 +564,6 @@
}
/**
- * @see
org.apache.wicket.settings.IMarkupSettings#getMarkupParserFactory()
- */
- public IMarkupParserFactory getMarkupParserFactory()
- {
- if (markupParserFactory == null)
- {
- markupParserFactory = new MarkupParserFactory();
- }
- return markupParserFactory;
- }
-
- /**
* @see org.apache.wicket.settings.ISessionSettings#getMaxPageMaps()
*/
public final int getMaxPageMaps()
@@ -971,19 +952,6 @@
}
/**
- * @see
org.apache.wicket.settings.IMarkupSettings#setMarkupParserFactory(org.apache.wicket.markup.IMarkupParserFactory)
- */
- public void setMarkupParserFactory(IMarkupParserFactory factory)
- {
- if (factory == null)
- {
- throw new IllegalArgumentException("markup parser
factory cannot be null");
- }
-
- markupParserFactory = factory;
- }
-
- /**
* @see org.apache.wicket.settings.ISessionSettings#setMaxPageMaps(int)
*/
public final void setMaxPageMaps(int maxPageMaps)
@@ -1249,28 +1217,6 @@
}
/**
- * @see org.apache.wicket.settings.IMarkupSettings#getMarkupCache()
- */
- public IMarkupCache getMarkupCache()
- {
- if (markupCache == null)
- {
- // Construct markup cache for this application
- markupCache = new MarkupCache();
- }
-
- return markupCache;
- }
-
- /**
- * @see
org.apache.wicket.settings.IMarkupSettings#setMarkupCache(org.apache.wicket.markup.IMarkupCache)
- */
- public void setMarkupCache(final IMarkupCache markupCache)
- {
- this.markupCache = markupCache;
- }
-
- /**
*
* @see
org.apache.wicket.settings.IApplicationSettings#getDefaultMaximumUploadSize()
*/
@@ -1494,4 +1440,24 @@
{
authenticationStrategy = strategy;
}
+
+ /**
+ * @see org.apache.wicket.settings.IMarkupSettings#getMarkupFactory()
+ */
+ public MarkupFactory getMarkupFactory()
+ {
+ if (markupFactory == null)
+ {
+ markupFactory = new MarkupFactory();
+ }
+ return markupFactory;
+ }
+
+ /**
+ * @see
org.apache.wicket.settings.IMarkupSettings#setMarkupFactory(org.apache.wicket.markup.MarkupFactory)
+ */
+ public void setMarkupFactory(final MarkupFactory factory)
+ {
+ markupFactory = factory;
+ }
}