tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1094827 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
Date Tue, 19 Apr 2011 00:18:34 GMT
Author: hlship
Date: Tue Apr 19 00:18:34 2011
New Revision: 1094827

URL: http://svn.apache.org/viewvc?rev=1094827&view=rev
Log:
TAP5-1508: Create a mapping of nested component ids to component page elements, inside PageImpl

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java?rev=1094827&r1=1094826&r2=1094827&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
Tue Apr 19 00:18:34 2011
@@ -16,11 +16,12 @@ package org.apache.tapestry5.internal.st
 
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Pattern;
 
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.internal.services.PersistentFieldManager;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.internal.util.OneShotLock;
 import org.apache.tapestry5.ioc.services.PerThreadValue;
 import org.apache.tapestry5.ioc.services.PerthreadManager;
@@ -47,6 +48,8 @@ public class PageImpl implements Page
 
     private final OneShotLock lock = new OneShotLock();
 
+    private final Map<String, ComponentPageElement> idToComponent = CollectionFactory.newCaseInsensitiveMap();
+
     /**
      * Obtained from the {@link org.apache.tapestry5.internal.services.PersistentFieldManager}
when
      * first needed,
@@ -54,6 +57,8 @@ public class PageImpl implements Page
      */
     private final PerThreadValue<PersistentFieldBundle> fieldBundle;
 
+    private static final Pattern SPLIT_ON_DOT = Pattern.compile("\\.");
+
     /**
      * @param name
      *            canonicalized page name
@@ -80,15 +85,25 @@ public class PageImpl implements Page
         return String.format("Page[%s %s]", name, locale);
     }
 
-    public ComponentPageElement getComponentElementByNestedId(String nestedId)
+    public synchronized ComponentPageElement getComponentElementByNestedId(String nestedId)
     {
         assert nestedId != null;
-        ComponentPageElement element = rootElement;
 
-        if (InternalUtils.isNonBlank(nestedId))
+        if (nestedId.equals(""))
+            return rootElement;
+
+        ComponentPageElement element = idToComponent.get(nestedId);
+
+        if (element == null)
         {
-            for (String id : nestedId.split("\\."))
+            element = rootElement;
+
+            for (String id : SPLIT_ON_DOT.split(nestedId))
+            {
                 element = element.getEmbeddedElement(id);
+            }
+
+            idToComponent.put(nestedId, element);
         }
 
         return element;



Mime
View raw message