Author: jdonnerstag
Date: Fri Dec  3 19:05:33 2010
New Revision: 1041955

URL: http://svn.apache.org/viewvc?rev=1041955&view=rev
Log:
transient MarkupContainer.markupStream no longer needed (because of markup 
fragments)

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProvider.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/panel/Fragment.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/handler/PageProvider.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Fri Dec  
3 19:05:33 2010
@@ -2154,7 +2154,7 @@ public abstract class Component
         *            if this is false only the PREPARED_FOR_RENDER flag is 
removed from component, the
         *            RENDERING flag is not set.
         * 
-        * @see #prepareForRender(boolean)
+        * @see #internalPrepareForRender(boolean)
         */
        public final void markRendering(boolean setRenderingFlag)
        {
@@ -2194,19 +2194,14 @@ public abstract class Component
         * <p>
         * Prepares the component and it's children for rendering. On whole 
page render this method must
         * be called on the page. On AJAX request, this method must be called 
on updated component.
-        * </p>
-        * 
-        * TODO this method is not part of public api, so rename to 
internalPrepareForRender
         * 
         * @param setRenderingFlag
         *            Whether to set the rendering flag. This must be true if 
the page is about to be
         *            rendered. However, there are usecases to call this method 
without an immediate
         *            render (e.g. on stateless listner request target to build 
the component
         *            hierarchy), in that case setRenderingFlag should be false
-        * 
-        * 
         */
-       public void prepareForRender(boolean setRenderingFlag)
+       public void internalPrepareForRender(boolean setRenderingFlag)
        {
                beforeRender();
 
@@ -2245,7 +2240,7 @@ public abstract class Component
         */
        public final void prepareForRender()
        {
-               prepareForRender(true);
+               internalPrepareForRender(true);
        }
 
        /**
@@ -2291,11 +2286,11 @@ public abstract class Component
                        MarkupContainer parent = getParent();
                        if ((parent == null) || (parent.getFlag(FLAG_RENDERING) 
== false) || isAuto())
                        {
-                               prepareForRender(true);
+                               internalPrepareForRender(true);
                        }
 
                        // Do the render
-                       render_();
+                       internalRender();
                }
                catch (final RuntimeException ex)
                {
@@ -2329,20 +2324,19 @@ public abstract class Component
        /**
         * Performs a render of this component as part of a Page level render 
process.
         */
-       private final void render_()
+       private final void internalRender()
        {
-               // Step 1: Make sure there is a markup available for the 
Component
+               // Make sure there is a markup available for the Component
                IMarkupFragment markup = getMarkup();
                if (markup == null)
                {
                        throw new MarkupNotFoundException("Markup not found for 
Component: " + toString());
                }
 
-               // Step 2: A markup stream based on the markup should yield the 
same result.
-               // We want to use the new markup stream
+               // MarkupStream is an Iterator for the markup
                MarkupStream markupStream = new MarkupStream(markup);
-               setMarkupStream(markupStream);
 
+               // Flag: we stated the render process
                markRendering(true);
 
                MarkupElement elem = markup.get(0);
@@ -3956,21 +3950,6 @@ public abstract class Component
        }
 
        /**
-        * The markup stream will be assigned to the component at the beginning 
of the component render
-        * phase. It is temporary working variable only.
-        * 
-        * @see #findMarkupStream()
-        * @see MarkupContainer#getMarkupStream()
-        * 
-        * @param markupStream
-        *            The current markup stream which should be applied by the 
component to render
-        *            itself
-        */
-       protected void setMarkupStream(final MarkupStream markupStream)
-       {
-       }
-
-       /**
         * @param <V>
         *            The model type
         * @param model

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=1041955&r1=1041954&r2=1041955&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 Dec  3 19:05:33 2010
@@ -100,12 +100,6 @@ public abstract class MarkupContainer ex
        private Object children;
 
        /**
-        * The markup stream for this container. This variable is used only 
during the render phase to
-        * provide access to the current element within the stream.
-        */
-       private transient MarkupStream markupStream;
-
-       /**
         * @see org.apache.wicket.Component#Component(String)
         */
        public MarkupContainer(final String id)
@@ -447,16 +441,6 @@ public abstract class MarkupContainer ex
        }
 
        /**
-        * Get the markup stream set on this container.
-        * 
-        * @return Returns the markup stream set on this container.
-        */
-       public final MarkupStream getMarkupStream()
-       {
-               return markupStream;
-       }
-
-       /**
         * Get the childs markup
         * 
         * @see Component#getMarkup()
@@ -691,8 +675,8 @@ public abstract class MarkupContainer ex
        }
 
        /**
-        * Renders the entire associated markup stream for a container such as 
a Border or Panel. Any
-        * leading or trailing raw markup in the associated markup is skipped.
+        * Renders the entire associated markup for a container such as a 
Border or Panel. Any leading
+        * or trailing raw markup in the associated markup is skipped.
         * 
         * @param openTagName
         *            the tag to render the associated markup for
@@ -702,11 +686,8 @@ public abstract class MarkupContainer ex
        public final void renderAssociatedMarkup(final String openTagName, 
final String exceptionMessage)
        {
                // Get markup associated with Border or Panel component
-               final MarkupStream originalMarkupStream = getMarkupStream();
                final MarkupStream associatedMarkupStream = new 
MarkupStream(getMarkup(null));
 
-               setMarkupStream(associatedMarkupStream);
-
                // Get open tag in associated markup of border component
                MarkupElement elem = associatedMarkupStream.get();
                if ((elem instanceof ComponentTag) == false)
@@ -753,7 +734,6 @@ public abstract class MarkupContainer ex
                        }
 
                        renderClosingComponentTag(associatedMarkupStream, 
associatedMarkupOpenTag, false);
-                       setMarkupStream(originalMarkupStream);
                }
                finally
                {
@@ -876,9 +856,9 @@ public abstract class MarkupContainer ex
                buffer.append(super.toString(detailed));
                if (detailed)
                {
-                       if (getMarkupStream() != null)
+                       if (getMarkup() != null)
                        {
-                               buffer.append(", markupStream = " + 
getMarkupStream());
+                               buffer.append(", markup = " + new 
MarkupStream(getMarkup()).toString());
                        }
 
                        if (children_size() != 0)
@@ -912,7 +892,7 @@ public abstract class MarkupContainer ex
         * 
         * @param <S>
         *            The type that goes into the Visitor.component() method.
-        * 
+        * @param <R>
         * @param clazz
         *            The class of child to visit, or null to visit all children
         * @param visitor
@@ -920,7 +900,6 @@ public abstract class MarkupContainer ex
         * @return The return value from a visitor which halted the traversal, 
or null if the entire
         *         traversal occurred
         */
-
        public final <S extends Component, R> R visitChildren(final Class<?> 
clazz,
                final IVisitor<S, R> visitor)
        {
@@ -931,6 +910,7 @@ public abstract class MarkupContainer ex
         * Traverses all child components in this container, calling the 
visitor's visit method at each
         * one.
         * 
+        * @param <R>
         * @param visitor
         *            The visitor to call back to
         * @return The return value from a visitor which halted the traversal, 
or null if the entire
@@ -1609,18 +1589,6 @@ public abstract class MarkupContainer ex
        }
 
        /**
-        * Set markup stream for this container.
-        * 
-        * @param markupStream
-        *            The markup stream
-        */
-       @Override
-       protected final void setMarkupStream(final MarkupStream markupStream)
-       {
-               this.markupStream = markupStream;
-       }
-
-       /**
         * 
         */
        private static class ComponentSourceEntry extends 
org.apache.wicket.ComponentSourceEntry

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java Fri Dec  3 
19:05:33 2010
@@ -377,17 +377,17 @@ public abstract class Page extends Marku
        }
 
        /**
-        * @see org.apache.wicket.Component#prepareForRender(boolean)
+        * @see org.apache.wicket.Component#internalPrepareForRender(boolean)
         */
        @Override
-       public void prepareForRender(boolean setRenderingFlag)
+       public void internalPrepareForRender(boolean setRenderingFlag)
        {
                if (!getFlag(FLAG_INITIALIZED))
                {
                        // initialize the page if not yet initialized
                        initialize();
                }
-               super.prepareForRender(setRenderingFlag);
+               super.internalPrepareForRender(setRenderingFlag);
        }
 
        /**

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProvider.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProvider.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProvider.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProvider.java
 Fri Dec  3 19:05:33 2010
@@ -19,7 +19,6 @@ package org.apache.wicket.markup;
 import java.util.Locale;
 
 import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.util.string.AppendingStringBuffer;
 
 
 /**
@@ -40,7 +39,7 @@ public class DefaultMarkupCacheKeyProvid
 
        /**
         * Construct a proper key value for the cache
-        *
+        * 
         * @param container
         *            The container requesting the markup
         * @param clazz
@@ -51,7 +50,7 @@ public class DefaultMarkupCacheKeyProvid
        public String getCacheKey(final MarkupContainer container, final 
Class<?> clazz)
        {
                final String classname = clazz.getName();
-               final AppendingStringBuffer buffer = new 
AppendingStringBuffer(classname.length() + 64);
+               final StringBuilder buffer = new 
StringBuilder(classname.length() + 64);
                buffer.append(classname);
 
                final Locale locale = container.getLocale();
@@ -63,7 +62,7 @@ public class DefaultMarkupCacheKeyProvid
                        final boolean hasLocale = locale.getLanguage().length() 
!= 0;
                        final boolean hasCountry = locale.getCountry().length() 
!= 0;
                        final boolean hasVariant = locale.getVariant().length() 
!= 0;
-                       
+
                        if (hasCountry || (hasLocale && hasVariant))
                        {
                                buffer.append('_').append(locale.getCountry());
@@ -74,13 +73,16 @@ public class DefaultMarkupCacheKeyProvid
                        }
                }
                if (container.getStyle() != null)
+               {
                        buffer.append('_').append(container.getStyle());
+               }
 
                if (container.getVariation() != null)
+               {
                        buffer.append('_').append(container.getVariation());
+               }
 
                
buffer.append('.').append(container.getMarkupType().getExtension());
-
                return buffer.toString();
        }
 }

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=1041955&r1=1041954&r2=1041955&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 Dec  3 19:05:33 2010
@@ -21,8 +21,8 @@ import org.apache.wicket.settings.IMarku
 
 /**
  * Each Wicket application has a single IMarkupCache associated with it (see 
{...@link IMarkupSettings}
- * ). The markup cache is used by every Component to get its associated markup 
stream. Note that it
- * is the markup caches responsibility to load the markup, if not yet done.
+ * ). Via {...@link MarkupFactory} the markup cache is used by every Component 
to get its associated
+ * markup stream.
  * 
  * @author Juergen Donnerstag
  */

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=1041955&r1=1041954&r2=1041955&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 Dec  3 19:05:33 2010
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
  * version.
  * 
  * @see IMarkupSettings
+ * @see MarkupFactory
  * 
  * @author Jonathan Locke
  * @author Juergen Donnerstag
@@ -52,10 +53,10 @@ public class MarkupCache implements IMar
        /** Log for reporting. */
        private static final Logger log = 
LoggerFactory.getLogger(MarkupCache.class);
 
-       /** Map of markup tags by class (exactly what is in the file). */
+       /** The actual cache: location => Markup */
        private final ICache<CharSequence, Markup> markupCache;
 
-       /** Map of markup tags by class (exactly what is in the file). */
+       /** Add extra indirection to the cache: key => location */
        private final ICache<CharSequence, CharSequence> markupKeyCache;
 
        /** The markup cache key provider used by MarkupCache */
@@ -378,7 +379,7 @@ public class MarkupCache implements IMar
        {
                if (cacheKey != null)
                {
-                       String locationString = 
(String)markupKeyCache.get(cacheKey);
+                       CharSequence locationString = 
markupKeyCache.get(cacheKey);
                        if (locationString != null)
                        {
                                return markupCache.get(locationString);

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
 Fri Dec  3 19:05:33 2010
@@ -166,7 +166,6 @@ public class Fragment extends WebMarkupC
        private void renderFragment(final ComponentTag openTag)
        {
                MarkupStream stream = new MarkupStream(getMarkup(null));
-               setMarkupStream(stream);
 
                // Get the fragments open tag
                ComponentTag fragmentOpenTag = stream.getTag();

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
 Fri Dec  3 19:05:33 2010
@@ -47,8 +47,8 @@ import org.slf4j.LoggerFactory;
  * "autolink" by the MarkupParser for all tags with href attribute, such as 
anchor and link tags
  * with no explicit wicket id. E.g. &lt;a href="Home.html"&gt;
  * <p>
- * If href points to a *.html file, a BookmarkablePageLink<?> will 
automatically be created, except for
- * absolute paths, where an ExternalLink is created.
+ * If href points to a *.html file, a BookmarkablePageLink<?> will 
automatically be created, except
+ * for absolute paths, where an ExternalLink is created.
  * <p>
  * If href points to a *.html file, it resolves the given URL by searching for 
a page class, either
  * relative or absolute, specified by the href attribute of the tag. If 
relative the href URL must
@@ -90,22 +90,22 @@ public final class AutoLinkResolver impl
                {
                        if (!pathInfo.absolute && (pathInfo.path != null) && 
(pathInfo.path.length() > 0))
                        {
-                               // Href is relative. Create a resource 
reference pointing at
-                               // this file
+                               // Href is relative. Create a resource 
reference pointing at this file
 
                                // <wicket:head> components are handled 
differently. We can
                                // not use the container, because it is the 
container the
                                // header has been added to (e.g. the Page). 
What we need
                                // however, is the component (e.g. a Panel) 
which
                                // contributed it.
-                               Class<? extends Component> clazz = 
container.getMarkupStream().getContainerClass();
+                               MarkupStream markupStream = new 
MarkupStream(container.getMarkup());
+                               Class<? extends Component> clazz = 
markupStream.getContainerClass();
 
                                // However if the markup stream is a merged 
markup stream (inheritance), than we
                                // need the class of the markup file which 
contained the tag.
-                               if ((container.getMarkupStream().get() 
instanceof ComponentTag) &&
-                                       
(container.getMarkupStream().getTag().getMarkupClass() != null))
+                               if ((markupStream.get() instanceof 
ComponentTag) &&
+                                       (markupStream.getTag().getMarkupClass() 
!= null))
                                {
-                                       clazz = 
container.getMarkupStream().getTag().getMarkupClass();
+                                       clazz = 
markupStream.getTag().getMarkupClass();
                                }
 
                                // Create the component implementing the link
@@ -441,11 +441,10 @@ public final class AutoLinkResolver impl
                                        parentWithContainer = 
container.findParentWithAssociatedMarkup();
                                }
                                if ((parentWithContainer instanceof Page) && 
!pathInfo.path.startsWith("/") &&
-                                       page.getMarkupStream().isMergedMarkup())
+                                       new 
MarkupStream(page.getMarkup()).isMergedMarkup())
                                {
-                                       Class<? extends Page> clazz = (Class<? 
extends Page>)container.getMarkupStream()
-                                               .getTag()
-                                               .getMarkupClass();
+                                       Class<? extends Page> clazz = (Class<? 
extends Page>)new MarkupStream(
+                                               
container.getMarkup()).getTag().getMarkupClass();
                                        if (clazz != null)
                                        {
                                                // Href is relative. Resolve 
the url given relative to

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/handler/PageProvider.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/request/handler/PageProvider.java?rev=1041955&r1=1041954&r2=1041955&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/handler/PageProvider.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/request/handler/PageProvider.java
 Fri Dec  3 19:05:33 2010
@@ -260,7 +260,7 @@ public class PageProvider implements IPa
                                freshCreated = true;
                                if (prepareForRenderNewPage() && page 
instanceof Page)
                                {
-                                       ((Page)page).prepareForRender(false);
+                                       
((Page)page).internalPrepareForRender(false);
                                }
                        }
                }


Reply via email to